@taiga-ui/cdk 4.0.0-alpha.0 → 4.0.0-rc.10

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 (199) hide show
  1. package/classes/index.d.ts +0 -1
  2. package/constants/used-icons.d.ts +1 -1
  3. package/constants/version.d.ts +1 -1
  4. package/constants/version.js +1 -1
  5. package/esm2022/classes/index.mjs +1 -2
  6. package/esm2022/constants/used-icons.mjs +9 -1
  7. package/esm2022/constants/version.mjs +2 -2
  8. package/esm2022/directives/auto-focus/autofocus.options.mjs +3 -3
  9. package/esm2022/directives/copy-processor/copy-processor.directive.mjs +3 -3
  10. package/esm2022/directives/high-dpi/high-dpi.directive.mjs +3 -3
  11. package/esm2022/directives/obscured/obscured.service.mjs +3 -3
  12. package/esm2022/services/index.mjs +2 -2
  13. package/esm2022/services/scroll.service.mjs +4 -4
  14. package/esm2022/services/theme-color.service.mjs +30 -0
  15. package/esm2022/tokens/active-element.mjs +3 -3
  16. package/esm2022/tokens/environment.mjs +15 -7
  17. package/esm2022/tokens/removed-element.mjs +3 -3
  18. package/esm2022/tokens/window-size.mjs +3 -3
  19. package/esm2022/utils/focus/focused-in.mjs +7 -0
  20. package/esm2022/utils/focus/index.mjs +2 -1
  21. package/fesm2022/taiga-ui-cdk-classes.mjs +1 -15
  22. package/fesm2022/taiga-ui-cdk-classes.mjs.map +1 -1
  23. package/fesm2022/taiga-ui-cdk-constants.mjs +9 -1
  24. package/fesm2022/taiga-ui-cdk-constants.mjs.map +1 -1
  25. package/fesm2022/taiga-ui-cdk-directives-auto-focus.mjs +2 -2
  26. package/fesm2022/taiga-ui-cdk-directives-auto-focus.mjs.map +1 -1
  27. package/fesm2022/taiga-ui-cdk-directives-copy-processor.mjs +2 -2
  28. package/fesm2022/taiga-ui-cdk-directives-copy-processor.mjs.map +1 -1
  29. package/fesm2022/taiga-ui-cdk-directives-high-dpi.mjs +2 -2
  30. package/fesm2022/taiga-ui-cdk-directives-high-dpi.mjs.map +1 -1
  31. package/fesm2022/taiga-ui-cdk-directives-obscured.mjs +2 -2
  32. package/fesm2022/taiga-ui-cdk-directives-obscured.mjs.map +1 -1
  33. package/fesm2022/taiga-ui-cdk-services.mjs +22 -25
  34. package/fesm2022/taiga-ui-cdk-services.mjs.map +1 -1
  35. package/fesm2022/taiga-ui-cdk-tokens.mjs +19 -12
  36. package/fesm2022/taiga-ui-cdk-tokens.mjs.map +1 -1
  37. package/fesm2022/taiga-ui-cdk-utils-focus.mjs +8 -2
  38. package/fesm2022/taiga-ui-cdk-utils-focus.mjs.map +1 -1
  39. package/package.json +356 -67
  40. package/schematics/ng-update/interfaces/html-comment.d.ts +3 -2
  41. package/schematics/ng-update/interfaces/replacement-attribute-value.d.ts +6 -2
  42. package/schematics/ng-update/interfaces/replacement-identifier.d.ts +4 -10
  43. package/schematics/ng-update/interfaces/replacement-type.d.ts +4 -0
  44. package/schematics/ng-update/steps/rename-types.js +6 -2
  45. package/schematics/ng-update/steps/replace-identifier.js +30 -8
  46. package/schematics/ng-update/steps/replace-package-name.js +4 -5
  47. package/schematics/ng-update/utils/templates/replace-attr-values.js +39 -10
  48. package/schematics/ng-update/utils/templates/template-comments.js +7 -1
  49. package/schematics/ng-update/v4/index.js +9 -1
  50. package/schematics/ng-update/v4/migrate-icons/index.js +2 -2
  51. package/schematics/ng-update/v4/migrate-icons/rename-icons.js +13 -5
  52. package/schematics/ng-update/v4/migrate-icons/rename-proprietary-icons.d.ts +2 -1
  53. package/schematics/ng-update/v4/migrate-icons/rename-proprietary-icons.js +19 -6
  54. package/schematics/ng-update/v4/steps/constants/attr-to-directive-replace.js +3 -2
  55. package/schematics/ng-update/v4/steps/constants/attr-with-values-to-replace.js +44 -3
  56. package/schematics/ng-update/v4/steps/constants/attrs-to-replace.js +107 -21
  57. package/schematics/ng-update/v4/steps/constants/html-comments.js +9 -0
  58. package/schematics/ng-update/v4/steps/constants/identifiers-to-replace.js +552 -213
  59. package/schematics/ng-update/v4/steps/constants/index.d.ts +1 -0
  60. package/schematics/ng-update/v4/steps/constants/index.js +1 -0
  61. package/schematics/ng-update/v4/steps/constants/inputs-to-remove.js +1 -0
  62. package/schematics/ng-update/v4/steps/constants/migration-warnings.js +20 -0
  63. package/schematics/ng-update/v4/steps/constants/modules-to-remove.js +20 -0
  64. package/schematics/ng-update/v4/steps/constants/modules-to-replace.d.ts +7 -6
  65. package/schematics/ng-update/v4/steps/constants/modules-to-replace.js +1 -0
  66. package/schematics/ng-update/v4/steps/constants/services.d.ts +2 -0
  67. package/schematics/ng-update/v4/steps/constants/services.js +15 -0
  68. package/schematics/ng-update/v4/steps/constants/tags-to-replace.js +14 -2
  69. package/schematics/ng-update/v4/steps/constants/types.js +33 -1
  70. package/schematics/ng-update/v4/steps/index.d.ts +4 -1
  71. package/schematics/ng-update/v4/steps/index.js +4 -1
  72. package/schematics/ng-update/v4/steps/migrate-alert-service.d.ts +2 -0
  73. package/schematics/ng-update/v4/steps/migrate-alert-service.js +110 -0
  74. package/schematics/ng-update/v4/steps/migrate-month-context.d.ts +2 -0
  75. package/schematics/ng-update/v4/steps/migrate-month-context.js +39 -0
  76. package/schematics/ng-update/v4/steps/migrate-number-format-settings.d.ts +2 -0
  77. package/schematics/ng-update/v4/steps/migrate-number-format-settings.js +64 -0
  78. package/schematics/ng-update/v4/steps/migrate-root.d.ts +3 -0
  79. package/schematics/ng-update/v4/steps/migrate-root.js +61 -0
  80. package/schematics/ng-update/v4/steps/migrate-templates.js +10 -2
  81. package/schematics/ng-update/v4/steps/styles/index.js +38 -0
  82. package/schematics/ng-update/v4/steps/styles/migrate-less-scss-constants.d.ts +1 -0
  83. package/schematics/ng-update/v4/steps/styles/migrate-less-scss-constants.js +13 -0
  84. package/schematics/ng-update/v4/steps/styles/migrate-scrollbar-behavior.d.ts +1 -0
  85. package/schematics/ng-update/v4/steps/styles/migrate-scrollbar-behavior.js +10 -0
  86. package/schematics/ng-update/v4/steps/styles/migrate-shadow-mixins.d.ts +1 -0
  87. package/schematics/ng-update/v4/steps/styles/migrate-shadow-mixins.js +23 -0
  88. package/schematics/ng-update/v4/steps/styles/migrate-space-mixins.d.ts +1 -0
  89. package/schematics/ng-update/v4/steps/styles/migrate-space-mixins.js +20 -0
  90. package/schematics/ng-update/v4/steps/styles/migrate-text-mixins.d.ts +1 -0
  91. package/schematics/ng-update/v4/steps/styles/migrate-text-mixins.js +54 -0
  92. package/schematics/ng-update/v4/steps/templates/index.d.ts +6 -0
  93. package/schematics/ng-update/v4/steps/templates/index.js +6 -0
  94. package/schematics/ng-update/v4/steps/templates/migrate-avatar.js +10 -5
  95. package/schematics/ng-update/{v3/steps/migrate-polymorpheus.d.ts → v4/steps/templates/migrate-axes.d.ts} +2 -2
  96. package/schematics/ng-update/v4/steps/templates/migrate-axes.js +26 -0
  97. package/schematics/ng-update/v4/steps/templates/migrate-badge.js +15 -6
  98. package/schematics/ng-update/v4/steps/templates/migrate-badged-content.js +1 -1
  99. package/schematics/ng-update/{v3/steps/migrate-textfield-controller.d.ts → v4/steps/templates/migrate-blocked.d.ts} +2 -2
  100. package/schematics/ng-update/v4/steps/templates/migrate-blocked.js +35 -0
  101. package/schematics/ng-update/v4/steps/templates/migrate-button-appearance.d.ts +8 -0
  102. package/schematics/ng-update/v4/steps/templates/migrate-button-appearance.js +41 -0
  103. package/schematics/ng-update/v4/steps/templates/migrate-expandable.js +3 -2
  104. package/schematics/ng-update/v4/steps/templates/migrate-focusable.js +7 -4
  105. package/schematics/ng-update/v4/steps/templates/migrate-label.d.ts +8 -0
  106. package/schematics/ng-update/v4/steps/templates/migrate-label.js +39 -0
  107. package/schematics/ng-update/v4/steps/templates/migrate-labeled.js +5 -7
  108. package/schematics/ng-update/v4/steps/templates/migrate-mobile-tabs.d.ts +8 -0
  109. package/schematics/ng-update/v4/steps/templates/migrate-mobile-tabs.js +45 -0
  110. package/schematics/ng-update/v4/steps/templates/migrate-notification.d.ts +8 -0
  111. package/schematics/ng-update/v4/steps/templates/migrate-notification.js +64 -0
  112. package/schematics/ng-update/v4/steps/templates/migrate-number-precision.d.ts +8 -0
  113. package/schematics/ng-update/v4/steps/templates/migrate-number-precision.js +36 -0
  114. package/schematics/ng-update/v4/steps/templates/migrate-overscroll.js +4 -6
  115. package/schematics/ng-update/v4/steps/templates/migrate-thumbnail-card.js +2 -1
  116. package/schematics/ng-update/v4/steps/templates/toggles/common.js +3 -2
  117. package/schematics/ng-update/v4/steps/templates/toggles/migrate-checkbox.js +36 -0
  118. package/schematics/ng-update/v4/steps/update-packages.js +21 -8
  119. package/schematics/ng-update/v4/steps/utils/replace-modules-with-providers.d.ts +1 -11
  120. package/schematics/ng-update/v4/steps/utils/replace-modules-with-providers.js +8 -4
  121. package/schematics/utils/get-named-import-references.js +4 -2
  122. package/schematics/utils/templates/elements.js +2 -1
  123. package/schematics/utils/templates/inputs.js +2 -1
  124. package/services/index.d.ts +1 -1
  125. package/services/theme-color.service.d.ts +16 -0
  126. package/tokens/environment.d.ts +1 -0
  127. package/utils/focus/focused-in.d.ts +2 -0
  128. package/utils/focus/index.d.ts +1 -0
  129. package/classes/controller.d.ts +0 -9
  130. package/esm2022/classes/controller.mjs +0 -18
  131. package/esm2022/services/static-request.service.mjs +0 -33
  132. package/schematics/ng-update/v3/constants/breakpoints.d.ts +0 -82
  133. package/schematics/ng-update/v3/constants/breakpoints.js +0 -34
  134. package/schematics/ng-update/v3/constants/constants.d.ts +0 -2
  135. package/schematics/ng-update/v3/constants/constants.js +0 -466
  136. package/schematics/ng-update/v3/constants/deprecated-functions.d.ts +0 -2
  137. package/schematics/ng-update/v3/constants/deprecated-functions.js +0 -680
  138. package/schematics/ng-update/v3/constants/enums.d.ts +0 -2
  139. package/schematics/ng-update/v3/constants/enums.js +0 -284
  140. package/schematics/ng-update/v3/constants/modules.d.ts +0 -2
  141. package/schematics/ng-update/v3/constants/modules.js +0 -9
  142. package/schematics/ng-update/v3/constants/services.d.ts +0 -2
  143. package/schematics/ng-update/v3/constants/services.js +0 -53
  144. package/schematics/ng-update/v3/constants/templates.d.ts +0 -57
  145. package/schematics/ng-update/v3/constants/templates.js +0 -744
  146. package/schematics/ng-update/v3/constants/tui-interactive-selectors.d.ts +0 -1
  147. package/schematics/ng-update/v3/constants/tui-interactive-selectors.js +0 -55
  148. package/schematics/ng-update/v3/constants/types.d.ts +0 -2
  149. package/schematics/ng-update/v3/constants/types.js +0 -156
  150. package/schematics/ng-update/v3/constants/warnings.d.ts +0 -2
  151. package/schematics/ng-update/v3/constants/warnings.js +0 -111
  152. package/schematics/ng-update/v3/index.d.ts +0 -3
  153. package/schematics/ng-update/v3/index.js +0 -105
  154. package/schematics/ng-update/v3/schema.json +0 -13
  155. package/schematics/ng-update/v3/steps/migrate-date-time.d.ts +0 -2
  156. package/schematics/ng-update/v3/steps/migrate-date-time.js +0 -207
  157. package/schematics/ng-update/v3/steps/migrate-polymorpheus.js +0 -78
  158. package/schematics/ng-update/v3/steps/migrate-progress.d.ts +0 -8
  159. package/schematics/ng-update/v3/steps/migrate-progress.js +0 -49
  160. package/schematics/ng-update/v3/steps/migrate-sliders/index.d.ts +0 -3
  161. package/schematics/ng-update/v3/steps/migrate-sliders/index.js +0 -19
  162. package/schematics/ng-update/v3/steps/migrate-sliders/migrate-input-range.d.ts +0 -3
  163. package/schematics/ng-update/v3/steps/migrate-sliders/migrate-input-range.js +0 -103
  164. package/schematics/ng-update/v3/steps/migrate-sliders/migrate-input-slider.d.ts +0 -3
  165. package/schematics/ng-update/v3/steps/migrate-sliders/migrate-input-slider.js +0 -90
  166. package/schematics/ng-update/v3/steps/migrate-taiga-proprietary-icons.d.ts +0 -3
  167. package/schematics/ng-update/v3/steps/migrate-taiga-proprietary-icons.js +0 -70
  168. package/schematics/ng-update/v3/steps/migrate-templates.d.ts +0 -4
  169. package/schematics/ng-update/v3/steps/migrate-templates.js +0 -216
  170. package/schematics/ng-update/v3/steps/migrate-textfield-controller.js +0 -98
  171. package/schematics/ng-update/v3/steps/miscellaneous.d.ts +0 -2
  172. package/schematics/ng-update/v3/steps/miscellaneous.js +0 -81
  173. package/schematics/ng-update/v3/steps/replace-functions.d.ts +0 -2
  174. package/schematics/ng-update/v3/steps/replace-functions.js +0 -138
  175. package/schematics/ng-update/v3/steps/replace-styles.d.ts +0 -3
  176. package/schematics/ng-update/v3/steps/replace-styles.js +0 -33
  177. package/schematics/ng-update/v3-30/constants/constants.d.ts +0 -2
  178. package/schematics/ng-update/v3-30/constants/constants.js +0 -8
  179. package/schematics/ng-update/v3-30/constants/icons.d.ts +0 -4
  180. package/schematics/ng-update/v3-30/constants/icons.js +0 -993
  181. package/schematics/ng-update/v3-30/index.d.ts +0 -3
  182. package/schematics/ng-update/v3-30/index.js +0 -33
  183. package/schematics/ng-update/v3-35/constants/constants.d.ts +0 -2
  184. package/schematics/ng-update/v3-35/constants/constants.js +0 -8
  185. package/schematics/ng-update/v3-35/constants/icons.d.ts +0 -4
  186. package/schematics/ng-update/v3-35/constants/icons.js +0 -2537
  187. package/schematics/ng-update/v3-35/index.d.ts +0 -3
  188. package/schematics/ng-update/v3-35/index.js +0 -33
  189. package/schematics/ng-update/v3-36/index.d.ts +0 -3
  190. package/schematics/ng-update/v3-36/index.js +0 -23
  191. package/schematics/ng-update/v3-40/index.d.ts +0 -3
  192. package/schematics/ng-update/v3-40/index.js +0 -62
  193. package/schematics/ng-update/v3-5/index.d.ts +0 -3
  194. package/schematics/ng-update/v3-5/index.js +0 -20
  195. package/schematics/ng-update/v3-5/steps/migrate-expand-templates.d.ts +0 -3
  196. package/schematics/ng-update/v3-5/steps/migrate-expand-templates.js +0 -44
  197. package/schematics/ng-update/v4/steps/migrate-styles.js +0 -20
  198. package/services/static-request.service.d.ts +0 -8
  199. /package/schematics/ng-update/v4/steps/{migrate-styles.d.ts → styles/index.d.ts} +0 -0
