@openrewrite/recipes-angular 1.17.0 → 1.19.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 (173) hide show
  1. package/dist/index.d.ts +12 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +83 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/libraries/cdk/find-cdk-signature-changes.d.ts +48 -0
  6. package/dist/libraries/cdk/find-cdk-signature-changes.d.ts.map +1 -0
  7. package/dist/libraries/cdk/find-cdk-signature-changes.js +323 -0
  8. package/dist/libraries/cdk/find-cdk-signature-changes.js.map +1 -0
  9. package/dist/libraries/cdk/find-removed-cdk-apis.d.ts +32 -0
  10. package/dist/libraries/cdk/find-removed-cdk-apis.d.ts.map +1 -0
  11. package/dist/libraries/cdk/find-removed-cdk-apis.js +75 -0
  12. package/dist/libraries/cdk/find-removed-cdk-apis.js.map +1 -0
  13. package/dist/libraries/cdk/migrate-cdk-sass-imports.d.ts +17 -0
  14. package/dist/libraries/cdk/migrate-cdk-sass-imports.d.ts.map +1 -0
  15. package/dist/libraries/cdk/migrate-cdk-sass-imports.js +177 -0
  16. package/dist/libraries/cdk/migrate-cdk-sass-imports.js.map +1 -0
  17. package/dist/libraries/cdk/migrate-cdk-stepper.d.ts +8 -0
  18. package/dist/libraries/cdk/migrate-cdk-stepper.d.ts.map +1 -0
  19. package/dist/libraries/cdk/migrate-cdk-stepper.js +92 -0
  20. package/dist/libraries/cdk/migrate-cdk-stepper.js.map +1 -0
  21. package/dist/libraries/cdk/migrate-deprecated-overlay-sass.d.ts +9 -0
  22. package/dist/libraries/cdk/migrate-deprecated-overlay-sass.d.ts.map +1 -0
  23. package/dist/libraries/cdk/migrate-deprecated-overlay-sass.js +57 -0
  24. package/dist/libraries/cdk/migrate-deprecated-overlay-sass.js.map +1 -0
  25. package/dist/libraries/cdk/migrate-drag-drop-registry.d.ts +8 -0
  26. package/dist/libraries/cdk/migrate-drag-drop-registry.d.ts.map +1 -0
  27. package/dist/libraries/cdk/migrate-drag-drop-registry.js +118 -0
  28. package/dist/libraries/cdk/migrate-drag-drop-registry.js.map +1 -0
  29. package/dist/libraries/cdk/migrate-focus-trap-factory-create.d.ts +8 -0
  30. package/dist/libraries/cdk/migrate-focus-trap-factory-create.d.ts.map +1 -0
  31. package/dist/libraries/cdk/migrate-focus-trap-factory-create.js +74 -0
  32. package/dist/libraries/cdk/migrate-focus-trap-factory-create.js.map +1 -0
  33. package/dist/libraries/cdk/remove-cdk-super-arguments.d.ts +8 -0
  34. package/dist/libraries/cdk/remove-cdk-super-arguments.d.ts.map +1 -0
  35. package/dist/libraries/cdk/remove-cdk-super-arguments.js +111 -0
  36. package/dist/libraries/cdk/remove-cdk-super-arguments.js.map +1 -0
  37. package/dist/libraries/cdk/remove-portal-factory-resolver-arguments.d.ts +8 -0
  38. package/dist/libraries/cdk/remove-portal-factory-resolver-arguments.d.ts.map +1 -0
  39. package/dist/libraries/cdk/remove-portal-factory-resolver-arguments.js +108 -0
  40. package/dist/libraries/cdk/remove-portal-factory-resolver-arguments.js.map +1 -0
  41. package/dist/libraries/cdk/remove-tilde-from-stylesheet-imports.d.ts +8 -0
  42. package/dist/libraries/cdk/remove-tilde-from-stylesheet-imports.d.ts.map +1 -0
  43. package/dist/libraries/cdk/remove-tilde-from-stylesheet-imports.js +27 -0
  44. package/dist/libraries/cdk/remove-tilde-from-stylesheet-imports.js.map +1 -0
  45. package/dist/libraries/cdk/rename-portal-template-selectors.d.ts +27 -0
  46. package/dist/libraries/cdk/rename-portal-template-selectors.d.ts.map +1 -0
  47. package/dist/libraries/cdk/rename-portal-template-selectors.js +75 -0
  48. package/dist/libraries/cdk/rename-portal-template-selectors.js.map +1 -0
  49. package/dist/libraries/cdk/upgrade-to-cdk.d.ts +38 -0
  50. package/dist/libraries/cdk/upgrade-to-cdk.d.ts.map +1 -0
  51. package/dist/libraries/cdk/upgrade-to-cdk.js +173 -0
  52. package/dist/libraries/cdk/upgrade-to-cdk.js.map +1 -0
  53. package/dist/libraries/components/lst.d.ts +9 -0
  54. package/dist/libraries/components/lst.d.ts.map +1 -0
  55. package/dist/libraries/components/lst.js +37 -0
  56. package/dist/libraries/components/lst.js.map +1 -0
  57. package/dist/libraries/components/stylesheets.d.ts +13 -0
  58. package/dist/libraries/components/stylesheets.d.ts.map +1 -0
  59. package/dist/libraries/components/stylesheets.js +71 -0
  60. package/dist/libraries/components/stylesheets.js.map +1 -0
  61. package/dist/libraries/components/symbols.d.ts +27 -0
  62. package/dist/libraries/components/symbols.d.ts.map +1 -0
  63. package/dist/libraries/components/symbols.js +120 -0
  64. package/dist/libraries/components/symbols.js.map +1 -0
  65. package/dist/libraries/components/templates.d.ts +24 -0
  66. package/dist/libraries/components/templates.d.ts.map +1 -0
  67. package/dist/libraries/components/templates.js +141 -0
  68. package/dist/libraries/components/templates.js.map +1 -0
  69. package/dist/libraries/primeng/18/mark-deprecated-components.d.ts.map +1 -1
  70. package/dist/libraries/primeng/18/mark-deprecated-components.js +9 -5
  71. package/dist/libraries/primeng/18/mark-deprecated-components.js.map +1 -1
  72. package/dist/migration/add-trust-proxy-headers.d.ts.map +1 -1
  73. package/dist/migration/add-trust-proxy-headers.js +2 -1
  74. package/dist/migration/add-trust-proxy-headers.js.map +1 -1
  75. package/dist/migration/migrate-to-solution-style-tsconfig.d.ts.map +1 -1
  76. package/dist/migration/migrate-to-solution-style-tsconfig.js +6 -8
  77. package/dist/migration/migrate-to-solution-style-tsconfig.js.map +1 -1
  78. package/dist/migration/replace-angular-http-imports.js +1 -1
  79. package/dist/migration/replace-angular-http-imports.js.map +1 -1
  80. package/dist/migration/replace-initial-navigation.d.ts.map +1 -1
  81. package/dist/migration/replace-initial-navigation.js +2 -2
  82. package/dist/migration/replace-initial-navigation.js.map +1 -1
  83. package/dist/migration/replace-node-sass-with-sass.d.ts.map +1 -1
  84. package/dist/migration/replace-node-sass-with-sass.js +5 -2
  85. package/dist/migration/replace-node-sass-with-sass.js.map +1 -1
  86. package/dist/migration/update-component-template-url.js +1 -1
  87. package/dist/migration/update-component-template-url.js.map +1 -1
  88. package/dist/migration/upgrade-angular-dependencies.d.ts +3 -0
  89. package/dist/migration/upgrade-angular-dependencies.d.ts.map +1 -0
  90. package/dist/migration/upgrade-angular-dependencies.js +25 -0
  91. package/dist/migration/upgrade-angular-dependencies.js.map +1 -0
  92. package/dist/migration/upgrade-to-angular-10.d.ts.map +1 -1
  93. package/dist/migration/upgrade-to-angular-10.js +14 -17
  94. package/dist/migration/upgrade-to-angular-10.js.map +1 -1
  95. package/dist/migration/upgrade-to-angular-11.d.ts.map +1 -1
  96. package/dist/migration/upgrade-to-angular-11.js +14 -17
  97. package/dist/migration/upgrade-to-angular-11.js.map +1 -1
  98. package/dist/migration/upgrade-to-angular-12.d.ts.map +1 -1
  99. package/dist/migration/upgrade-to-angular-12.js +12 -14
  100. package/dist/migration/upgrade-to-angular-12.js.map +1 -1
  101. package/dist/migration/upgrade-to-angular-13.d.ts.map +1 -1
  102. package/dist/migration/upgrade-to-angular-13.js +14 -14
  103. package/dist/migration/upgrade-to-angular-13.js.map +1 -1
  104. package/dist/migration/upgrade-to-angular-14.d.ts.map +1 -1
  105. package/dist/migration/upgrade-to-angular-14.js +14 -14
  106. package/dist/migration/upgrade-to-angular-14.js.map +1 -1
  107. package/dist/migration/upgrade-to-angular-15.d.ts.map +1 -1
  108. package/dist/migration/upgrade-to-angular-15.js +11 -12
  109. package/dist/migration/upgrade-to-angular-15.js.map +1 -1
  110. package/dist/migration/upgrade-to-angular-16.d.ts.map +1 -1
  111. package/dist/migration/upgrade-to-angular-16.js +12 -13
  112. package/dist/migration/upgrade-to-angular-16.js.map +1 -1
  113. package/dist/migration/upgrade-to-angular-17.d.ts.map +1 -1
  114. package/dist/migration/upgrade-to-angular-17.js +14 -14
  115. package/dist/migration/upgrade-to-angular-17.js.map +1 -1
  116. package/dist/migration/upgrade-to-angular-18.d.ts.map +1 -1
  117. package/dist/migration/upgrade-to-angular-18.js +12 -13
  118. package/dist/migration/upgrade-to-angular-18.js.map +1 -1
  119. package/dist/migration/upgrade-to-angular-19.d.ts.map +1 -1
  120. package/dist/migration/upgrade-to-angular-19.js +12 -13
  121. package/dist/migration/upgrade-to-angular-19.js.map +1 -1
  122. package/dist/migration/upgrade-to-angular-20.d.ts.map +1 -1
  123. package/dist/migration/upgrade-to-angular-20.js +13 -12
  124. package/dist/migration/upgrade-to-angular-20.js.map +1 -1
  125. package/dist/migration/upgrade-to-angular-21.d.ts.map +1 -1
  126. package/dist/migration/upgrade-to-angular-21.js +13 -12
  127. package/dist/migration/upgrade-to-angular-21.js.map +1 -1
  128. package/dist/migration/upgrade-to-angular-22.d.ts.map +1 -1
  129. package/dist/migration/upgrade-to-angular-22.js +13 -12
  130. package/dist/migration/upgrade-to-angular-22.js.map +1 -1
  131. package/dist/migration/upgrade-to-angular-9.d.ts.map +1 -1
  132. package/dist/migration/upgrade-to-angular-9.js +14 -17
  133. package/dist/migration/upgrade-to-angular-9.js.map +1 -1
  134. package/package.json +2 -2
  135. package/src/index.ts +97 -0
  136. package/src/libraries/cdk/find-cdk-signature-changes.ts +209 -0
  137. package/src/libraries/cdk/find-removed-cdk-apis.ts +76 -0
  138. package/src/libraries/cdk/migrate-cdk-sass-imports.ts +174 -0
  139. package/src/libraries/cdk/migrate-cdk-stepper.ts +58 -0
  140. package/src/libraries/cdk/migrate-deprecated-overlay-sass.ts +56 -0
  141. package/src/libraries/cdk/migrate-drag-drop-registry.ts +79 -0
  142. package/src/libraries/cdk/migrate-focus-trap-factory-create.ts +51 -0
  143. package/src/libraries/cdk/remove-cdk-super-arguments.ts +83 -0
  144. package/src/libraries/cdk/remove-portal-factory-resolver-arguments.ts +88 -0
  145. package/src/libraries/cdk/remove-tilde-from-stylesheet-imports.ts +22 -0
  146. package/src/libraries/cdk/rename-portal-template-selectors.ts +51 -0
  147. package/src/libraries/cdk/upgrade-to-cdk.ts +146 -0
  148. package/src/libraries/components/lst.ts +33 -0
  149. package/src/libraries/components/stylesheets.ts +55 -0
  150. package/src/libraries/components/symbols.ts +116 -0
  151. package/src/libraries/components/templates.ts +126 -0
  152. package/src/libraries/primeng/18/mark-deprecated-components.ts +8 -4
  153. package/src/migration/add-trust-proxy-headers.ts +2 -1
  154. package/src/migration/migrate-to-solution-style-tsconfig.ts +10 -9
  155. package/src/migration/replace-angular-http-imports.ts +2 -2
  156. package/src/migration/replace-initial-navigation.ts +3 -1
  157. package/src/migration/replace-node-sass-with-sass.ts +6 -3
  158. package/src/migration/update-component-template-url.ts +1 -1
  159. package/src/migration/upgrade-angular-dependencies.ts +28 -0
  160. package/src/migration/upgrade-to-angular-10.ts +14 -17
  161. package/src/migration/upgrade-to-angular-11.ts +14 -17
  162. package/src/migration/upgrade-to-angular-12.ts +12 -14
  163. package/src/migration/upgrade-to-angular-13.ts +14 -14
  164. package/src/migration/upgrade-to-angular-14.ts +14 -14
  165. package/src/migration/upgrade-to-angular-15.ts +11 -12
  166. package/src/migration/upgrade-to-angular-16.ts +13 -14
  167. package/src/migration/upgrade-to-angular-17.ts +14 -14
  168. package/src/migration/upgrade-to-angular-18.ts +13 -14
  169. package/src/migration/upgrade-to-angular-19.ts +13 -14
  170. package/src/migration/upgrade-to-angular-20.ts +13 -12
  171. package/src/migration/upgrade-to-angular-21.ts +13 -12
  172. package/src/migration/upgrade-to-angular-22.ts +13 -12
  173. package/src/migration/upgrade-to-angular-9.ts +14 -17
