@taiga-ui/cdk 4.4.1 → 4.5.0-canary.49229f4

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 (90) hide show
  1. package/constants/used-icons.d.ts +1 -1
  2. package/constants/version.d.ts +1 -1
  3. package/constants/version.js +1 -1
  4. package/directives/auto-focus/handlers/default.handler.d.ts +3 -2
  5. package/directives/native-validator/native-validator.directive.d.ts +1 -2
  6. package/esm2022/constants/used-icons.mjs +3 -1
  7. package/esm2022/constants/version.mjs +2 -2
  8. package/esm2022/date-time/day.mjs +9 -9
  9. package/esm2022/date-time/month.mjs +4 -4
  10. package/esm2022/directives/auto-focus/autofocus.options.mjs +2 -2
  11. package/esm2022/directives/auto-focus/handlers/default.handler.mjs +5 -3
  12. package/esm2022/directives/native-validator/native-validator.directive.mjs +4 -7
  13. package/esm2022/directives/obscured/obscured.service.mjs +4 -4
  14. package/esm2022/directives/pan/pan.service.mjs +3 -3
  15. package/esm2022/directives/swipe/swipe.service.mjs +7 -7
  16. package/esm2022/directives/zoom/zoom.service.mjs +5 -5
  17. package/esm2022/observables/zone.mjs +24 -4
  18. package/esm2022/services/id.service.mjs +6 -7
  19. package/esm2022/utils/color/hex-to-rgba.mjs +2 -2
  20. package/esm2022/utils/color/parse-gradient.mjs +10 -10
  21. package/esm2022/utils/color/rgba-to-hex.mjs +8 -10
  22. package/esm2022/utils/focus/move-focus.mjs +2 -2
  23. package/esm2022/utils/math/round-with.mjs +3 -3
  24. package/esm2022/utils/miscellaneous/distance-between-touches.mjs +2 -2
  25. package/esm2022/utils/miscellaneous/is-valid-url.mjs +7 -7
  26. package/fesm2022/taiga-ui-cdk-constants.mjs +3 -1
  27. package/fesm2022/taiga-ui-cdk-constants.mjs.map +1 -1
  28. package/fesm2022/taiga-ui-cdk-date-time.mjs +11 -11
  29. package/fesm2022/taiga-ui-cdk-date-time.mjs.map +1 -1
  30. package/fesm2022/taiga-ui-cdk-directives-auto-focus.mjs +5 -3
  31. package/fesm2022/taiga-ui-cdk-directives-auto-focus.mjs.map +1 -1
  32. package/fesm2022/taiga-ui-cdk-directives-native-validator.mjs +3 -6
  33. package/fesm2022/taiga-ui-cdk-directives-native-validator.mjs.map +1 -1
  34. package/fesm2022/taiga-ui-cdk-directives-obscured.mjs +3 -3
  35. package/fesm2022/taiga-ui-cdk-directives-obscured.mjs.map +1 -1
  36. package/fesm2022/taiga-ui-cdk-directives-pan.mjs +2 -2
  37. package/fesm2022/taiga-ui-cdk-directives-pan.mjs.map +1 -1
  38. package/fesm2022/taiga-ui-cdk-directives-swipe.mjs +6 -6
  39. package/fesm2022/taiga-ui-cdk-directives-swipe.mjs.map +1 -1
  40. package/fesm2022/taiga-ui-cdk-directives-zoom.mjs +4 -4
  41. package/fesm2022/taiga-ui-cdk-directives-zoom.mjs.map +1 -1
  42. package/fesm2022/taiga-ui-cdk-observables.mjs +24 -5
  43. package/fesm2022/taiga-ui-cdk-observables.mjs.map +1 -1
  44. package/fesm2022/taiga-ui-cdk-services.mjs +5 -6
  45. package/fesm2022/taiga-ui-cdk-services.mjs.map +1 -1
  46. package/fesm2022/taiga-ui-cdk-utils-color.mjs +17 -19
  47. package/fesm2022/taiga-ui-cdk-utils-color.mjs.map +1 -1
  48. package/fesm2022/taiga-ui-cdk-utils-focus.mjs +1 -1
  49. package/fesm2022/taiga-ui-cdk-utils-focus.mjs.map +1 -1
  50. package/fesm2022/taiga-ui-cdk-utils-math.mjs +2 -2
  51. package/fesm2022/taiga-ui-cdk-utils-math.mjs.map +1 -1
  52. package/fesm2022/taiga-ui-cdk-utils-miscellaneous.mjs +7 -7
  53. package/fesm2022/taiga-ui-cdk-utils-miscellaneous.mjs.map +1 -1
  54. package/observables/zone.d.ts +7 -5
  55. package/package.json +356 -356
  56. package/schematics/constants/taiga-styles.d.ts +0 -2
  57. package/schematics/constants/taiga-styles.js +1 -3
  58. package/schematics/ng-add/index.js +4 -7
  59. package/schematics/ng-add/schema.d.ts +0 -1
  60. package/schematics/ng-add/schema.json +0 -9
  61. package/schematics/ng-add/steps/add-taiga-modules.js +10 -1
  62. package/schematics/ng-add/steps/add-taiga-styles.js +1 -4
  63. package/schematics/ng-add/steps/wrap-with-tui-root.js +7 -2
  64. package/schematics/ng-update/v4/index.js +4 -0
  65. package/schematics/ng-update/v4/migrate-addon-doc/replace-symbols.js +4 -0
  66. package/schematics/ng-update/v4/steps/constants/attr-with-values-to-replace.js +5 -0
  67. package/schematics/ng-update/v4/steps/constants/identifiers-to-replace.js +0 -41
  68. package/schematics/ng-update/v4/steps/drop-universal-mock.d.ts +2 -0
  69. package/schematics/ng-update/v4/steps/drop-universal-mock.js +20 -0
  70. package/schematics/ng-update/v4/steps/migrate-alert-service.js +2 -2
  71. package/schematics/ng-update/v4/steps/migrate-editor.d.ts +5 -0
  72. package/schematics/ng-update/v4/steps/migrate-editor.js +77 -0
  73. package/schematics/ng-update/v4/steps/migrate-legacy-mask.js +2 -2
  74. package/schematics/ng-update/v4/steps/migrate-number-format-settings.js +1 -1
  75. package/schematics/ng-update/v4/steps/migrate-root.js +28 -8
  76. package/schematics/ng-update/v4/steps/restore-tui-mapper.js +1 -1
  77. package/schematics/ng-update/v4/steps/restore-tui-matcher.js +1 -1
  78. package/schematics/ng-update/v4/steps/templates/migrate-avatar.js +4 -1
  79. package/schematics/ng-update/v4/steps/templates/migrate-overscroll.js +5 -1
  80. package/schematics/ng-update/v4/steps/templates/migrate-prevent-default.js +3 -3
  81. package/schematics/ng-update/v4/steps/templates/migrate-progress-segmented.js +2 -2
  82. package/schematics/ng-update/v4/steps/update-packages.d.ts +0 -1
  83. package/schematics/ng-update/v4/steps/update-packages.js +1 -6
  84. package/schematics/ng-update/v4/steps/utils/clean-object.js +1 -1
  85. package/schematics/utils/add-unique-import.js +4 -3
  86. package/schematics/utils/angular-json-manipulations.js +5 -3
  87. package/schematics/utils/get-component-from-identifier.js +1 -1
  88. package/schematics/utils/templates/get-component-templates.js +2 -2
  89. package/schematics/utils/templates/ng-component-input-manipulations.js +3 -3
  90. package/services/id.service.d.ts +1 -3