@@ -2,10 +2,14 @@ import type { Element } from 'parse5/dist/tree-adapters/default';
2
2
  export interface ReplacementAttributeValue {
3
3
  readonly attrNames: string[];
4
4
  readonly newAttrName?: string;
5
- readonly values: Array<{
5
+ readonly valueReplacer: Array<{
6
6
  readonly from: string;
7
7
  readonly to: string;
8
- }>;
8
+ }> | ((value: string) => string);
9
9
  readonly withTagNames?: string[];
10
10
  readonly filterFn?: (el: Element) => boolean;
11
+ readonly directiveModule?: {
12
+ readonly moduleSpecifier: string;
13
+ readonly name: string;
14
+ };
11
15
  }
@@ -7,16 +7,10 @@ export interface ReplacementIdentifier {
7
7
  readonly moduleSpecifier: string;
8
8
  readonly name: string;
9
9
  readonly namedImport?: string;
10
+ readonly spreadInModule?: boolean;
10
11
  };
11
12
  }
12
- export interface ReplacementIdentifierMulti extends Pick<ReplacementIdentifier, 'from'> {
13
- readonly to: Array<{
14
- readonly moduleSpecifier: string;
15
- readonly name: string;
16
- readonly namedImport?: string;
17
- }> | {
18
- readonly moduleSpecifier: string;
19
- readonly name: string;
20
- readonly namedImport?: string;
21
- };
13
+ export interface ReplacementIdentifierMulti {
14
+ readonly from: Array<ReplacementIdentifier['from']> | ReplacementIdentifier['from'];
15
+ readonly to: Array<ReplacementIdentifier['to']> | ReplacementIdentifier['to'];
22
16
  }
@@ -4,4 +4,8 @@ export interface ReplacementType {
4
4
  readonly preserveGenerics?: boolean;
5
5
  readonly to?: string;
6
6
  readonly removeImport?: boolean;
7
+ readonly newImports?: Array<{
8
+ name: string;
9
+ moduleSpecifier: string;
10
+ }>;
7
11
  }
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renameTypes = void 0;
4
4
  const ng_morph_1 = require("ng-morph");
5
+ const add_unique_import_1 = require("../../utils/add-unique-import");
5
6
  const colored_log_1 = require("../../utils/colored-log");
6
7
  const get_named_import_references_1 = require("../../utils/get-named-import-references");
7
8
  const import_manipulations_1 = require("../../utils/import-manipulations");
8
- function renameType(from, to, moduleSpecifier, preserveGenerics = false, removeImport = false) {
9
+ function renameType({ from, to, moduleSpecifier, preserveGenerics = false, removeImport = false, newImports = [], }) {
9
10
  const references = (0, get_named_import_references_1.getNamedImportReferences)(from, moduleSpecifier);
10
11
  references.forEach((ref) => {
11
12
  if (ref.wasForgotten()) {
@@ -18,6 +19,9 @@ function renameType(from, to, moduleSpecifier, preserveGenerics = false, removeI
18
19
  else if (ng_morph_1.Node.isTypeReference(parent)) {
19
20
  const targetType = preserveGenerics && to ? addGeneric(to, parent.getTypeArguments()) : to;
20
21
  parent.replaceWithText(targetType || 'any');
22
+ newImports.forEach(({ name, moduleSpecifier }) => {
23
+ (0, add_unique_import_1.addUniqueImport)(parent.getSourceFile().getFilePath(), name, moduleSpecifier);
24
+ });
21
25
  }
22
26
  });
23
27
  }
@@ -42,7 +46,7 @@ function addGeneric(typeName, generics) {
42
46
  function renameTypes(options, types) {
43
47
  !options['skip-logs'] &&
44
48
  (0, colored_log_1.infoLog)(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} renaming types...`);
45
- types.forEach(({ from, to, moduleSpecifier, preserveGenerics, removeImport }) => renameType(from, to, moduleSpecifier, preserveGenerics, removeImport));
49
+ types.forEach(renameType);
46
50
  !options['skip-logs'] &&
47
51
  (0, colored_log_1.successLog)(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SUCCESS_SYMBOL} types renamed \n`);
48
52
  }
@@ -6,17 +6,30 @@ const add_unique_import_1 = require("../../utils/add-unique-import");
6
6
  const colored_log_1 = require("../../utils/colored-log");
7
7
  const get_named_import_references_1 = require("../../utils/get-named-import-references");
8
8
  const import_manipulations_1 = require("../../utils/import-manipulations");
9
+ const progress_1 = require("../../utils/progress");
9
10
  function replaceIdentifiers(options, constants) {
10
11
  !options['skip-logs'] &&
11
12
  (0, colored_log_1.infoLog)(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} replacing identifiers...`);
12
- constants.forEach(replaceIdentifier);
13
+ const progressLog = (0, progress_1.setupProgressLogger)({
14
+ total: constants.length,
15
+ });
16
+ constants.forEach(({ from, to }) => {
17
+ toArray(from).forEach((x) => replaceIdentifier({ from: x, to }));
18
+ !options['skip-logs'] &&
19
+ progressLog(toArray(from)
20
+ .map((x) => x.name)
21
+ .join(', '));
22
+ });
13
23
  !options['skip-logs'] &&
14
24
  (0, colored_log_1.successLog)(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SUCCESS_SYMBOL} identifiers replaced \n`);
15
25
  }
16
26
  exports.replaceIdentifiers = replaceIdentifiers;
17
27
  function replaceIdentifier({ from, to }) {
18
- const references = (0, get_named_import_references_1.getNamedImportReferences)(from.name, from.moduleSpecifier);
28
+ const references = toArray(from)
29
+ .map(({ name, moduleSpecifier }) => (0, get_named_import_references_1.getNamedImportReferences)(name, moduleSpecifier))
30
+ .flat();
19
31
  references.forEach((ref) => {
32
+ var _a;
20
33
  if (ref.wasForgotten()) {
21
34
  return;
22
35
  }
@@ -26,15 +39,24 @@ function replaceIdentifier({ from, to }) {
26
39
  addImports(to, parent.getSourceFile().getFilePath());
27
40
  }
28
41
  else {
29
- ref === null || ref === void 0 ? void 0 : ref.replaceWithText(Array.isArray(to) ? to.map(({ name }) => name).join(', ') : to.name);
42
+ const decorator = ref.getParentWhile((node) => node.getKindName() !== 'Decorator');
43
+ const inModule = ((_a = decorator === null || decorator === void 0 ? void 0 : decorator.getFirstChildIfKind(ng_morph_1.ts.SyntaxKind.Identifier)) === null || _a === void 0 ? void 0 : _a.getText()) ===
44
+ 'NgModule';
45
+ ref.replaceWithText(getReplacementText(to, !!inModule));
30
46
  }
31
47
  });
32
48
  }
33
49
  exports.replaceIdentifier = replaceIdentifier;
34
50
  function addImports(identifier, filePath) {
35
- Array.isArray(identifier)
36
- ? identifier.forEach(({ name, namedImport, moduleSpecifier }) => {
37
- (0, add_unique_import_1.addUniqueImport)(filePath, namedImport || name, moduleSpecifier);
38
- })
39
- : (0, add_unique_import_1.addUniqueImport)(filePath, identifier.namedImport || identifier.name, identifier.moduleSpecifier);
51
+ toArray(identifier).forEach(({ name, namedImport, moduleSpecifier }) => {
52
+ (0, add_unique_import_1.addUniqueImport)(filePath, namedImport || name, moduleSpecifier);
53
+ });
54
+ }
55
+ function getReplacementText(to, inModule) {
56
+ return toArray(to)
57
+ .map(({ name, spreadInModule }) => spreadInModule && inModule ? `...${name}` : name)
58
+ .join(', ');
59
+ }
60
+ function toArray(x) {
61
+ return Array.isArray(x) ? x : [x];
40
62
  }
@@ -6,13 +6,12 @@ const constants_1 = require("../../constants");
6
6
  const get_file_system_1 = require("../utils/get-file-system");
7
7
  const replace_text_1 = require("../utils/replace-text");
8
8
  function replacePackageName(oldPackage, newPackage, tree) {
9
- if (!(0, ng_morph_1.getPackageJsonDependency)(tree, oldPackage)) {
10
- return;
11
- }
12
9
  const fileSystem = (0, get_file_system_1.getFileSystem)(tree);
13
10
  (0, replace_text_1.replaceText)([{ from: oldPackage, to: newPackage.name }], constants_1.ALL_TS_FILES);
14
- (0, ng_morph_1.removePackageJsonDependency)(tree, oldPackage);
15
- (0, ng_morph_1.addPackageJsonDependency)(tree, newPackage);
11
+ if ((0, ng_morph_1.getPackageJsonDependency)(tree, oldPackage)) {
12
+ (0, ng_morph_1.removePackageJsonDependency)(tree, oldPackage);
13
+ (0, ng_morph_1.addPackageJsonDependency)(tree, newPackage);
14
+ }
16
15
  fileSystem.commitEdits();
17
16
  (0, ng_morph_1.saveActiveProject)();
18
17
  }
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.replaceAttrValues = void 0;
4
+ const add_import_to_closest_module_1 = require("../../../utils/add-import-to-closest-module");
4
5
  const elements_1 = require("../../../utils/templates/elements");
5
6
  const template_resource_1 = require("../../../utils/templates/template-resource");
6
7
  function replaceAttrValues({ resource, recorder, fileSystem, data, }) {
7
8
  const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
8
9
  const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
9
- data.forEach(({ attrNames, values, withTagNames, filterFn, newAttrName }) => {
10
+ data.forEach(({ attrNames, valueReplacer, withTagNames, filterFn, newAttrName, directiveModule, }) => {
10
11
  const elements = [
11
12
  ...(0, elements_1.findElementsWithAttributeOnTag)(template, attrNames, withTagNames, filterFn),
12
13
  ];
@@ -15,16 +16,44 @@ function replaceAttrValues({ resource, recorder, fileSystem, data, }) {
15
16
  if (!name || !value) {
16
17
  return;
17
18
  }
18
- const attributeName = attrNames.find((attrName) => attrName.toLowerCase() === name);
19
- values.forEach(({ from, to }) => {
20
- var _a, _b;
21
- if (value === from) {
22
- const { startOffset, endOffset } = ((_b = (_a = element.sourceCodeLocation) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b[name]) || { startOffset: 0, endOffset: 0 };
23
- recorder.remove(templateOffset + startOffset, endOffset - startOffset);
24
- recorder.insertRight(templateOffset + startOffset, `${newAttrName || attributeName}="${to}"`);
25
- }
26
- });
19
+ const attributeName = attrNames.find((attrName) => attrName.toLowerCase() === name) || '';
20
+ if (Array.isArray(valueReplacer)) {
21
+ valueReplacer.forEach(({ from, to }) => {
22
+ if (value === from) {
23
+ replaceValue({
24
+ element,
25
+ recorder,
26
+ templateOffset,
27
+ attrName: name,
28
+ attrNewName: newAttrName || attributeName,
29
+ attrValue: to,
30
+ });
31
+ }
32
+ });
33
+ }
34
+ else {
35
+ replaceValue({
36
+ element,
37
+ recorder,
38
+ templateOffset,
39
+ attrName: name,
40
+ attrNewName: newAttrName || attributeName,
41
+ attrValue: valueReplacer(value),
42
+ });
43
+ }
44
+ if (directiveModule) {
45
+ (0, add_import_to_closest_module_1.addImportToClosestModule)(resource.componentPath, directiveModule.name, directiveModule.moduleSpecifier);
46
+ }
27
47
  });
28
48
  });
29
49
  }
30
50
  exports.replaceAttrValues = replaceAttrValues;
51
+ function replaceValue({ element, recorder, templateOffset, attrName, attrNewName, attrValue, }) {
52
+ var _a, _b;
53
+ const { startOffset, endOffset } = ((_b = (_a = element.sourceCodeLocation) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b[attrName]) || {
54
+ startOffset: 0,
55
+ endOffset: 0,
56
+ };
57
+ recorder.remove(templateOffset + startOffset, endOffset - startOffset);
58
+ recorder.insertRight(templateOffset + startOffset, `${attrNewName}="${attrValue}"`);
59
+ }
@@ -7,7 +7,13 @@ const template_resource_1 = require("../../../utils/templates/template-resource"
7
7
  function addHTMLCommentTags({ resource, recorder, fileSystem, data, }) {
8
8
  const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
9
9
  const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
10
- data.forEach(({ comment, tag, withAttrs }) => {
10
+ data.forEach(({ comment, tag, withAttrs, pattern }) => {
11
+ if (pattern && template.match(pattern)) {
12
+ recorder.insertRight(templateOffset && templateOffset + 1, `<!-- ${insert_todo_1.TODO_MARK} ${comment} -->\n`);
13
+ }
14
+ if (!tag || !withAttrs) {
15
+ return;
16
+ }
11
17
  const elementStartOffsets = [
12
18
  ...(0, elements_1.findElementsWithAttributeOnTag)(template, withAttrs, [tag]),
13
19
  ...(withAttrs.length
@@ -9,16 +9,21 @@ const versions_1 = require("../../ng-add/constants/versions");
9
9
  const colored_log_1 = require("../../utils/colored-log");
10
10
  const get_execution_time_1 = require("../../utils/get-execution-time");
11
11
  const steps_1 = require("../steps");
12
+ const replace_services_1 = require("../steps/replace-services");
12
13
  const get_file_system_1 = require("../utils/get-file-system");
13
14
  const enums_1 = require("../v4/steps/constants/enums");
14
15
  const steps_2 = require("./steps");
15
16
  const constants_1 = require("./steps/constants");
16
17
  const modules_to_replace_1 = require("./steps/constants/modules-to-replace");
17
18
  const types_1 = require("./steps/constants/types");
19
+ const migrate_root_1 = require("./steps/migrate-root");
18
20
  const replace_modules_with_providers_1 = require("./steps/utils/replace-modules-with-providers");
19
21
  function main(options) {
20
22
  return (tree, context) => {
21
23
  const fileSystem = (0, get_file_system_1.getFileSystem)(tree);
24
+ (0, steps_1.replaceEnums)(options, enums_1.ENUMS_TO_REPLACE);
25
+ (0, migrate_root_1.migrateRoot)(fileSystem, options);
26
+ (0, replace_services_1.replaceServices)(options, constants_1.SERVICES_TO_REPLACE);
22
27
  (0, steps_1.replaceIdentifiers)(options, constants_1.IDENTIFIERS_TO_REPLACE);
23
28
  (0, steps_1.removeModules)(options, constants_1.MODULES_TO_REMOVE);
24
29
  (0, replace_modules_with_providers_1.replaceModulesWithProviders)(options, modules_to_replace_1.MODULES_TO_REPLACE_WITH_PROVIDERS);
@@ -29,7 +34,10 @@ function main(options) {
29
34
  (0, steps_2.migrateDestroyService)(options);
30
35
  (0, steps_2.migrateOptionProviders)(options);
31
36
  (0, steps_2.migrateAllCountryIsoCodes)(options);
32
- (0, steps_1.replaceEnums)(options, enums_1.ENUMS_TO_REPLACE);
37
+ (0, steps_2.migrateAlertService)(options);
38
+ (0, steps_2.migrateNumberFormatSettings)(options);
39
+ (0, steps_2.migrateMonthContext)(options);
40
+ (0, ng_morph_1.saveActiveProject)();
33
41
  (0, steps_2.migrateTemplates)(fileSystem, options);
34
42
  (0, steps_1.showWarnings)(context, constants_1.MIGRATION_WARNINGS);
35
43
  fileSystem.commitEdits();
@@ -9,12 +9,12 @@ const rename_icons_1 = require("./rename-icons");
9
9
  const rename_proprietary_icons_1 = require("./rename-proprietary-icons");
10
10
  function migrateIcons(options) {
11
11
  return (0, schematics_1.chain)([
12
- (tree, _) => {
12
+ (tree, context) => {
13
13
  const fileSystem = (0, get_file_system_1.getFileSystem)(tree);
14
14
  !options['skip-logs'] &&
15
15
  (0, colored_log_1.infoLog)(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} replacing icons...`);
16
16
  if (hasProprietaryIcons(tree)) {
17
- (0, rename_proprietary_icons_1.renameProprietaryIcons)();
17
+ (0, rename_proprietary_icons_1.renameProprietaryIcons)(context);
18
18
  }
19
19
  else {
20
20
  (0, rename_icons_1.renameIcons)();
@@ -17,18 +17,26 @@ const CHANGED_ICONS = [
17
17
  { from: 'tuiIconDragLarge', to: ' @tui.grip-vertical' },
18
18
  { from: 'tuiIconGrid', to: '@tui.layout-grid' },
19
19
  { from: 'tuiIconGridLarge', to: '@tui.layout-grid' },
20
+ { from: 'tuiIconTool', to: '@tui.wrench' },
21
+ { from: 'tuiIconUnlock', to: '@tui.lock-open' },
22
+ { from: 'tuiIconMessageCircle', to: '@tui.message-circle' },
23
+ { from: 'tuiIconSliders', to: '@tui.sliders-vertical' },
24
+ { from: 'tuiIconPlusSquare', to: '@tui.square-plus' },
25
+ { from: 'tuiIconAlertTriangle', to: '@tui.triangle-alert' },
26
+ { from: 'tuiIconUploadCloud', to: '@tui.cloud-upload' },
27
+ { from: 'tuiIconDownloadCloud', to: '@tui.cloud-download' },
20
28
  ];
21
29
  function renameIcons(pattern = constants_1.ALL_FILES) {
22
30
  const sourceFiles = (0, ng_morph_1.getSourceFiles)(pattern);
23
31
  sourceFiles.forEach((file) => {
24
32
  let text = file.getFullText();
25
33
  CHANGED_ICONS.map(({ from, to }) => ({
26
- from: new RegExp(`\\b${from}\\b`, 'g'),
34
+ from: new RegExp(`["'\`]${from}["'\`]`, 'g'),
27
35
  to,
28
36
  })).forEach(({ from, to }) => {
29
- text = text.replaceAll(from, to);
37
+ text = text.replaceAll(from, `"${to}"`);
30
38
  });
31
- const regex = /\btuiIcon(?!Button\b)[A-Z][a-zA-Z0-9]*\b/g;
39
+ const regex = /['"`]tuiIcon(?!Button\b)[A-Z][a-zA-Z0-9]*\b/g;
32
40
  text = text.replaceAll(regex, (match) => convertString(match));
33
41
  file.replaceWithText(text);
34
42
  });
@@ -36,7 +44,7 @@ function renameIcons(pattern = constants_1.ALL_FILES) {
36
44
  exports.renameIcons = renameIcons;
37
45
  function convertString(input) {
38
46
  let result = input
39
- .replace(/^tuiIcon/, '')
47
+ .replace(/["'`]tuiIcon/, '')
40
48
  .replace(/Large$/, '')
41
49
  .replaceAll(/([A-Z0-9])/g, '-$1')
42
50
  .toLowerCase();
@@ -45,5 +53,5 @@ function convertString(input) {
45
53
  result = result.replace('-circle', '');
46
54
  result = `circle${result}`;
47
55
  }
48
- return `@tui.${result.startsWith('-') ? result.slice(1) : result}`;
56
+ return `${input.slice(0, 1)}@tui.${result.startsWith('-') ? result.slice(1) : result}`;
49
57
  }
@@ -1,2 +1,3 @@
1
1
  /// <reference lib="es2021" />
2
- export declare function renameProprietaryIcons(pattern?: import("ng-morph").Pattern): void;
2
+ import type { SchematicContext } from '@angular-devkit/schematics';
3
+ export declare function renameProprietaryIcons({ logger }: SchematicContext, pattern?: import("ng-morph").Pattern): void;
@@ -1,22 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renameProprietaryIcons = void 0;
4
- /// <reference lib="es2021" />
5
4
  const ng_morph_1 = require("ng-morph");
6
5
  const constants_1 = require("../../../constants");
7
- function renameProprietaryIcons(pattern = constants_1.ALL_FILES) {
6
+ function renameProprietaryIcons({ logger }, pattern = constants_1.ALL_FILES) {
8
7
  const sourceFiles = (0, ng_morph_1.getSourceFiles)(pattern);
9
8
  sourceFiles.forEach((file) => {
10
9
  let text = file.getFullText();
11
- const regex = /\btuiIcon(?!Button\b)[A-Z][a-zA-Z0-9]*\b/g;
12
- text = text.replaceAll(regex, (match) => convertString(match));
10
+ const regex = /['"`]tuiIcon(?!Button\b)[A-Z][a-zA-Z0-9]*\b/g;
11
+ text = text.replaceAll(regex, (icon) => {
12
+ if (icon.match(/['"`]tuiIcon(?!Tds)\w*/)) {
13
+ logger.warn(`[WARNING] in ${file.getSourceFile().getFilePath()}: Invalid icon name ${icon}. Please select an icon from the proprietary pack.`);
14
+ return icon;
15
+ }
16
+ return convertString(icon);
17
+ });
18
+ const invalidIcons = [...new Set(text.match(/\b(tuiIcon(?!Tds|Button)\w*)\b/g))];
19
+ if (invalidIcons.length) {
20
+ const message = `TODO (Taiga UI migration): invalid icons ${invalidIcons.join(', ')}. Please select an icon from the proprietary pack`;
21
+ const todo = file.getFilePath().endsWith('html')
22
+ ? `<!-- ${message} -->`
23
+ : `// ${message}`;
24
+ text = `${todo}\n${text}`;
25
+ }
13
26
  file.replaceWithText(text);
14
27
  });
15
28
  }
16
29
  exports.renameProprietaryIcons = renameProprietaryIcons;
17
30
  function convertString(input) {
18
31
  const result = input
19
- .replace(/^tuiIconTds/, '')
32
+ .replace(/['"`]tuiIconTds/, '')
20
33
  .replace(/SmallPragmatic$/, '')
21
34
  .replace(/MediumPragmatic$/, '')
22
35
  .replace(/Small$/, '')
@@ -30,7 +43,7 @@ function convertString(input) {
30
43
  .toLowerCase();
31
44
  const pack = extractPackName(input);
32
45
  const subfolder = extractSubfolder(input);
33
- return `@tui.${pack}${subfolder ? `.${subfolder}` : ''}.${result.startsWith('-') ? result.slice(1) : result}`;
46
+ return `${input.slice(0, 1)}@tui.${pack}${subfolder ? `.${subfolder}` : ''}.${result.startsWith('-') ? result.slice(1) : result}`;
34
47
  }
35
48
  function extractPackName(input) {
36
49
  if (input.endsWith('Pragmatic')) {
@@ -50,13 +50,14 @@ exports.ATTRS_TO_DIRECTIVE_REPLACE = [
50
50
  },
51
51
  },
52
52
  {
53
- componentSelector: ['button'],
53
+ componentSelector: ['button', 'a'],
54
54
  inputProperty: 'showLoader',
55
55
  directive: 'loading',
56
56
  directiveModule: {
57
57
  name: 'TuiButtonLoading',
58
58
  moduleSpecifier: '@taiga-ui/kit',
59
59
  },
60
- filterFn: (el) => (0, elements_1.hasElementAttribute)(el, 'tuiButton'),
60
+ filterFn: (el) => (0, elements_1.hasElementAttribute)(el, 'tuiButton') ||
61
+ (0, elements_1.hasElementAttribute)(el, 'tuiIconButton'),
61
62
  },
62
63
  ];
@@ -2,20 +2,61 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ATTR_WITH_VALUES_TO_REPLACE = void 0;
4
4
  const elements_1 = require("../../../../utils/templates/elements");
5
+ const hasPseudo = [
6
+ 'button',
7
+ 'a',
8
+ 'tui-checkbox',
9
+ 'tui-checkbox-block',
10
+ 'tui-radio',
11
+ 'tui-radio-block',
12
+ 'tui-radio-labeled',
13
+ 'tui-checkbox-labeled',
14
+ ];
5
15
  exports.ATTR_WITH_VALUES_TO_REPLACE = [
6
16
  {
7
17
  attrNames: ['shape'],
8
18
  newAttrName: '[style.border-radius.%]',
9
- values: [{ from: 'rounded', to: '100' }],
19
+ valueReplacer: [{ from: 'rounded', to: '100' }],
10
20
  withTagNames: ['button'],
11
- filterFn: (el) => (0, elements_1.hasElementAttribute)(el, 'tuiButton'),
21
+ filterFn: (el) => (0, elements_1.hasElementAttribute)(el, 'tuiButton') ||
22
+ (0, elements_1.hasElementAttribute)(el, 'tuiIconButton'),
12
23
  },
13
24
  {
14
25
  attrNames: ['tuiMode'],
15
26
  newAttrName: 'tuiTheme',
16
- values: [
27
+ valueReplacer: [
17
28
  { from: 'onDark', to: 'dark' },
18
29
  { from: 'onLight', to: 'light' },
19
30
  ],
20
31
  },
32
+ {
33
+ attrNames: ['[pseudoActive]'],
34
+ newAttrName: '[tuiAppearanceState]',
35
+ withTagNames: hasPseudo,
36
+ valueReplacer: (condition) => `${condition} ? 'active' : null`,
37
+ },
38
+ {
39
+ attrNames: ['[pseudoFocus]'],
40
+ newAttrName: '[tuiAppearanceState]',
41
+ withTagNames: hasPseudo,
42
+ valueReplacer: (condition) => `${condition} ? 'focus' : null`,
43
+ },
44
+ {
45
+ attrNames: ['[pseudoHover]'],
46
+ newAttrName: '[tuiAppearanceState]',
47
+ withTagNames: hasPseudo,
48
+ valueReplacer: (condition) => `${condition} ? 'hover' : null`,
49
+ },
50
+ {
51
+ attrNames: ['[pseudoInvalid]'],
52
+ newAttrName: '[tuiAppearanceState]',
53
+ withTagNames: hasPseudo,
54
+ valueReplacer: (condition) => `${condition} ? 'invalid' : null`,
55
+ },
56
+ {
57
+ attrNames: ['[pseudoDisabled]'],
58
+ newAttrName: '[tuiAppearanceState]',
59
+ withTagNames: ['tui-radio-block', 'tui-radio-labeled', 'tui-radio'],
60
+ valueReplacer: (condition) => `${condition} ? 'disabled' : null`,
61
+ },
21
62
  ];