@@ -0,0 +1,58 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
9
+ import {isIdentifier, J} from "@openrewrite/rewrite/java";
10
+ import {create} from "mutative";
11
+ import {importedNames} from "../components/symbols";
12
+ import {extendedClassName, isSuperCall} from "../components/lst";
13
+ import {argumentCount, isCdkClass} from "./find-cdk-signature-changes";
14
+
15
+ export class MigrateCdkStepper extends Recipe {
16
+ readonly name = "org.openrewrite.angular.cdk.MigrateCdkStepper";
17
+ readonly displayName = "Migrate `CdkStepper` subclasses to CDK 14";
18
+ readonly description = "CDK 14 made `CdkStepper._orientation` private and removed the deprecated `_document` " +
19
+ "constructor parameter. Replaces `_orientation` with the public `orientation` property and removes the fourth " +
20
+ "argument of `super(...)` in classes that extend `CdkStepper`.";
21
+
22
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
23
+ return new class extends JavaScriptVisitor<ExecutionContext> {
24
+ private stepper = new Map<string, string>();
25
+
26
+ protected async visitJsCompilationUnit(cu: JS.CompilationUnit, p: ExecutionContext): Promise<J | undefined> {
27
+ this.stepper = importedNames(cu, '@angular/cdk/stepper', ['CdkStepper']);
28
+ return super.visitJsCompilationUnit(cu, p);
29
+ }
30
+
31
+ protected async visitFieldAccess(fieldAccess: J.FieldAccess, p: ExecutionContext): Promise<J | undefined> {
32
+ const f = await super.visitFieldAccess(fieldAccess, p) as J.FieldAccess;
33
+ const name = f.name.element;
34
+ if (name.simpleName !== '_orientation') return f;
35
+ const declaredByStepper = isCdkClass(name.fieldType?.owner, 'CdkStepper') ||
36
+ (isIdentifier(f.target) && f.target.simpleName === 'this' && this.insideStepperSubclass());
37
+ if (!declaredByStepper) return f;
38
+ return create(f, draft => {
39
+ draft.name.element.simpleName = 'orientation';
40
+ });
41
+ }
42
+
43
+ protected async visitFunctionCall(functionCall: JS.FunctionCall, p: ExecutionContext): Promise<J | undefined> {
44
+ const call = await super.visitFunctionCall(functionCall, p) as JS.FunctionCall;
45
+ if (!isSuperCall(call) || argumentCount(call.arguments) !== 4 || !this.insideStepperSubclass()) return call;
46
+ const elements = call.arguments.elements;
47
+ const retained = [...elements.slice(0, 2), {...elements[2], after: elements[3].after}];
48
+ return {...call, arguments: {...call.arguments, elements: retained}} as JS.FunctionCall;
49
+ }
50
+
51
+ private insideStepperSubclass(): boolean {
52
+ const classDecl = this.cursor.firstEnclosing((t: any): t is J.ClassDeclaration => t?.kind === J.Kind.ClassDeclaration);
53
+ const extended = classDecl && extendedClassName(classDecl);
54
+ return extended !== undefined && this.stepper.has(extended);
55
+ }
56
+ }();
57
+ }
58
+ }
@@ -0,0 +1,56 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ import {escapeRegExp, StylesheetRecipe, withoutComments} from "../components/stylesheets";
8
+
9
+ const DEPRECATED_USE = /@use\s+(['"])~?@angular\/cdk\/overlay\/_?index-deprecated(?:\.scss)?\1(?:\s+as\s+([\w-]+|\*))?\s*;[ \t]*(\r?\n)?/g;
10
+
11
+ const OVERLAY_USE = /@use\s+(['"])~?@angular\/cdk\/overlay\1(?:\s+as\s+overlay)?\s*;/;
12
+
13
+ /** The variables of `overlay/_index-deprecated.scss`, mapped to the `@angular/cdk/overlay` names they aliased. */
14
+ const VARIABLES: Record<string, string> = {
15
+ 'z-index-overlay-container': 'overlay-container-z-index',
16
+ 'z-index-overlay-backdrop': 'overlay-backdrop-z-index',
17
+ 'z-index-overlay': 'overlay-z-index',
18
+ 'dark-backdrop-background': 'overlay-backdrop-color',
19
+ };
20
+
21
+ export class MigrateDeprecatedOverlaySass extends StylesheetRecipe {
22
+ readonly name = "org.openrewrite.angular.cdk.MigrateDeprecatedOverlaySass";
23
+ readonly displayName = "Migrate the removed CDK overlay Sass variables";
24
+ readonly description = "CDK 21 deleted `@angular/cdk/overlay/index-deprecated` and its `$z-index-overlay-container`, " +
25
+ "`$z-index-overlay`, `$z-index-overlay-backdrop` and `$dark-backdrop-background` variables. Replaces the `@use` " +
26
+ "with `@angular/cdk/overlay` and renames the variables to `$overlay-container-z-index`, `$overlay-z-index`, " +
27
+ "`$overlay-backdrop-z-index` and `$overlay-backdrop-color`.";
28
+
29
+ protected acceptsPath(sourcePath: string): boolean {
30
+ return sourcePath.endsWith('.scss');
31
+ }
32
+
33
+ protected migrate(content: string): string {
34
+ if (!content.includes('index-deprecated')) return content;
35
+ return withoutComments(content, migrateDeprecatedOverlay);
36
+ }
37
+ }
38
+
39
+ function migrateDeprecatedOverlay(content: string): string {
40
+ const hasOverlayUse = OVERLAY_USE.test(content);
41
+ let migrated = content;
42
+ for (const match of [...content.matchAll(DEPRECATED_USE)]) {
43
+ const [rule, quote, alias, newline = ''] = match;
44
+ const namespace = alias ?? 'index-deprecated';
45
+ const newNamespace = alias ?? 'overlay';
46
+ const replacement = alias !== undefined ? `@use ${quote}@angular/cdk/overlay${quote} as ${alias};${newline}`
47
+ : hasOverlayUse ? '' : `@use ${quote}@angular/cdk/overlay${quote};${newline}`;
48
+ migrated = migrated.replace(rule, replacement);
49
+ for (const [name, newName] of Object.entries(VARIABLES)) {
50
+ const reference = namespace === '*' ? `(?<![\\w.-])\\$${name}` : `(?<![\\w-])${escapeRegExp(namespace)}\\.\\$${name}`;
51
+ const renamed = newNamespace === '*' ? `$${newName}` : `${newNamespace}.$${newName}`;
52
+ migrated = migrated.replace(new RegExp(`${reference}(?![\\w-])`, 'g'), renamed);
53
+ }
54
+ }
55
+ return migrated;
56
+ }
@@ -0,0 +1,79 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ import {emptyMarkers, ExecutionContext, foundSearchResult, randomId, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
9
+ import {emptySpace, Expression, isIdentifier, J} from "@openrewrite/rewrite/java";
10
+ import {importedNames} from "../components/symbols";
11
+ import {emptyArguments} from "../components/lst";
12
+ import {isCdkClass} from "./find-cdk-signature-changes";
13
+
14
+ /** Observable operators that `scrolled()` supports as well as the `scroll` subject did. */
15
+ const OBSERVABLE_METHODS = ['pipe', 'subscribe'];
16
+
17
+ export class MigrateDragDropRegistry extends Recipe {
18
+ readonly name = "org.openrewrite.angular.cdk.MigrateDragDropRegistry";
19
+ readonly displayName = "Migrate `DragDropRegistry` to CDK 20";
20
+ readonly description = "CDK 20 made `DragDropRegistry` non-generic and removed its `scroll` subject. Removes the type " +
21
+ "arguments of `DragDropRegistry<...>`, rewrites `registry.scroll.pipe(...)` and `registry.scroll.subscribe(...)` " +
22
+ "to the `scrolled()` method, and marks other uses of `scroll`, which relied on it being a `Subject`.";
23
+
24
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
25
+ return new class extends JavaScriptVisitor<ExecutionContext> {
26
+ private registry = new Map<string, string>();
27
+
28
+ protected async visitJsCompilationUnit(cu: JS.CompilationUnit, p: ExecutionContext): Promise<J | undefined> {
29
+ this.registry = importedNames(cu, '@angular/cdk/drag-drop', ['DragDropRegistry']);
30
+ return super.visitJsCompilationUnit(cu, p);
31
+ }
32
+
33
+ protected async visitParameterizedType(type: J.ParameterizedType, p: ExecutionContext): Promise<J | undefined> {
34
+ const t = await super.visitParameterizedType(type, p) as J.ParameterizedType;
35
+ if (!isIdentifier(t.class) || !this.registry.has(t.class.simpleName)) return t;
36
+ return {...t.class, prefix: t.prefix};
37
+ }
38
+
39
+ protected async visitMethodInvocation(method: J.MethodInvocation, p: ExecutionContext): Promise<J | undefined> {
40
+ const m = await super.visitMethodInvocation(method, p) as J.MethodInvocation;
41
+ const select = m.select?.element;
42
+ if (!OBSERVABLE_METHODS.includes(m.name.simpleName) || !isRegistryScroll(select)) return m;
43
+ return {...m, select: {...m.select!, element: scrolledCall(select as J.FieldAccess)}} as J.MethodInvocation;
44
+ }
45
+
46
+ protected async visitFieldAccess(fieldAccess: J.FieldAccess, p: ExecutionContext): Promise<J | undefined> {
47
+ const f = await super.visitFieldAccess(fieldAccess, p) as J.FieldAccess;
48
+ if (!isRegistryScroll(f)) return f;
49
+ const parent = this.cursor.parentTree()?.value;
50
+ if (parent?.kind === J.Kind.MethodInvocation && OBSERVABLE_METHODS.includes((parent as J.MethodInvocation).name.simpleName)) {
51
+ return f;
52
+ }
53
+ return foundSearchResult(f, "`DragDropRegistry.scroll` was removed in @angular/cdk 20. " +
54
+ "Use the `scrolled()` method, which returns an `Observable` instead of a `Subject`.");
55
+ }
56
+ }();
57
+ }
58
+ }
59
+
60
+ function isRegistryScroll(expression: J | undefined): boolean {
61
+ if (expression?.kind !== J.Kind.FieldAccess) return false;
62
+ const name = (expression as J.FieldAccess).name.element;
63
+ return name.simpleName === 'scroll' && isCdkClass(name.fieldType?.owner, 'DragDropRegistry');
64
+ }
65
+
66
+ /** `registry.scroll` rebuilt as `registry.scrolled()`, keeping the receiver and its formatting. */
67
+ function scrolledCall(scroll: J.FieldAccess): J.MethodInvocation {
68
+ const name = scroll.name.element;
69
+ return {
70
+ kind: J.Kind.MethodInvocation,
71
+ id: randomId(),
72
+ prefix: scroll.prefix,
73
+ markers: emptyMarkers,
74
+ select: {kind: J.Kind.RightPadded, element: scroll.target, after: scroll.name.before, markers: emptyMarkers} as J.RightPadded<Expression>,
75
+ name: {...name, simpleName: 'scrolled', fieldType: undefined, type: undefined},
76
+ arguments: emptyArguments({kind: J.Kind.Container, before: emptySpace, elements: [], markers: emptyMarkers} as J.Container<Expression>),
77
+ methodType: undefined,
78
+ } as J.MethodInvocation;
79
+ }
@@ -0,0 +1,51 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ import {ExecutionContext, foundSearchResult, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {JavaScriptVisitor, Template} from "@openrewrite/rewrite/javascript";
9
+ import {isLiteral, J, Type} from "@openrewrite/rewrite/java";
10
+ import {argumentCount, isCdkClass} from "./find-cdk-signature-changes";
11
+
12
+ export class MigrateFocusTrapFactoryCreate extends Recipe {
13
+ readonly name = "org.openrewrite.angular.cdk.MigrateFocusTrapFactoryCreate";
14
+ readonly displayName = "Pass a config object to `ConfigurableFocusTrapFactory.create`";
15
+ readonly description = "CDK 22 removed the `create(element, deferCaptureElements: boolean)` overload of " +
16
+ "`ConfigurableFocusTrapFactory`. Rewrites `create(element, true)` to `create(element, {defer: true})`, and marks " +
17
+ "calls whose second argument is a boolean expression other than a literal.";
18
+
19
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
20
+ return new class extends JavaScriptVisitor<ExecutionContext> {
21
+ protected async visitMethodInvocation(method: J.MethodInvocation, p: ExecutionContext): Promise<J | undefined> {
22
+ const m = await super.visitMethodInvocation(method, p) as J.MethodInvocation;
23
+ if (m.name.simpleName !== 'create' || argumentCount(m.arguments) !== 2) return m;
24
+ if (!isCdkClass(m.methodType?.declaringType, 'ConfigurableFocusTrapFactory')) return m;
25
+
26
+ const args = m.arguments.elements;
27
+ const defer = args[1].element;
28
+ if (isLiteral(defer) && typeof defer.value === 'boolean') {
29
+ const applied = await Template.builder()
30
+ .code(`create(element, {defer: ${defer.value}})`)
31
+ .build()
32
+ .apply(m, this.cursor) as J.MethodInvocation;
33
+ const config = applied.arguments?.elements?.[1]?.element;
34
+ if (!config) return m;
35
+ const elements = [args[0], {...args[1], element: {...config, prefix: defer.prefix}}];
36
+ return {...m, arguments: {...m.arguments, elements}} as J.MethodInvocation;
37
+ }
38
+ if (isBoolean(defer)) {
39
+ return foundSearchResult(m, "The boolean overload of `ConfigurableFocusTrapFactory.create` was " +
40
+ "removed in @angular/cdk 22. Pass `{defer: <value>}` instead.");
41
+ }
42
+ return m;
43
+ }
44
+ }();
45
+ }
46
+ }
47
+
48
+ function isBoolean(expression: J): boolean {
49
+ const type = (expression as J & {type?: Type}).type;
50
+ return Type.isPrimitive(type) && type.keyword === 'boolean';
51
+ }
@@ -0,0 +1,83 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
9
+ import {J} from "@openrewrite/rewrite/java";
10
+ import {importedNames} from "../components/symbols";
11
+ import {emptyArguments, extendedClassName, isSuperCall} from "../components/lst";
12
+ import {argumentCount} from "./find-cdk-signature-changes";
13
+
14
+ /** Classes whose constructor was `constructor(...args: unknown[])` in CDK 21 and takes no arguments in CDK 22. */
15
+ const ZERO_ARGUMENT_CONSTRUCTORS: Record<string, string[]> = {
16
+ '@angular/cdk/a11y': [
17
+ 'AriaDescriber', 'CdkAriaLive', 'CdkMonitorFocus', 'CdkTrapFocus', 'ConfigurableFocusTrapFactory',
18
+ 'FocusMonitor', 'FocusTrapFactory', 'HighContrastModeDetector', 'InputModalityDetector',
19
+ 'InteractivityChecker', 'LiveAnnouncer'
20
+ ],
21
+ '@angular/cdk/accordion': ['CdkAccordionItem'],
22
+ '@angular/cdk/bidi': ['Directionality'],
23
+ '@angular/cdk/clipboard': ['CdkCopyToClipboard', 'Clipboard'],
24
+ '@angular/cdk/dialog': ['CdkDialogContainer', 'Dialog'],
25
+ '@angular/cdk/drag-drop': [
26
+ 'CdkDrag', 'CdkDragHandle', 'CdkDragPlaceholder', 'CdkDragPreview', 'CdkDropList', 'DragDrop',
27
+ 'DragDropRegistry'
28
+ ],
29
+ '@angular/cdk/layout': ['BreakpointObserver', 'MediaMatcher'],
30
+ '@angular/cdk/observers': ['CdkObserveContent', 'ContentObserver'],
31
+ '@angular/cdk/overlay': [
32
+ 'CdkConnectedOverlay', 'CdkOverlayOrigin', 'CdkScrollable', 'FullscreenOverlayContainer', 'Overlay',
33
+ 'OverlayContainer', 'OverlayPositionBuilder', 'ScrollDispatcher', 'ScrollStrategyOptions', 'ViewportRuler'
34
+ ],
35
+ '@angular/cdk/portal': ['CdkPortal', 'CdkPortalOutlet'],
36
+ '@angular/cdk/scrolling': [
37
+ 'CdkScrollable', 'CdkVirtualForOf', 'CdkVirtualScrollViewport', 'CdkVirtualScrollable',
38
+ 'CdkVirtualScrollableElement', 'CdkVirtualScrollableWindow', 'ScrollDispatcher', 'ViewportRuler'
39
+ ],
40
+ '@angular/cdk/stepper': [
41
+ 'CdkStep', 'CdkStepHeader', 'CdkStepLabel', 'CdkStepper', 'CdkStepperNext', 'CdkStepperPrevious'
42
+ ],
43
+ '@angular/cdk/table': [
44
+ 'BaseRowDef', 'CdkCell', 'CdkCellDef', 'CdkCellOutlet', 'CdkColumnDef', 'CdkFooterCell',
45
+ 'CdkFooterCellDef', 'CdkFooterRowDef', 'CdkHeaderCell', 'CdkHeaderCellDef', 'CdkHeaderRowDef',
46
+ 'CdkNoDataRow', 'CdkRowDef', 'CdkTable', 'CdkTextColumn', 'DataRowOutlet', 'FooterRowOutlet',
47
+ 'HeaderRowOutlet', 'NoDataRowOutlet'
48
+ ],
49
+ '@angular/cdk/text-field': ['AutofillMonitor', 'CdkAutofill', 'CdkTextareaAutosize'],
50
+ '@angular/cdk/tree': [
51
+ 'CdkNestedTreeNode', 'CdkTree', 'CdkTreeNode', 'CdkTreeNodeDef', 'CdkTreeNodeOutlet', 'CdkTreeNodePadding',
52
+ 'CdkTreeNodeToggle'
53
+ ],
54
+ };
55
+
56
+ export class RemoveCdkSuperArguments extends Recipe {
57
+ readonly name = "org.openrewrite.angular.cdk.RemoveCdkSuperArguments";
58
+ readonly displayName = "Remove the `super(...)` arguments of CDK subclasses";
59
+ readonly description = "CDK 22 removed the `constructor(...args: unknown[])` that kept old `super(...)` calls compiling " +
60
+ "after the CDK classes moved to `inject()`. Removes the arguments of `super(...)` in classes that extend one of " +
61
+ "those classes, such as `CdkStepper`, `CdkTable` or `Overlay`, since the CDK already ignored them.";
62
+
63
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
64
+ return new class extends JavaScriptVisitor<ExecutionContext> {
65
+ private cdkClasses = new Set<string>();
66
+
67
+ protected async visitJsCompilationUnit(cu: JS.CompilationUnit, p: ExecutionContext): Promise<J | undefined> {
68
+ this.cdkClasses = new Set(Object.entries(ZERO_ARGUMENT_CONSTRUCTORS)
69
+ .flatMap(([module, classes]) => [...importedNames(cu, module, classes).keys()]));
70
+ return this.cdkClasses.size === 0 ? cu : super.visitJsCompilationUnit(cu, p);
71
+ }
72
+
73
+ protected async visitFunctionCall(functionCall: JS.FunctionCall, p: ExecutionContext): Promise<J | undefined> {
74
+ const call = await super.visitFunctionCall(functionCall, p) as JS.FunctionCall;
75
+ if (!isSuperCall(call) || argumentCount(call.arguments) === 0) return call;
76
+ const classDecl = this.cursor.firstEnclosing((t: any): t is J.ClassDeclaration => t?.kind === J.Kind.ClassDeclaration);
77
+ const extended = classDecl && extendedClassName(classDecl);
78
+ if (!extended || !this.cdkClasses.has(extended)) return call;
79
+ return {...call, arguments: emptyArguments(call.arguments)} as JS.FunctionCall;
80
+ }
81
+ }();
82
+ }
83
+ }
@@ -0,0 +1,88 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ import {ExecutionContext, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {JavaScriptVisitor, JS} from "@openrewrite/rewrite/javascript";
9
+ import {Expression, isIdentifier, J, Type} from "@openrewrite/rewrite/java";
10
+ import {importedNames} from "../components/symbols";
11
+ import {argumentCount} from "./find-cdk-signature-changes";
12
+
13
+ interface RemovedParameters {
14
+ /** Index of the `ComponentFactoryResolver` parameter. */
15
+ resolver: number;
16
+ /** Index of a later parameter that CDK 20 removed as well. */
17
+ trailing?: number;
18
+ /** Arguments the CDK 20 constructor accepts at most, so a longer call is unambiguously a CDK 19 one. */
19
+ newArity: number;
20
+ }
21
+
22
+ const REMOVED_PARAMETERS: Record<string, RemovedParameters> = {
23
+ // (component, viewContainerRef, injector, componentFactoryResolver, projectableNodes)
24
+ ComponentPortal: {resolver: 3, newArity: 4},
25
+ // (outletElement, componentFactoryResolver, appRef, defaultInjector, document)
26
+ DomPortalOutlet: {resolver: 1, trailing: 4, newArity: 3},
27
+ DomPortalHost: {resolver: 1, trailing: 4, newArity: 3},
28
+ };
29
+
30
+ export class RemovePortalFactoryResolverArguments extends Recipe {
31
+ readonly name = "org.openrewrite.angular.cdk.RemovePortalFactoryResolverArguments";
32
+ readonly displayName = "Remove the `ComponentFactoryResolver` argument of CDK portals";
33
+ readonly description = "CDK 20 removed the deprecated `ComponentFactoryResolver` parameter of the `ComponentPortal` " +
34
+ "constructor and the `ComponentFactoryResolver` and `Document` parameters of the `DomPortalOutlet` constructor. " +
35
+ "Removes those arguments from `new ComponentPortal(...)` and `new DomPortalOutlet(...)` so the remaining ones " +
36
+ "line up with the new parameter lists. A call that also fits the new parameter list is only changed when the " +
37
+ "argument is typed or named as a `ComponentFactoryResolver`.";
38
+
39
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
40
+ return new class extends JavaScriptVisitor<ExecutionContext> {
41
+ private portalClasses = new Map<string, string>();
42
+
43
+ protected async visitJsCompilationUnit(cu: JS.CompilationUnit, p: ExecutionContext): Promise<J | undefined> {
44
+ this.portalClasses = importedNames(cu, '@angular/cdk/portal', Object.keys(REMOVED_PARAMETERS));
45
+ if (this.portalClasses.size === 0) return cu;
46
+ return super.visitJsCompilationUnit(cu, p);
47
+ }
48
+
49
+ protected async visitNewClass(newClass: J.NewClass, p: ExecutionContext): Promise<J | undefined> {
50
+ const n = await super.visitNewClass(newClass, p) as J.NewClass;
51
+ const clazz = n.class;
52
+ if (!clazz || !isIdentifier(clazz)) return n;
53
+ const portalClass = this.portalClasses.get(clazz.simpleName);
54
+ if (!portalClass) return n;
55
+
56
+ const removed = REMOVED_PARAMETERS[portalClass];
57
+ let elements = n.arguments.elements;
58
+ const resolver = elements[removed.resolver]?.element;
59
+ if (!resolver || (argumentCount(n.arguments) <= removed.newArity && !isResolver(resolver))) return n;
60
+
61
+ if (removed.trailing !== undefined) {
62
+ elements = removeArgument(elements, removed.trailing);
63
+ }
64
+ elements = removeArgument(elements, removed.resolver);
65
+ return {...n, arguments: {...n.arguments, elements}} as J.NewClass;
66
+ }
67
+ }();
68
+ }
69
+ }
70
+
71
+ function removeArgument(elements: J.RightPadded<Expression>[], index: number): J.RightPadded<Expression>[] {
72
+ if (index >= elements.length) return elements;
73
+ const retained = elements.filter((_, i) => i !== index);
74
+ if (index === elements.length - 1) {
75
+ retained[retained.length - 1] = {...retained[retained.length - 1], after: elements[index].after};
76
+ }
77
+ return retained;
78
+ }
79
+
80
+ /** Whether an argument is typed as, or named like, a `ComponentFactoryResolver`. */
81
+ function isResolver(argument: Expression): boolean {
82
+ const type = (argument as Expression & {type?: Type}).type;
83
+ if (Type.isClass(type) && type.fullyQualifiedName.endsWith('ComponentFactoryResolver')) return true;
84
+ const name = isIdentifier(argument) ? argument.simpleName
85
+ : argument.kind === J.Kind.FieldAccess ? (argument as J.FieldAccess).name.element.simpleName
86
+ : undefined;
87
+ return name !== undefined && /resolver/i.test(name);
88
+ }
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ import {StylesheetRecipe, withoutComments} from "../components/stylesheets";
8
+
9
+ const TILDE_IMPORT = /(@(?:import|use|forward)\s+['"])~(@angular\/[^'"]*?)(?:\.scss)?(['"])/g;
10
+
11
+ export class RemoveTildeFromStylesheetImports extends StylesheetRecipe {
12
+ readonly name = "org.openrewrite.angular.cdk.RemoveTildeFromStylesheetImports";
13
+ readonly displayName = "Remove `~` from `@angular` stylesheet imports";
14
+ readonly description = "Removes the webpack-specific `~` prefix and the `.scss` extension from `@import`, `@use` and " +
15
+ "`@forward` rules that load `@angular/cdk` or `@angular/material` stylesheets. The Angular 13 CLI deprecated " +
16
+ "tilde imports. This is the `ng update` tilde-import migration of `@angular/cdk` 13.";
17
+
18
+ protected migrate(content: string): string {
19
+ if (!content.includes('~@angular/')) return content;
20
+ return withoutComments(content, masked => masked.replace(TILDE_IMPORT, '$1$2$3'));
21
+ }
22
+ }
@@ -0,0 +1,51 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ import {ExecutionContext, foundSearchResult, Recipe, TreeVisitor} from "@openrewrite/rewrite";
8
+ import {PlainText, PlainTextVisitor} from "@openrewrite/rewrite/text";
9
+ import {RenameTemplateAttributes, renameTemplateAttributes} from "../components/templates";
10
+
11
+ export class RenamePortalTemplateSelectors extends RenameTemplateAttributes {
12
+ readonly name = "org.openrewrite.angular.cdk.RenamePortalTemplateSelectors";
13
+ readonly displayName = "Rename the removed CDK portal directive selectors";
14
+ readonly description = "CDK 21 removed `PortalHostDirective` and `TemplatePortalDirective`. Renames the selectors " +
15
+ "only they matched to those of `CdkPortalOutlet` and `CdkPortal`: `[cdkPortalHost]` becomes `[cdkPortalOutlet]`, " +
16
+ "a `#ref=\"cdkPortalHost\"` reference becomes `#ref=\"cdkPortalOutlet\"`, and `<ng-template cdk-portal>` becomes " +
17
+ "`<ng-template cdkPortal>`, in `.html` templates and inline `template` metadata.";
18
+
19
+ protected readonly attributes = [
20
+ {name: 'cdkPortalHost', newName: 'cdkPortalOutlet'},
21
+ {name: 'cdk-portal', newName: 'cdkPortal', element: 'ng-template'},
22
+ ];
23
+ protected readonly exportAs = [
24
+ {name: 'cdkPortalHost', newName: 'cdkPortalOutlet'},
25
+ ];
26
+ }
27
+
28
+ const UNPREFIXED_SELECTORS = [
29
+ {name: 'portal', newName: 'cdkPortal', element: 'ng-template'},
30
+ {name: 'portalHost', newName: 'cdkPortalOutlet'},
31
+ ];
32
+
33
+ export class FindUnprefixedPortalSelectors extends Recipe {
34
+ readonly name = "org.openrewrite.angular.cdk.FindUnprefixedPortalSelectors";
35
+ readonly displayName = "Find the removed unprefixed CDK portal selectors";
36
+ readonly description = "Finds `.html` templates that use the `portal` or `portalHost` attribute, which only the " +
37
+ "`TemplatePortalDirective` and `PortalHostDirective` that CDK 21 removed matched. These names are too generic to " +
38
+ "rename blindly, so confirm they are the CDK directives and rename them to `cdkPortal` and `cdkPortalOutlet`.";
39
+
40
+ async editor(): Promise<TreeVisitor<any, ExecutionContext>> {
41
+ return new class extends PlainTextVisitor<ExecutionContext> {
42
+ override async visitText(text: PlainText, p: ExecutionContext): Promise<PlainText | undefined> {
43
+ const t = await super.visitText(text, p) as PlainText;
44
+ if (!t || !t.sourcePath.endsWith('.html')) return t;
45
+ if (renameTemplateAttributes(t.text, UNPREFIXED_SELECTORS) === t.text) return t;
46
+ return foundSearchResult(t, "`portal` and `portalHost` stopped matching a CDK directive in " +
47
+ "@angular/cdk 21. If they refer to the CDK portal directives, rename them to `cdkPortal` and `cdkPortalOutlet`.");
48
+ }
49
+ }();
50
+ }
51
+ }
@@ -0,0 +1,146 @@
1
+ /*
2
+ * Copyright 2026 the original author or authors.
3
+ *
4
+ * Moderne Proprietary. Only for use by Moderne customers under the terms of a commercial contract.
5
+ */
6
+
7
+ import {Recipe} from "@openrewrite/rewrite";
8
+ import {renameSymbols} from "../components/symbols";
9
+ import {RemoveTildeFromStylesheetImports} from "./remove-tilde-from-stylesheet-imports";
10
+ import {FindRemovedCdk13Apis, FindRemovedCdk14Apis, FindRemovedCdk20Apis, FindRemovedCdk21Apis, FindRemovedCdk22Apis} from "./find-removed-cdk-apis";
11
+ import {
12
+ FindComponentPortalFactoryResolver,
13
+ FindDialogComponentFactoryResolver,
14
+ FindDropListRefDropWithoutEvent,
15
+ FindFocusTrapWithoutInjector,
16
+ FindOverlayConnectedTo,
17
+ FindSelectionModelVoidOverrides,
18
+ FindTestElementImplementations
19
+ } from "./find-cdk-signature-changes";
20
+ import {MigrateCdkSassImports} from "./migrate-cdk-sass-imports";
21
+ import {RemovePortalFactoryResolverArguments} from "./remove-portal-factory-resolver-arguments";
22
+ import {FindUnprefixedPortalSelectors, RenamePortalTemplateSelectors} from "./rename-portal-template-selectors";
23
+ import {MigrateFocusTrapFactoryCreate} from "./migrate-focus-trap-factory-create";
24
+ import {MigrateCdkStepper} from "./migrate-cdk-stepper";
25
+ import {MigrateDragDropRegistry} from "./migrate-drag-drop-registry";
26
+ import {MigrateDeprecatedOverlaySass} from "./migrate-deprecated-overlay-sass";
27
+ import {RemoveCdkSuperArguments} from "./remove-cdk-super-arguments";
28
+
29
+ // The `@angular/cdk` version bump is part of `UpgradeToAngularN`, which runs these composites as well.
30
+
31
+ export class UpgradeToCdk13CodeChanges extends Recipe {
32
+ readonly name = "org.openrewrite.angular.cdk.UpgradeToCdk13CodeChanges";
33
+ readonly displayName = "Angular CDK 13 code changes";
34
+ readonly description = "The `@angular/cdk` source changes of the version 13 migration: renames " +
35
+ "`CKD_COPY_TO_CLIPBOARD_CONFIG`, removes `~` from `@angular` stylesheet imports, and finds the removed " +
36
+ "`ConnectedPositionStrategy` API. `UpgradeToAngular13` includes this recipe.";
37
+
38
+ async recipeList(): Promise<Recipe[]> {
39
+ return [
40
+ ...renameSymbols([
41
+ {module: '@angular/cdk/clipboard', name: 'CKD_COPY_TO_CLIPBOARD_CONFIG', newName: 'CDK_COPY_TO_CLIPBOARD_CONFIG'},
42
+ ]),
43
+ new RemoveTildeFromStylesheetImports(),
44
+ new FindRemovedCdk13Apis(),
45
+ new FindOverlayConnectedTo(),
46
+ ];
47
+ }
48
+ }
49
+
50
+ export class UpgradeToCdk14CodeChanges extends Recipe {
51
+ readonly name = "org.openrewrite.angular.cdk.UpgradeToCdk14CodeChanges";
52
+ readonly displayName = "Angular CDK 14 code changes";
53
+ readonly description = "The `@angular/cdk` source changes of the version 14 migration: migrates `CdkStepper` " +
54
+ "subclasses off the private `_orientation` and the removed `_document` parameter, and finds imports from the " +
55
+ "removed `@angular/cdk/testing/protractor` entry point. `UpgradeToAngular14` includes this recipe.";
56
+
57
+ async recipeList(): Promise<Recipe[]> {
58
+ return [
59
+ new MigrateCdkStepper(),
60
+ new FindRemovedCdk14Apis(),
61
+ ];
62
+ }
63
+ }
64
+
65
+ export class UpgradeToCdk17CodeChanges extends Recipe {
66
+ readonly name = "org.openrewrite.angular.cdk.UpgradeToCdk17CodeChanges";
67
+ readonly displayName = "Angular CDK 17 code changes";
68
+ readonly description = "The `@angular/cdk` source changes of the version 17 migration: replaces the Sass `@import` " +
69
+ "entry points that CDK 17 deleted with `@use '@angular/cdk'`. `UpgradeToAngular17` includes this recipe.";
70
+
71
+ async recipeList(): Promise<Recipe[]> {
72
+ return [new MigrateCdkSassImports()];
73
+ }
74
+ }
75
+
76
+ export class UpgradeToCdk20CodeChanges extends Recipe {
77
+ readonly name = "org.openrewrite.angular.cdk.UpgradeToCdk20CodeChanges";
78
+ readonly displayName = "Angular CDK 20 code changes";
79
+ readonly description = "The `@angular/cdk` source changes of the version 20 migration: renames the removed " +
80
+ "`*PortalHost` aliases to their `*PortalOutlet` classes, drops the `ComponentFactoryResolver` arguments of the " +
81
+ "portal constructors, migrates `DragDropRegistry` off its type arguments and `scroll` subject, and finds the " +
82
+ "removed dialog, portal and table APIs and the `SelectionModel` overrides that still return `void`. " +
83
+ "`UpgradeToAngular20` includes this recipe.";
84
+
85
+ async recipeList(): Promise<Recipe[]> {
86
+ return [
87
+ ...renameSymbols([
88
+ {module: '@angular/cdk/portal', name: 'BasePortalHost', newName: 'BasePortalOutlet'},
89
+ {module: '@angular/cdk/portal', name: 'DomPortalHost', newName: 'DomPortalOutlet'},
90
+ {module: '@angular/cdk/portal', name: 'PortalHost', newName: 'PortalOutlet'},
91
+ ]),
92
+ new RemovePortalFactoryResolverArguments(),
93
+ new MigrateDragDropRegistry(),
94
+ new FindRemovedCdk20Apis(),
95
+ new FindDialogComponentFactoryResolver(),
96
+ new FindComponentPortalFactoryResolver(),
97
+ new FindSelectionModelVoidOverrides(),
98
+ ];
99
+ }
100
+ }
101
+
102
+ export class UpgradeToCdk21CodeChanges extends Recipe {
103
+ readonly name = "org.openrewrite.angular.cdk.UpgradeToCdk21CodeChanges";
104
+ readonly displayName = "Angular CDK 21 code changes";
105
+ readonly description = "The `@angular/cdk` source changes of the version 21 migration: replaces the removed " +
106
+ "`TemplatePortalDirective` and `PortalHostDirective` with `CdkPortal` and `CdkPortalOutlet` in code and " +
107
+ "templates, renames the removed overlay Sass variables, and finds the removed `@angular/cdk/a11y` factories and incomplete `TestElement` implementations. " +
108
+ "`UpgradeToAngular21` includes this recipe.";
109
+
110
+ async recipeList(): Promise<Recipe[]> {
111
+ return [
112
+ ...renameSymbols([
113
+ {module: '@angular/cdk/portal', name: 'TemplatePortalDirective', newName: 'CdkPortal'},
114
+ {module: '@angular/cdk/portal', name: 'PortalHostDirective', newName: 'CdkPortalOutlet'},
115
+ ]),
116
+ new RenamePortalTemplateSelectors(),
117
+ new FindUnprefixedPortalSelectors(),
118
+ new MigrateDeprecatedOverlaySass(),
119
+ new FindRemovedCdk21Apis(),
120
+ new FindTestElementImplementations(),
121
+ ];
122
+ }
123
+ }
124
+
125
+ export class UpgradeToCdk22CodeChanges extends Recipe {
126
+ readonly name = "org.openrewrite.angular.cdk.UpgradeToCdk22CodeChanges";
127
+ readonly displayName = "Angular CDK 22 code changes";
128
+ readonly description = "The `@angular/cdk` source changes of the version 22 migration: renames `ContextMenuTracker` " +
129
+ "to `MenuTracker`, removes the `super(...)` arguments that CDK constructors no longer accept, rewrites the boolean " +
130
+ "overload of `ConfigurableFocusTrapFactory.create`, and finds the removed " +
131
+ "`AriaDescriber` constants and the calls missing a now-required `Injector` or `event` argument. " +
132
+ "`UpgradeToAngular22` includes this recipe.";
133
+
134
+ async recipeList(): Promise<Recipe[]> {
135
+ return [
136
+ ...renameSymbols([
137
+ {module: '@angular/cdk/menu', name: 'ContextMenuTracker', newName: 'MenuTracker'},
138
+ ]),
139
+ new RemoveCdkSuperArguments(),
140
+ new MigrateFocusTrapFactoryCreate(),
141
+ new FindRemovedCdk22Apis(),
142
+ new FindFocusTrapWithoutInjector(),
143
+ new FindDropListRefDropWithoutEvent(),
144
+ ];
145
+ }
146
+ }