@taiga-ui/cdk 2.47.0 → 2.48.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 (79) hide show
  1. package/abstract/controller.d.ts +6 -0
  2. package/abstract/taiga-ui-cdk-abstract.metadata.json +1 -1
  3. package/bundles/taiga-ui-cdk-abstract.umd.js +12 -0
  4. package/bundles/taiga-ui-cdk-abstract.umd.js.map +1 -1
  5. package/bundles/taiga-ui-cdk-abstract.umd.min.js +1 -1
  6. package/bundles/taiga-ui-cdk-abstract.umd.min.js.map +1 -1
  7. package/bundles/taiga-ui-cdk-directives-auto-focus.umd.js +96 -35
  8. package/bundles/taiga-ui-cdk-directives-auto-focus.umd.js.map +1 -1
  9. package/bundles/taiga-ui-cdk-directives-auto-focus.umd.min.js +1 -1
  10. package/bundles/taiga-ui-cdk-directives-auto-focus.umd.min.js.map +1 -1
  11. package/bundles/taiga-ui-cdk-enums.umd.js +12 -0
  12. package/bundles/taiga-ui-cdk-enums.umd.js.map +1 -1
  13. package/bundles/taiga-ui-cdk-enums.umd.min.js +1 -1
  14. package/bundles/taiga-ui-cdk-enums.umd.min.js.map +1 -1
  15. package/bundles/taiga-ui-cdk-utils-browser.umd.js +2 -2
  16. package/bundles/taiga-ui-cdk-utils-browser.umd.js.map +1 -1
  17. package/bundles/taiga-ui-cdk-utils-browser.umd.min.js +1 -1
  18. package/bundles/taiga-ui-cdk-utils-browser.umd.min.js.map +1 -1
  19. package/bundles/taiga-ui-cdk-utils-focus.umd.js +1 -1
  20. package/bundles/taiga-ui-cdk-utils-focus.umd.js.map +1 -1
  21. package/bundles/taiga-ui-cdk-utils-focus.umd.min.js +1 -1
  22. package/bundles/taiga-ui-cdk-utils-focus.umd.min.js.map +1 -1
  23. package/directives/auto-focus/autofocus.options.d.ts +1 -1
  24. package/directives/auto-focus/handlers/ios.handler.d.ts +26 -1
  25. package/directives/auto-focus/taiga-ui-cdk-directives-auto-focus.metadata.json +1 -1
  26. package/enums/autocomplete.d.ts +10 -0
  27. package/enums/taiga-ui-cdk-enums.metadata.json +1 -1
  28. package/esm2015/abstract/controller.js +7 -1
  29. package/esm2015/directives/auto-focus/autofocus.options.js +7 -6
  30. package/esm2015/directives/auto-focus/handlers/ios.handler.js +80 -29
  31. package/esm2015/enums/autocomplete.js +12 -1
  32. package/esm2015/utils/browser/is-edge-older-than.js +2 -2
  33. package/esm2015/utils/browser/is-safari.js +2 -2
  34. package/esm2015/utils/focus/get-native-focused.js +2 -2
  35. package/esm5/abstract/controller.js +14 -1
  36. package/esm5/directives/auto-focus/autofocus.options.js +7 -6
  37. package/esm5/directives/auto-focus/handlers/ios.handler.js +92 -30
  38. package/esm5/enums/autocomplete.js +12 -1
  39. package/esm5/utils/browser/is-edge-older-than.js +2 -2
  40. package/esm5/utils/browser/is-safari.js +2 -2
  41. package/esm5/utils/focus/get-native-focused.js +2 -2
  42. package/fesm2015/taiga-ui-cdk-abstract.js +7 -1
  43. package/fesm2015/taiga-ui-cdk-abstract.js.map +1 -1
  44. package/fesm2015/taiga-ui-cdk-directives-auto-focus.js +84 -33
  45. package/fesm2015/taiga-ui-cdk-directives-auto-focus.js.map +1 -1
  46. package/fesm2015/taiga-ui-cdk-enums.js +11 -0
  47. package/fesm2015/taiga-ui-cdk-enums.js.map +1 -1
  48. package/fesm2015/taiga-ui-cdk-utils-browser.js +2 -2
  49. package/fesm2015/taiga-ui-cdk-utils-browser.js.map +1 -1
  50. package/fesm2015/taiga-ui-cdk-utils-focus.js +1 -1
  51. package/fesm2015/taiga-ui-cdk-utils-focus.js.map +1 -1
  52. package/fesm5/taiga-ui-cdk-abstract.js +12 -1
  53. package/fesm5/taiga-ui-cdk-abstract.js.map +1 -1
  54. package/fesm5/taiga-ui-cdk-directives-auto-focus.js +96 -34
  55. package/fesm5/taiga-ui-cdk-directives-auto-focus.js.map +1 -1
  56. package/fesm5/taiga-ui-cdk-enums.js +11 -0
  57. package/fesm5/taiga-ui-cdk-enums.js.map +1 -1
  58. package/fesm5/taiga-ui-cdk-utils-browser.js +2 -2
  59. package/fesm5/taiga-ui-cdk-utils-browser.js.map +1 -1
  60. package/fesm5/taiga-ui-cdk-utils-focus.js +1 -1
  61. package/fesm5/taiga-ui-cdk-utils-focus.js.map +1 -1
  62. package/package.json +1 -1
  63. package/schematics/ng-update/constants/consts.js +28 -0
  64. package/schematics/ng-update/constants/enums.js +22 -0
  65. package/schematics/ng-update/constants/services.d.ts +8 -0
  66. package/schematics/ng-update/constants/services.js +43 -0
  67. package/schematics/ng-update/constants/types.d.ts +1 -0
  68. package/schematics/ng-update/constants/types.js +29 -0
  69. package/schematics/ng-update/constants/warnings.js +22 -0
  70. package/schematics/ng-update/index.js +2 -0
  71. package/schematics/ng-update/steps/rename-types.js +26 -17
  72. package/schematics/ng-update/steps/replace-const.js +2 -2
  73. package/schematics/ng-update/steps/replace-enums.js +2 -2
  74. package/schematics/ng-update/steps/replace-services.d.ts +1 -0
  75. package/schematics/ng-update/steps/replace-services.js +51 -0
  76. package/schematics/ng-update/steps/show-warnings.js +26 -9
  77. package/schematics/utils/{remove-import.d.ts → import-manipulations.d.ts} +1 -0
  78. package/schematics/utils/import-manipulations.js +19 -0
  79. package/schematics/utils/remove-import.js +0 -11