@@ -1,4 +1,2 @@
1
- export declare const TAIGA_GLOBAL_OLD_STYLE = "node_modules/@taiga-ui/core/styles/taiga-ui-global.less";
2
- export declare const TAIGA_GLOBAL_NEW_STYLE = "node_modules/@taiga-ui/styles/taiga-ui-global.less";
3
1
  export declare const TAIGA_THEME_STYLE = "node_modules/@taiga-ui/core/styles/taiga-ui-theme.less";
4
2
  export declare const TAIGA_THEME_FONTS = "node_modules/@taiga-ui/core/styles/taiga-ui-fonts.less";
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TAIGA_THEME_FONTS = exports.TAIGA_THEME_STYLE = exports.TAIGA_GLOBAL_NEW_STYLE = exports.TAIGA_GLOBAL_OLD_STYLE = void 0;
4
- exports.TAIGA_GLOBAL_OLD_STYLE = 'node_modules/@taiga-ui/core/styles/taiga-ui-global.less';
5
- exports.TAIGA_GLOBAL_NEW_STYLE = 'node_modules/@taiga-ui/styles/taiga-ui-global.less';
3
+ exports.TAIGA_THEME_FONTS = exports.TAIGA_THEME_STYLE = void 0;
6
4
  exports.TAIGA_THEME_STYLE = 'node_modules/@taiga-ui/core/styles/taiga-ui-theme.less';
7
5
  exports.TAIGA_THEME_FONTS = 'node_modules/@taiga-ui/core/styles/taiga-ui-fonts.less';
@@ -14,14 +14,11 @@ function addDependencies(tree, options) {
14
14
  type: ng_morph_1.NodeDependencyType.Default,
15
15
  });
16
16
  });
17
+ (0, ng_morph_1.addPackageJsonDependency)(tree, {
18
+ name: '@taiga-ui/event-plugins',
19
+ version: '^4.0.2',
20
+ });
17
21
  removeTaigaSchematicsPackage(tree);
18
- if (options.addGlobalStyles) {
19
- (0, ng_morph_1.addPackageJsonDependency)(tree, {
20
- name: '@taiga-ui/styles',
21
- version: versions_1.TAIGA_VERSION,
22
- type: ng_morph_1.NodeDependencyType.Default,
23
- });
24
- }
25
22
  if (packages.includes('addon-table') || packages.includes('addon-mobile')) {
26
23
  addAngularCdkDep(tree);
27
24
  }