@@ -8,6 +8,7 @@ const rename_types_1 = require("./steps/rename-types");
8
8
  const replace_const_1 = require("./steps/replace-const");
9
9
  const replace_deep_import_1 = require("./steps/replace-deep-import");
10
10
  const show_warnings_1 = require("./steps/show-warnings");
11
+ const replace_services_1 = require("./steps/replace-services");
11
12
  function updateToV3(_) {
12
13
  return (tree, context) => tslib_1.__awaiter(this, void 0, void 0, function* () {
13
14
  context.logger.info(`taiga packages will be updated to ${versions_1.TAIGA_VERSION}`);
@@ -16,6 +17,7 @@ function updateToV3(_) {
16
17
  replace_enums_1.replaceEnums();
17
18
  rename_types_1.renameTypes();
18
19
  replace_const_1.replaceConsts();
20
+ replace_services_1.replaceServices();
19
21
  show_warnings_1.showWarnings(context);
20
22
  ng_morph_1.saveActiveProject();
21
23
  });
@@ -1,34 +1,43 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const get_named_import_references_1 = require("../../utils/get-named-import-references");
4
3
  const ng_morph_1 = require("ng-morph");
4
+ const get_named_import_references_1 = require("../../utils/get-named-import-references");
5
5
  const types_1 = require("../constants/types");
6
- const remove_import_1 = require("../../utils/remove-import");
6
+ const import_manipulations_1 = require("../../utils/import-manipulations");
7
7
  function renameTypes() {
8
- types_1.TYPES_TO_RENAME.forEach(({ from, to, moduleSpecifier }) => {
9
- renameType(from, to, moduleSpecifier);
8
+ types_1.TYPES_TO_RENAME.forEach(({ from, to, moduleSpecifier, preserveGenerics }) => {
9
+ renameType(from, to, moduleSpecifier, preserveGenerics);
10
10
  });
11
11
  }
12
12
  exports.renameTypes = renameTypes;
13
- function renameType(from, to, moduleSpecifier) {
13
+ function renameType(from, to, moduleSpecifier, preserveGenerics = false) {
14
14
  const references = get_named_import_references_1.getNamedImportReferences(from, moduleSpecifier);
15
15
  references.forEach(ref => {
16
16
  const parent = ref.getParent();
17
- if (ng_morph_1.Node.isImportSpecifier(parent) && to) {
18
- renameImport(parent, to, from);
19
- }
20
- else if (ng_morph_1.Node.isImportSpecifier(parent) && !to) {
21
- remove_import_1.removeImport(parent);
17
+ if (ng_morph_1.Node.isImportSpecifier(parent)) {
18
+ processImport(parent, from, to);
22
19
  }
23
20
  else if (ng_morph_1.Node.isTypeReferenceNode(parent)) {
24
- parent.replaceWithText(to || 'any');
21
+ const targetType = preserveGenerics && to ? addGeneric(to, parent.getTypeArguments()) : to;
22
+ parent.replaceWithText(targetType || 'any');
25
23
  }
26
24
  });
27
25
  }
28
- function renameImport(specifier, to, from) {
29
- const namedImport = specifier
30
- .getImportDeclaration()
31
- .getNamedImports()
32
- .find(specifier => specifier.getName() === from);
33
- namedImport === null || namedImport === void 0 ? void 0 : namedImport.replaceWithText(to);
26
+ function processImport(node, from, to) {
27
+ const filePath = node.getSourceFile().getFilePath();
28
+ const targetImportAlreadyExists = Boolean(ng_morph_1.getImports(filePath, { namedImports: to }).length);
29
+ if (to && !targetImportAlreadyExists) {
30
+ import_manipulations_1.renameImport(node, removeGeneric(to), removeGeneric(from));
31
+ }
32
+ else {
33
+ import_manipulations_1.removeImport(node);
34
+ }
35
+ }
36
+ function removeGeneric(type) {
37
+ return type.replace(/<.*>$/gi, '');
38
+ }
39
+ function addGeneric(typeName, generics) {
40
+ const typeArgs = generics.map(t => t.getType().getText());
41
+ const genericType = typeArgs.length ? `<${typeArgs.join(', ')}>` : '';
42
+ return typeName + genericType;
34
43
  }
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const get_named_import_references_1 = require("../../utils/get-named-import-references");
4
4
  const ng_morph_1 = require("ng-morph");
5
- const remove_import_1 = require("../../utils/remove-import");
5
+ const import_manipulations_1 = require("../../utils/import-manipulations");
6
6
  const add_unique_import_1 = require("../../utils/add-unique-import");
7
7
  const consts_1 = require("../constants/consts");
8
8
  function replaceConsts() {
@@ -14,7 +14,7 @@ function replaceConst({ from, to }) {
14
14
  for (let ref of references) {
15
15
  const parent = ref.getParent();
16
16
  if (ng_morph_1.Node.isImportSpecifier(parent)) {
17
- remove_import_1.removeImport(parent);
17
+ import_manipulations_1.removeImport(parent);
18
18
  add_unique_import_1.addUniqueImport(parent.getSourceFile().getFilePath(), to.namedImport || to.name, to.moduleSpecifier);
19
19
  }
20
20
  else {
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ng_morph_1 = require("ng-morph");
4
4
  const get_named_import_references_1 = require("../../utils/get-named-import-references");
5
5
  const enums_1 = require("../constants/enums");
6
- const remove_import_1 = require("../../utils/remove-import");
6
+ const import_manipulations_1 = require("../../utils/import-manipulations");
7
7
  function replaceEnums() {
8
8
  enums_1.ENUMS_TO_REPLACE.forEach(({ name, replaceValues, keepAsType }) => {
9
9
  replaceEnumWithString(name, replaceValues, keepAsType);
@@ -15,7 +15,7 @@ function replaceEnumWithString(enumName, replaceValues, keepAsType = true) {
15
15
  for (let ref of references) {
16
16
  const parent = ref.getParent();
17
17
  if (ng_morph_1.Node.isImportSpecifier(parent) && !(keepAsType && containTypeRef(parent))) {
18
- remove_import_1.removeImport(parent);
18
+ import_manipulations_1.removeImport(parent);
19
19
  continue;
20
20
  }
21
21
  if (ng_morph_1.Node.isTypeReferenceNode(parent) && !keepAsType) {
@@ -0,0 +1 @@
1
+ export declare function replaceServices(): void;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const services_1 = require("../constants/services");
4
+ const get_named_import_references_1 = require("../../utils/get-named-import-references");
5
+ const ng_morph_1 = require("ng-morph");
6
+ const import_manipulations_1 = require("../../utils/import-manipulations");
7
+ const add_unique_import_1 = require("../../utils/add-unique-import");
8
+ function replaceServices() {
9
+ services_1.SERVICES_TO_REPLACE.forEach(service => replaceService(service));
10
+ }
11
+ exports.replaceServices = replaceServices;
12
+ function replaceService({ from, to, replaceMethods }) {
13
+ const references = get_named_import_references_1.getNamedImportReferences(from.name, from.moduleSpecifier);
14
+ references.forEach(ref => {
15
+ const parent = ref.getParent();
16
+ if (ng_morph_1.Node.isImportSpecifier(parent)) {
17
+ import_manipulations_1.removeImport(parent);
18
+ add_unique_import_1.addUniqueImport(parent.getSourceFile().getFilePath(), to.namedImport || to.name, to.moduleSpecifier);
19
+ return;
20
+ }
21
+ if (ng_morph_1.Node.isTypeReferenceNode(parent) && (replaceMethods === null || replaceMethods === void 0 ? void 0 : replaceMethods.length)) {
22
+ replaceProperties(parent, replaceMethods);
23
+ }
24
+ ref.replaceWithText(to.name);
25
+ });
26
+ }
27
+ function replaceProperties(parent, replaceProperties) {
28
+ const statement = parent.getParent();
29
+ const identifier = statement.getChildrenOfKind(ng_morph_1.SyntaxKind.Identifier)[0];
30
+ identifier.findReferencesAsNodes().forEach(ref => {
31
+ let parent = ref.getParent();
32
+ if ((ng_morph_1.Node.isPropertyAccessExpression(parent) &&
33
+ parent.getText().startsWith('this.')) ||
34
+ ng_morph_1.Node.isCallExpression(parent)) {
35
+ parent = parent.getParentIfKind(ng_morph_1.SyntaxKind.PropertyAccessExpression);
36
+ }
37
+ if (ng_morph_1.Node.isPropertyAccessExpression(parent)) {
38
+ replaceProperty(parent, replaceProperties);
39
+ return;
40
+ }
41
+ });
42
+ }
43
+ function replaceProperty(node, properties) {
44
+ const identifiers = node.getChildrenOfKind(ng_morph_1.SyntaxKind.Identifier);
45
+ identifiers.forEach(identifier => {
46
+ const property = properties === null || properties === void 0 ? void 0 : properties.find(property => property.from === identifier.getText());
47
+ if (property) {
48
+ identifier.replaceWithText(property.to);
49
+ }
50
+ });
51
+ }
@@ -1,18 +1,35 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ng_morph_1 = require("ng-morph");
3
4
  const warnings_1 = require("../constants/warnings");
4
- const get_named_import_references_1 = require("../../utils/get-named-import-references");
5
5
  function showWarnings(context) {
6
6
  warnings_1.MIGRATION_WARNINGS.forEach(warning => showWarning(warning, context));
7
7
  }
8
8
  exports.showWarnings = showWarnings;
9
- function showWarning({ name, message, moduleSpecifier }, { logger }) {
10
- const references = get_named_import_references_1.getNamedImportReferences(name, moduleSpecifier);
11
- references.forEach(reference => {
12
- const file = reference.getSourceFile().getFilePath();
13
- const { line, column } = reference
14
- .getSourceFile()
15
- .getLineAndColumnAtPos(reference.getStart());
16
- logger.warn(`[WARNING]: in ${file} at line ${line}, col ${column}: ${message}`);
9
+ function showWarning({ name, message, moduleSpecifier = '**/**' }, { logger }) {
10
+ const references = ng_morph_1.getImports('**/**', {
11
+ moduleSpecifier,
12
+ namedImports: [name],
13
+ })
14
+ .map(i => { var _a; return (_a = i
15
+ .getNamedImports()
16
+ .find(namedImport => namedImport.getName() === name)) === null || _a === void 0 ? void 0 : _a.getNameNode(); })
17
+ .filter((namedImport) => Boolean(namedImport));
18
+ const referencesMeta = references.map(ref => {
19
+ const sourceFile = ref.getSourceFile();
20
+ return {
21
+ sourceFile,
22
+ filePath: sourceFile.getFilePath().toString(),
23
+ startLinePos: ref.getStartLinePos(),
24
+ };
25
+ });
26
+ /**
27
+ * We have to twice iterate array with refs because otherwise we get error:
28
+ * > Attempted to get information from a node that was removed or forgotten.
29
+ * See this {@link https://ts-morph.com/manipulation/#strongwarningstrong warning}
30
+ */
31
+ referencesMeta.forEach(({ sourceFile, filePath, startLinePos }) => {
32
+ logger.warn(`[WARNING] in ${filePath}: ${message}`);
33
+ sourceFile.insertText(startLinePos, `// TODO: ${message}\n`);
17
34
  });
18
35
  }
@@ -1,2 +1,3 @@
1
1
  import { ImportSpecifier } from 'ng-morph';
2
2
  export declare function removeImport(specifier: ImportSpecifier): void;
3
+ export declare function renameImport(specifier: ImportSpecifier, to: string, from: string): void;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function removeImport(specifier) {
4
+ if (specifier.getImportDeclaration().getNamedImports().length === 1) {
5
+ specifier.getImportDeclaration().remove();
6
+ }
7
+ else {
8
+ specifier.remove();
9
+ }
10
+ }
11
+ exports.removeImport = removeImport;
12
+ function renameImport(specifier, to, from) {
13
+ const namedImport = specifier
14
+ .getImportDeclaration()
15
+ .getNamedImports()
16
+ .find(specifier => specifier.getName() === from);
17
+ namedImport === null || namedImport === void 0 ? void 0 : namedImport.replaceWithText(to);
18
+ }
19
+ exports.renameImport = renameImport;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- function removeImport(specifier) {
4
- if (specifier.getImportDeclaration().getNamedImports().length === 1) {
5
- specifier.getImportDeclaration().remove();
6
- }
7
- else {
8
- specifier.remove();
9
- }
10
- }
11
- exports.removeImport = removeImport;