@@ -1,5 +1,4 @@
1
1
  export interface TuiSchema {
2
- readonly addGlobalStyles: boolean;
3
2
  readonly addons: readonly string[];
4
3
  readonly project: string;
5
4
  /**
@@ -11,15 +11,6 @@
11
11
  "$source": "projectName"
12
12
  }
13
13
  },
14
- "addGlobalStyles": {
15
- "description": "Setting up global styles",
16
- "type": "boolean",
17
- "default": false,
18
- "x-prompt": {
19
- "message": "Do you want to use global Taiga UI classes, such as 'tui-space', 'tui-skeleton', etc?",
20
- "type": "confirmation"
21
- }
22
- },
23
14
  "addons": {
24
15
  "description": "Setting up additional packages",
25
16
  "type": "array",
@@ -19,12 +19,20 @@ function addTuiModules({ mainClass, context, }) {
19
19
  (0, ng_morph_1.addImportToNgModule)(mainClass, module.name, { unique: true });
20
20
  (0, add_unique_import_1.addUniqueImport)(mainModulePath, module.name, module.packageName);
21
21
  });
22
+ (0, ng_morph_1.addProviderToNgModule)(mainClass, 'NG_EVENT_PLUGINS', { unique: true });
23
+ (0, add_unique_import_1.addUniqueImport)(mainModulePath, 'NG_EVENT_PLUGINS', '@taiga-ui/event-plugins');
22
24
  context.logger.info(`${modules.map((module) => module.name)} was added to ${mainModulePath}`);
23
25
  }
24
26
  function addTuiEntitiesToStandalone({ bootstrapFunction, options, context, }) {
25
27
  const [rootComponentIdentifier, bootstrapOptions = bootstrapFunction.addArgument('{providers}: []'),] = bootstrapFunction.getArguments();
28
+ if (!rootComponentIdentifier) {
29
+ return;
30
+ }
26
31
  const mainClass = (0, get_component_from_identifier_1.getComponentFromIdentifier)(rootComponentIdentifier);
27
32
  const optionsObject = getOptionsObject(bootstrapOptions);
33
+ if (!optionsObject) {
34
+ return;
35
+ }
28
36
  if (mainClass) {
29
37
  addMainModuleToRootComponent({ mainClass, options, context });
30
38
  addRootTuiProvidersToBootstrapFn(optionsObject);
@@ -66,11 +74,12 @@ function getModules(extraModules) {
66
74
  return [...(extraModules || []), modules_1.MAIN_MODULE];
67
75
  }
68
76
  function getOptionsObject(options) {
77
+ var _a;
69
78
  if (ng_morph_1.Node.isObjectLiteralExpression(options)) {
70
79
  return options;
71
80
  }
72
81
  const definition = options.getDefinitionNodes()[0];
73
- return definition.getChildrenOfKind(ng_morph_1.SyntaxKind.ObjectLiteralExpression)[0];
82
+ return (_a = definition === null || definition === void 0 ? void 0 : definition.getChildrenOfKind(ng_morph_1.SyntaxKind.ObjectLiteralExpression)[0]) !== null && _a !== void 0 ? _a : null;
74
83
  }
75
84
  function addTaigaModules(options) {
76
85
  return (tree, context) => tslib_1.__awaiter(this, void 0, void 0, function* () {
@@ -6,10 +6,7 @@ const angular_json_manipulations_1 = require("../../utils/angular-json-manipulat
6
6
  function addTaigaStyles(options) {
7
7
  return (_, context) => {
8
8
  const taigaLocalStyles = [taiga_styles_1.TAIGA_THEME_STYLE, taiga_styles_1.TAIGA_THEME_FONTS];
9
- const taigaStyles = options.addGlobalStyles
10
- ? [...taigaLocalStyles, taiga_styles_1.TAIGA_GLOBAL_NEW_STYLE]
11
- : taigaLocalStyles;
12
- return (0, angular_json_manipulations_1.addStylesToAngularJson)(options, context, taigaStyles);
9
+ return (0, angular_json_manipulations_1.addStylesToAngularJson)(options, context, taigaLocalStyles);
13
10
  };
14
11
  }
15
12
  exports.addTaigaStyles = addTaigaStyles;
@@ -32,8 +32,13 @@ function getAppTemplatePath(mainPath) {
32
32
  const standaloneBootstrapFunction = (0, get_standalone_bootstrap_function_1.getStandaloneBootstrapFunction)(mainPath);
33
33
  if (standaloneBootstrapFunction) {
34
34
  const [componentIdentifier] = standaloneBootstrapFunction.getArguments();
35
- const component = (0, get_component_from_identifier_1.getComponentFromIdentifier)(componentIdentifier);
36
- return (component && getTemplatePathFromComponent(component)) || '';
35
+ if (componentIdentifier) {
36
+ const component = (0, get_component_from_identifier_1.getComponentFromIdentifier)(componentIdentifier);
37
+ if (component) {
38
+ return getTemplatePathFromComponent(component);
39
+ }
40
+ }
41
+ return '';
37
42
  }
38
43
  const mainModule = (0, ng_morph_1.getMainModule)(mainPath);
39
44
  if (!mainModule) {
@@ -16,11 +16,14 @@ const steps_2 = require("./steps");
16
16
  const constants_1 = require("./steps/constants");
17
17
  const modules_to_replace_1 = require("./steps/constants/modules-to-replace");
18
18
  const types_1 = require("./steps/constants/types");
19
+ const drop_universal_mock_1 = require("./steps/drop-universal-mock");
20
+ const migrate_editor_1 = require("./steps/migrate-editor");
19
21
  const migrate_root_1 = require("./steps/migrate-root");
20
22
  const replace_modules_with_providers_1 = require("./steps/utils/replace-modules-with-providers");
21
23
  function main(options) {
22
24
  return (tree, context) => {
23
25
  const fileSystem = (0, get_file_system_1.getFileSystem)(tree);
26
+ (0, migrate_editor_1.migrateEditor)(fileSystem, options);
24
27
  (0, steps_1.replaceEnums)(options, enums_1.ENUMS_TO_REPLACE);
25
28
  (0, migrate_root_1.migrateRoot)(fileSystem, options);
26
29
  (0, replace_services_1.replaceServices)(options, constants_1.SERVICES_TO_REPLACE);
@@ -37,6 +40,7 @@ function main(options) {
37
40
  (0, steps_2.migrateAlertService)(options);
38
41
  (0, steps_2.migrateNumberFormatSettings)(options);
39
42
  (0, steps_2.migrateMonthContext)(options);
43
+ (0, drop_universal_mock_1.dropUniversalMock)(options);
40
44
  (0, ng_morph_1.saveActiveProject)();
41
45
  (0, steps_2.migrateTemplates)(fileSystem, options);
42
46
  (0, steps_1.showWarnings)(context, constants_1.MIGRATION_WARNINGS);
@@ -99,6 +99,10 @@ exports.DOC_SYMBOLS_TO_REPLACE = [
99
99
  name: 'TuiAddonDocModule',
100
100
  moduleSpecifier: '@taiga-ui/addon-doc',
101
101
  },
102
+ {
103
+ name: 'TuiDocExampleModule',
104
+ moduleSpecifier: '@taiga-ui/addon-doc',
105
+ },
102
106
  ],
103
107
  to: {
104
108
  name: 'TuiAddonDoc',
@@ -29,6 +29,11 @@ exports.ATTR_WITH_VALUES_TO_REPLACE = [
29
29
  { from: 'onLight', to: 'light' },
30
30
  ],
31
31
  },
32
+ {
33
+ attrNames: ['tuiHintAppearance'],
34
+ newAttrName: 'tuiHintAppearance',
35
+ valueReplacer: [{ from: 'onDark', to: 'dark' }],
36
+ },
32
37
  {
33
38
  attrNames: ['[pseudoActive]'],
34
39
  newAttrName: '[tuiAppearanceState]',
@@ -587,47 +587,6 @@ exports.IDENTIFIERS_TO_REPLACE = [
587
587
  moduleSpecifier: '@taiga-ui/kit',
588
588
  },
589
589
  },
590
- {
591
- from: { name: 'TuiEditorModule', moduleSpecifier: '@tinkoff/tui-editor' },
592
- to: [
593
- { name: 'TuiEditor', moduleSpecifier: '@taiga-ui/editor' },
594
- { name: 'TuiEditorSocket', moduleSpecifier: '@taiga-ui/editor' },
595
- ],
596
- },
597
- {
598
- from: { name: 'TuiEditorSocketModule', moduleSpecifier: '@tinkoff/tui-editor' },
599
- to: { name: 'TuiEditorSocket', moduleSpecifier: '@taiga-ui/editor' },
600
- },
601
- {
602
- from: { name: 'TuiToolbarModule', moduleSpecifier: '@tinkoff/tui-editor' },
603
- to: { name: 'TuiToolbar', moduleSpecifier: '@taiga-ui/editor' },
604
- },
605
- {
606
- from: { name: 'defaultEditorExtensions', moduleSpecifier: '@tinkoff/tui-editor' },
607
- to: { name: 'TUI_EDITOR_DEFAULT_EXTENSIONS', moduleSpecifier: '@taiga-ui/editor' },
608
- },
609
- {
610
- from: {
611
- name: 'TUI_EDITOR_DEFAULT_EXTENSIONS',
612
- moduleSpecifier: '@tinkoff/tui-editor',
613
- },
614
- to: { name: 'TUI_EDITOR_DEFAULT_EXTENSIONS', moduleSpecifier: '@taiga-ui/editor' },
615
- },
616
- {
617
- from: [
618
- { name: 'defaultEditorTools', moduleSpecifier: '@tinkoff/tui-editor' },
619
- { name: 'TUI_EDITOR_DEFAULT_TOOLS', moduleSpecifier: '@tinkoff/tui-editor' },
620
- ],
621
- to: { name: 'TUI_EDITOR_DEFAULT_TOOLS', moduleSpecifier: '@taiga-ui/editor' },
622
- },
623
- {
624
- from: { name: 'TuiColorPickerModule', moduleSpecifier: '@tinkoff/tui-editor' },
625
- to: { name: 'TuiColorPickerModule', moduleSpecifier: '@taiga-ui/legacy' },
626
- },
627
- {
628
- from: { name: 'TuiInputColorModule', moduleSpecifier: '@tinkoff/tui-editor' },
629
- to: { name: 'TuiInputColorModule', moduleSpecifier: '@taiga-ui/legacy' },
630
- },
631
590
  {
632
591
  from: { name: 'TuiFadeModule', moduleSpecifier: '@taiga-ui/experimental' },
633
592
  to: {
@@ -0,0 +1,2 @@
1
+ import type { TuiSchema } from '../../../ng-add/schema';
2
+ export declare function dropUniversalMock(options: TuiSchema): void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dropUniversalMock = void 0;
4
+ const ng_morph_1 = require("ng-morph");
5
+ const file_globs_1 = require("../../../constants/file-globs");
6
+ const colored_log_1 = require("../../../utils/colored-log");
7
+ function dropUniversalMock(options) {
8
+ const moduleSpecifier = '@ng-web-apis/universal/mocks';
9
+ const imports = (0, ng_morph_1.getImports)(file_globs_1.ALL_TS_FILES, { moduleSpecifier });
10
+ if (imports.length) {
11
+ !options['skip-logs'] &&
12
+ (0, colored_log_1.infoLog)(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} drop "${moduleSpecifier}" import`);
13
+ const match = new RegExp(`import\\s+[\\'\\"\`]${moduleSpecifier}[\\'\\"\`];`, 'g');
14
+ imports.forEach((declaration) => declaration
15
+ .getSourceFile()
16
+ .replaceWithText(declaration.getSourceFile().getFullText().replaceAll(match, '')));
17
+ !options['skip-logs'] && (0, colored_log_1.titleLog)(`${colored_log_1.FINISH_SYMBOL} successfully migrated \n`);
18
+ }
19
+ }
20
+ exports.dropUniversalMock = dropUniversalMock;
@@ -8,10 +8,10 @@ const OPTIONS_MIGRATIONS = {
8
8
  autoClose: (property) => {
9
9
  const [propertyKey, propertyValue] = property.getText().split(/\s?:\s?/);
10
10
  switch (propertyValue) {
11
- case 'true':
12
- return property.replaceWithText(`${propertyKey}: 3_000`);
13
11
  case 'false':
14
12
  return property.replaceWithText(`${propertyKey}: 0`);
13
+ case 'true':
14
+ return property.replaceWithText(`${propertyKey}: 3_000`);
15
15
  default:
16
16
  return null;
17
17
  }
@@ -0,0 +1,5 @@
1
+ /// <reference lib="es2021" />
2
+ import { type DevkitFileSystem } from 'ng-morph';
3
+ import type { TuiSchema } from '../../../ng-add/schema';
4
+ export declare const TUI_EDITOR_VERSION = "^4.0.0";
5
+ export declare function migrateEditor(fileSystem: DevkitFileSystem, options: TuiSchema): void;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateEditor = exports.TUI_EDITOR_VERSION = void 0;
4
+ /// <reference lib="es2021" />
5
+ const ng_morph_1 = require("ng-morph");
6
+ const ng_morph_2 = require("ng-morph");
7
+ const file_globs_1 = require("../../../constants/file-globs");
8
+ const colored_log_1 = require("../../../utils/colored-log");
9
+ const replace_identifier_1 = require("../../steps/replace-identifier");
10
+ const replace_package_name_1 = require("../../steps/replace-package-name");
11
+ exports.TUI_EDITOR_VERSION = '^4.0.0';
12
+ function migrateEditor(fileSystem, options) {
13
+ const moduleSpecifier = ['@tinkoff/tui-editor', '@taiga-ui/addon-editor'];
14
+ const hasEditor = moduleSpecifier.every((pkg) => !(0, ng_morph_1.getPackageJsonDependency)(fileSystem.tree, pkg));
15
+ if (hasEditor) {
16
+ return;
17
+ }
18
+ !options['skip-logs'] &&
19
+ (0, colored_log_1.infoLog)(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} migrating editor...`);
20
+ (0, replace_identifier_1.replaceIdentifiers)(options, [
21
+ {
22
+ from: { name: 'TuiEditorModule', moduleSpecifier },
23
+ to: [
24
+ { name: 'TuiEditor', moduleSpecifier: '@taiga-ui/editor' },
25
+ { name: 'TuiEditorSocket', moduleSpecifier: '@taiga-ui/editor' },
26
+ ],
27
+ },
28
+ {
29
+ from: { name: 'TuiEditorSocketModule', moduleSpecifier },
30
+ to: { name: 'TuiEditorSocket', moduleSpecifier: '@taiga-ui/editor' },
31
+ },
32
+ {
33
+ from: { name: 'TuiToolbarModule', moduleSpecifier },
34
+ to: { name: 'TuiToolbar', moduleSpecifier: '@taiga-ui/editor' },
35
+ },
36
+ {
37
+ from: { name: 'defaultEditorExtensions', moduleSpecifier },
38
+ to: {
39
+ name: 'TUI_EDITOR_DEFAULT_EXTENSIONS',
40
+ moduleSpecifier: '@taiga-ui/editor',
41
+ },
42
+ },
43
+ {
44
+ from: { name: 'TUI_EDITOR_DEFAULT_EXTENSIONS', moduleSpecifier },
45
+ to: {
46
+ name: 'TUI_EDITOR_DEFAULT_EXTENSIONS',
47
+ moduleSpecifier: '@taiga-ui/editor',
48
+ },
49
+ },
50
+ {
51
+ from: [
52
+ { name: 'defaultEditorTools', moduleSpecifier },
53
+ {
54
+ name: 'TUI_EDITOR_DEFAULT_TOOLS',
55
+ moduleSpecifier: '@tinkoff/tui-editor',
56
+ },
57
+ ],
58
+ to: { name: 'TUI_EDITOR_DEFAULT_TOOLS', moduleSpecifier: '@taiga-ui/editor' },
59
+ },
60
+ {
61
+ from: { name: 'TuiColorPickerModule', moduleSpecifier },
62
+ to: { name: 'TuiColorPickerModule', moduleSpecifier: '@taiga-ui/legacy' },
63
+ },
64
+ {
65
+ from: { name: 'TuiInputColorModule', moduleSpecifier },
66
+ to: { name: 'TuiInputColorModule', moduleSpecifier: '@taiga-ui/legacy' },
67
+ },
68
+ ]);
69
+ (0, ng_morph_2.getSourceFiles)(file_globs_1.ALL_TS_FILES).forEach((sourceFile) => sourceFile.replaceWithText(sourceFile
70
+ .getFullText()
71
+ .replaceAll(/import\(['"`](@tinkoff|@taiga-ui)\/(tui-editor|addon-editor)\/(.*)['"`]\)/g, "import('@taiga-ui/editor')")));
72
+ (0, ng_morph_2.saveActiveProject)();
73
+ moduleSpecifier.forEach((pkg) => (0, replace_package_name_1.replacePackageName)(pkg, { name: '@taiga-ui/editor', version: exports.TUI_EDITOR_VERSION }, fileSystem.tree));
74
+ (0, ng_morph_2.saveActiveProject)();
75
+ !options['skip-logs'] && (0, colored_log_1.titleLog)(`${colored_log_1.FINISH_SYMBOL} successfully migrated \n`);
76
+ }
77
+ exports.migrateEditor = migrateEditor;
@@ -29,7 +29,7 @@ function migrateTuiMaskedMoneyValueIsEmpty(options) {
29
29
  }
30
30
  else if (ng_morph_1.Node.isCallExpression(parent)) {
31
31
  const [value] = parent.getArguments();
32
- parent.replaceWithText(`Number.isNaN(maskitoParseNumber(${value.getText()}, ','))`);
32
+ parent.replaceWithText(`Number.isNaN(maskitoParseNumber(${value === null || value === void 0 ? void 0 : value.getText()}, ','))`);
33
33
  }
34
34
  });
35
35
  }
@@ -48,7 +48,7 @@ function migrateTuiMaskedNumberStringToNumber(options) {
48
48
  }
49
49
  else if (ng_morph_1.Node.isCallExpression(parent)) {
50
50
  const [value, decimalSeparator] = parent.getArguments();
51
- parent.replaceWithText(`maskitoParseNumber(${value.getText()}, ${decimalSeparator.getText()})`);
51
+ parent.replaceWithText(`maskitoParseNumber(${value === null || value === void 0 ? void 0 : value.getText()}, ${decimalSeparator === null || decimalSeparator === void 0 ? void 0 : decimalSeparator.getText()})`);
52
52
  }
53
53
  });
54
54
  }
@@ -8,7 +8,7 @@ const OPTIONS_MIGRATIONS = {
8
8
  decimalLimit: (property) => property.replaceWithText(property.getText().replace('decimalLimit', 'precision')),
9
9
  decimal: (property) => {
10
10
  const [, propertyValue] = property.getText().split(/\s?:\s?/);
11
- property.replaceWithText(propertyValue.match(/^['"`]never['"`]$/)
11
+ property.replaceWithText((propertyValue === null || propertyValue === void 0 ? void 0 : propertyValue.match(/^['"`]never['"`]$/))
12
12
  ? 'precision: 0'
13
13
  : property.getText().replace('decimal', 'decimalMode'));
14
14
  },
@@ -38,25 +38,45 @@ function replaceRootIdentifier(ref, fileSystem) {
38
38
  .find((arg) => arg.getText() === ref.getText());
39
39
  if (node) {
40
40
  callExpression.removeArgument(node);
41
- addProviders(callExpression, fileSystem);
41
+ addProviders({ callExpression, fileSystem });
42
42
  }
43
43
  }
44
44
  else {
45
45
  ref.replaceWithText('TuiRoot');
46
+ addProviders({ fileSystem, modulePath: ref.getSourceFile().getFilePath() });
46
47
  }
47
48
  }
48
- function addProviders(callExpression, fileSystem) {
49
- const array = callExpression.getParentWhile(ng_morph_1.Node.isArrayLiteralExpression);
50
- if (!array) {
49
+ function addProviders({ callExpression, fileSystem, modulePath, }) {
50
+ var _a;
51
+ const providersArray = callExpression === null || callExpression === void 0 ? void 0 : callExpression.getParentWhile(ng_morph_1.Node.isArrayLiteralExpression);
52
+ const module = modulePath && ((_a = (0, ng_morph_1.getNgModules)(modulePath)) === null || _a === void 0 ? void 0 : _a[0]);
53
+ if (!providersArray && !modulePath) {
51
54
  return;
52
55
  }
53
- array.addElement('NG_EVENT_PLUGINS');
54
- (0, add_unique_import_1.addUniqueImport)(array.getSourceFile().getFilePath(), 'NG_EVENT_PLUGINS', '@taiga-ui/event-plugins');
56
+ const path = providersArray
57
+ ? providersArray.getSourceFile().getFilePath()
58
+ : modulePath || '';
59
+ if (providersArray) {
60
+ providersArray.addElement('NG_EVENT_PLUGINS');
61
+ }
62
+ else if (module) {
63
+ (0, ng_morph_1.addProviderToNgModule)(module, 'NG_EVENT_PLUGINS', { unique: true });
64
+ }
65
+ if (providersArray || module) {
66
+ (0, add_unique_import_1.addUniqueImport)(path, 'NG_EVENT_PLUGINS', '@taiga-ui/event-plugins');
67
+ }
55
68
  (0, ng_morph_1.getActiveProject)();
56
69
  const proprietary = (0, ng_morph_1.getPackageJsonDependency)(fileSystem.tree, '@taiga-ui/proprietary-core') ||
57
70
  (0, ng_morph_1.getPackageJsonDependency)(fileSystem.tree, '@taiga-ui/proprietary');
58
71
  if (proprietary) {
59
- array.addElement('TBANK_PROVIDERS');
60
- (0, add_unique_import_1.addUniqueImport)(array.getSourceFile().getFilePath(), 'TBANK_PROVIDERS', '@taiga-ui/proprietary');
72
+ if (providersArray) {
73
+ providersArray.addElement('TBANK_PROVIDERS');
74
+ }
75
+ else if (module) {
76
+ (0, ng_morph_1.addProviderToNgModule)(module, 'TBANK_PROVIDERS', { unique: true });
77
+ }
78
+ if (providersArray || module) {
79
+ (0, add_unique_import_1.addUniqueImport)(path, 'TBANK_PROVIDERS', '@taiga-ui/proprietary');
80
+ }
61
81
  }
62
82
  }
@@ -20,7 +20,7 @@ function updateTuiMapper(options) {
20
20
  return;
21
21
  }
22
22
  const [inputType] = typeArguments;
23
- inputType.replaceWithText(`[${inputType.getText()}, ...any]`);
23
+ inputType === null || inputType === void 0 ? void 0 : inputType.replaceWithText(`[${inputType.getText()}, ...any]`);
24
24
  }
25
25
  }
26
26
  }
@@ -20,7 +20,7 @@ function updateTuiMatcher(options) {
20
20
  return;
21
21
  }
22
22
  const [inputType] = typeArguments;
23
- inputType.replaceWithText(`[${inputType.getText()}, ...any]`);
23
+ inputType === null || inputType === void 0 ? void 0 : inputType.replaceWithText(`[${inputType.getText()}, ...any]`);
24
24
  }
25
25
  }
26
26
  }
@@ -30,7 +30,10 @@ function migrateAvatar({ resource, recorder, fileSystem, }) {
30
30
  const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
31
31
  const avatarElements = (0, elements_1.findElementsByTagName)(template, 'tui-avatar');
32
32
  const markerIconElements = (0, elements_1.findElementsByTagName)(template, 'tui-marker-icon');
33
- [...avatarElements, ...markerIconElements].forEach(({ attrs, sourceCodeLocation }) => {
33
+ [
34
+ ...avatarElements.filter(({ attrs }) => (0, inputs_1.findAttr)(attrs, 'avatarurl') || (0, inputs_1.findAttr)(attrs, 'text')),
35
+ ...markerIconElements,
36
+ ].forEach(({ attrs, sourceCodeLocation }) => {
34
37
  if (!sourceCodeLocation) {
35
38
  return;
36
39
  }
@@ -7,6 +7,7 @@ const template_resource_1 = require("../../../../utils/templates/template-resour
7
7
  const remove_attrs_1 = require("../utils/remove-attrs");
8
8
  const overscrollAttrName = 'tuiOverscroll';
9
9
  function migrateOverscroll({ resource, recorder, fileSystem, }) {
10
+ var _a;
10
11
  const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
11
12
  const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
12
13
  const elements = (0, elements_1.findElementsWithDirective)(template, overscrollAttrName).filter(({ sourceCodeLocation }) => !!sourceCodeLocation);
@@ -18,7 +19,10 @@ function migrateOverscroll({ resource, recorder, fileSystem, }) {
18
19
  attrToRemove &&
19
20
  (0, remove_attrs_1.removeAttrs)([attrToRemove], sourceCodeLocation, recorder, templateOffset);
20
21
  });
21
- addTodo(recorder, elements[0].sourceCodeLocation, templateOffset);
22
+ const element = (_a = elements[0]) === null || _a === void 0 ? void 0 : _a.sourceCodeLocation;
23
+ if (element) {
24
+ addTodo(recorder, element, templateOffset);
25
+ }
22
26
  }
23
27
  exports.migrateOverscroll = migrateOverscroll;
24
28
  function addTodo(recorder, sourceCodeLocation, templateOffset) {
@@ -9,7 +9,7 @@ function migratePreventDefault({ resource, recorder, fileSystem, }) {
9
9
  const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
10
10
  const elements = (0, elements_1.findElementsWithAttribute)(template, 'tuiPreventDefault');
11
11
  elements.forEach(({ attrs, sourceCodeLocation }) => {
12
- var _a, _b;
12
+ var _a, _b, _c, _d;
13
13
  if (!sourceCodeLocation) {
14
14
  return;
15
15
  }
@@ -18,8 +18,8 @@ function migratePreventDefault({ resource, recorder, fileSystem, }) {
18
18
  return;
19
19
  }
20
20
  const event = preventDefaultAttr.value;
21
- const preventDefaultStart = ((_a = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[preventDefaultAttr.name].startOffset) || 0;
22
- const preventDefaultEnd = ((_b = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.attrs) === null || _b === void 0 ? void 0 : _b[preventDefaultAttr.name].endOffset) || 0;
21
+ const preventDefaultStart = ((_b = (_a = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[preventDefaultAttr.name]) === null || _b === void 0 ? void 0 : _b.startOffset) || 0;
22
+ const preventDefaultEnd = ((_d = (_c = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.attrs) === null || _c === void 0 ? void 0 : _c[preventDefaultAttr.name]) === null || _d === void 0 ? void 0 : _d.endOffset) || 0;
23
23
  recorder.insertLeft(templateOffset + preventDefaultStart, `(${event}.prevent.silent)="0"`);
24
24
  recorder.remove(templateOffset + preventDefaultStart, preventDefaultEnd - preventDefaultStart);
25
25
  });
@@ -9,7 +9,7 @@ function migrateProgressSegmented({ resource, recorder, fileSystem, }) {
9
9
  const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
10
10
  const elements = (0, elements_1.findElementsByTagName)(template, 'tui-progress-segmented');
11
11
  elements.forEach(({ attrs, sourceCodeLocation }) => {
12
- var _a;
12
+ var _a, _b;
13
13
  if (!sourceCodeLocation) {
14
14
  return;
15
15
  }
@@ -18,7 +18,7 @@ function migrateProgressSegmented({ resource, recorder, fileSystem, }) {
18
18
  return;
19
19
  }
20
20
  const max = maxAttr.value;
21
- const insertTo = ((_a = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[maxAttr.name].endOffset) || 0;
21
+ const insertTo = ((_b = (_a = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[maxAttr.name]) === null || _b === void 0 ? void 0 : _b.endOffset) || 0;
22
22
  recorder.insertRight(insertTo + templateOffset, ` [segments]="${max}"`);
23
23
  });
24
24
  }
@@ -4,5 +4,4 @@ import type { TuiSchema } from '../../../ng-add/schema';
4
4
  export declare const TUI_POLYMORPHEUS_VERSION = "^4.6.4";
5
5
  export declare const TUI_DOMPURIFY_VERSION = "^4.1.2";
6
6
  export declare const TUI_EVENT_PLUGINS_VERSION = "^4.0.1";
7
- export declare const TUI_EDITOR_VERSION = "^2.5.0";
8
7
  export declare function updatePackages({ tree }: DevkitFileSystem, _: TuiSchema): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.updatePackages = exports.TUI_EDITOR_VERSION = exports.TUI_EVENT_PLUGINS_VERSION = exports.TUI_DOMPURIFY_VERSION = exports.TUI_POLYMORPHEUS_VERSION = void 0;
3
+ exports.updatePackages = exports.TUI_EVENT_PLUGINS_VERSION = exports.TUI_DOMPURIFY_VERSION = exports.TUI_POLYMORPHEUS_VERSION = void 0;
4
4
  const ng_morph_1 = require("ng-morph");
5
5
  const version_1 = require("../../../../constants/version");
6
6
  const constants_1 = require("../../../constants");
@@ -8,7 +8,6 @@ const steps_1 = require("../../steps");
8
8
  exports.TUI_POLYMORPHEUS_VERSION = '^4.6.4';
9
9
  exports.TUI_DOMPURIFY_VERSION = '^4.1.2';
10
10
  exports.TUI_EVENT_PLUGINS_VERSION = '^4.0.1';
11
- exports.TUI_EDITOR_VERSION = '^2.5.0';
12
11
  function updatePackages({ tree }, _) {
13
12
  const packagesToRemove = ['@taiga-ui/addon-tablebars', '@taiga-ui/addon-preview'];
14
13
  packagesToRemove.forEach((pkg) => {
@@ -26,10 +25,6 @@ function updatePackages({ tree }, _) {
26
25
  name: '@taiga-ui/event-plugins',
27
26
  version: exports.TUI_EVENT_PLUGINS_VERSION,
28
27
  }, tree);
29
- (0, steps_1.replacePackageName)('@tinkoff/tui-editor', {
30
- name: '@taiga-ui/editor',
31
- version: exports.TUI_EDITOR_VERSION,
32
- }, tree);
33
28
  const cdk = (0, ng_morph_1.getPackageJsonDependency)(tree, '@taiga-ui/cdk');
34
29
  if (!(0, ng_morph_1.getPackageJsonDependency)(tree, '@taiga-ui/event-plugins')) {
35
30
  (0, ng_morph_1.addPackageJsonDependency)(tree, {
@@ -4,7 +4,7 @@ exports.cleanObject = void 0;
4
4
  function checkValueIsEmpty(value) {
5
5
  // eslint-disable-next-line
6
6
  const nextValue = typeof value === 'string' ? value.trim() : value;
7
- return [undefined, null, NaN, ''].includes(nextValue);
7
+ return ['', NaN, null, undefined].includes(nextValue);
8
8
  }
9
9
  function cleanObject(object) {
10
10
  return JSON.parse(JSON.stringify(object, (_key, value) => checkValueIsEmpty(value) ? undefined : value));
@@ -13,11 +13,12 @@ function addUniqueImport(filePath, namedImport, moduleSpecifier) {
13
13
  const existingDeclaration = (0, ng_morph_1.getImports)(filePath, {
14
14
  moduleSpecifier,
15
15
  });
16
- if (existingDeclaration.length) {
17
- const modules = existingDeclaration[0]
16
+ const imports = existingDeclaration === null || existingDeclaration === void 0 ? void 0 : existingDeclaration[0];
17
+ if (imports) {
18
+ const modules = imports
18
19
  .getNamedImports()
19
20
  .map((namedImport) => namedImport.getText());
20
- (0, ng_morph_1.editImports)(existingDeclaration[0], () => ({
21
+ (0, ng_morph_1.editImports)(imports, () => ({
21
22
  namedImports: [...modules, namedImport],
22
23
  isTypeOnly: false,
23
24
  }));
@@ -60,14 +60,16 @@ function addStylesToAngularJson(options, context, taigaStyles, filter, stylesToR
60
60
  }
61
61
  if (stylesToReplace &&
62
62
  (styles === null || styles === void 0 ? void 0 : styles.filter((style) => style !== stylesToReplace.from))) {
63
- targetOptions.styles = Array.from(new Set([
63
+ const orderList = [
64
64
  ...taigaStyles,
65
65
  ...stylesToReplace.to,
66
66
  ...styles.filter((style) => style !== stylesToReplace.from),
67
- ]));
67
+ ];
68
+ targetOptions.styles = Array.from(new Set(orderList));
68
69
  }
69
70
  else {
70
- targetOptions.styles = Array.from(new Set([...taigaStyles, ...(styles || [])]));
71
+ const orderList = [...taigaStyles, ...(styles || [])];
72
+ targetOptions.styles = Array.from(new Set(orderList));
71
73
  }
72
74
  if (tree && stylesToReplace) {
73
75
  (0, ng_morph_1.addPackageJsonDependency)(tree, {
@@ -7,7 +7,7 @@ function getComponentFromIdentifier(identifier) {
7
7
  const rootImportDeclaration = (0, ng_morph_1.getImports)(identifier.getSourceFile().getFilePath(), {
8
8
  namedImports: [identifier.getText()],
9
9
  })[0];
10
- const rootComponentPath = ((_a = rootImportDeclaration.getModuleSpecifierSourceFile()) === null || _a === void 0 ? void 0 : _a.getFilePath()) || '';
10
+ const rootComponentPath = ((_a = rootImportDeclaration === null || rootImportDeclaration === void 0 ? void 0 : rootImportDeclaration.getModuleSpecifierSourceFile()) === null || _a === void 0 ? void 0 : _a.getFilePath()) || '';
11
11
  return (0, ng_morph_1.getNgComponents)(rootComponentPath, { name: identifier.getText() })[0];
12
12
  }
13
13
  exports.getComponentFromIdentifier = getComponentFromIdentifier;
@@ -7,8 +7,8 @@ const ng_morph_1 = require("ng-morph");
7
7
  function decoratorToTemplateResource(decorator) {
8
8
  var _a, _b, _c;
9
9
  const [metadata] = decorator.getArguments();
10
- const templateUrl = metadata.getProperty('templateUrl');
11
- const template = metadata.getProperty('template');
10
+ const templateUrl = metadata === null || metadata === void 0 ? void 0 : metadata.getProperty('templateUrl');
11
+ const template = metadata === null || metadata === void 0 ? void 0 : metadata.getProperty('template');
12
12
  const componentPath = decorator.getSourceFile().getFilePath();
13
13
  if (templateUrl) {
14
14
  const templatePath = path.parse(((_a = templateUrl === null || templateUrl === void 0 ? void 0 : templateUrl.getInitializer()) === null || _a === void 0 ? void 0 : _a.getText().replaceAll(/['"`]/g, '')) || '');