@taiga-ui/cdk 2.51.0 → 2.51.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taiga-ui/cdk",
3
- "version": "2.51.0",
3
+ "version": "2.51.1",
4
4
  "description": "Base library for creating Angular components and applications using Taiga UI principles regarding of actual visual appearance",
5
5
  "keywords": [
6
6
  "angular",
@@ -51,6 +51,7 @@ exports.ATTRS_TO_REPLACE = [
51
51
  from: {
52
52
  attrName: '[quantum]',
53
53
  withAttrsNames: ['tuiSlider'],
54
+ withTagNames: ['tui-slider'],
54
55
  },
55
56
  to: {
56
57
  attrName: '[step]',
@@ -15,23 +15,52 @@ const remove_module_1 = require("./steps/remove-module");
15
15
  const miscellaneous_1 = require("./steps/miscellaneous");
16
16
  const replace_functions_1 = require("./steps/replace-functions");
17
17
  const migrate_progress_1 = require("./steps/migrate-progress");
18
+ const colored_log_1 = require("../utils/colored-log");
18
19
  function updateToV3(_) {
19
20
  return (tree, context) => tslib_1.__awaiter(this, void 0, void 0, function* () {
20
- context.logger.info(`taiga packages will be updated to ${versions_1.TAIGA_VERSION}`);
21
- ng_morph_1.setActiveProject(ng_morph_1.createProject(tree, '/', '**/**'));
21
+ console.info('\x1b[35m', `taiga packages will be updated to ${versions_1.TAIGA_VERSION}`);
22
+ const fileSystem = getFileSystem(tree);
23
+ colored_log_1.infoLog('replacing deep imports...');
22
24
  replace_deep_import_1.replaceDeepImports();
25
+ colored_log_1.successLog('deep imports replaced');
26
+ colored_log_1.infoLog('replacing enums imports...');
23
27
  replace_enums_1.replaceEnums();
28
+ colored_log_1.successLog('enums replaced');
29
+ colored_log_1.infoLog('renaming types...');
24
30
  rename_types_1.renameTypes();
31
+ colored_log_1.successLog('types renamed');
32
+ colored_log_1.infoLog('replacing consts...');
25
33
  replace_const_1.replaceConsts();
34
+ colored_log_1.successLog('constants replaced');
35
+ colored_log_1.infoLog('replacing services...');
26
36
  replace_services_1.replaceServices();
37
+ colored_log_1.successLog('services replaced');
27
38
  show_warnings_1.showWarnings(context);
28
- migrate_templates_1.migrateTemplates(tree);
29
- migrate_sliders_1.migrateSliders(tree);
30
- migrate_progress_1.migrateProgress(tree);
39
+ colored_log_1.infoLog('migrating templates...');
40
+ migrate_templates_1.migrateTemplates(fileSystem);
41
+ colored_log_1.successLog('templates migrated');
42
+ fileSystem.commitEdits();
43
+ ng_morph_1.saveActiveProject();
44
+ const updatedFileSystem = getFileSystem(tree);
45
+ colored_log_1.infoLog('migrating sliders...');
46
+ migrate_sliders_1.migrateSliders(updatedFileSystem);
47
+ colored_log_1.successLog('sliders migrated');
48
+ colored_log_1.infoLog('migrating progress bars');
49
+ migrate_progress_1.migrateProgress(updatedFileSystem);
50
+ colored_log_1.successLog('progress bars migrated');
51
+ colored_log_1.infoLog('removing modules...');
31
52
  remove_module_1.removeModules();
53
+ colored_log_1.successLog('modules removed');
54
+ colored_log_1.infoLog('miscellaneous migrating...');
32
55
  replace_functions_1.replaceFunctions();
33
56
  miscellaneous_1.miscellaneousMigrations();
57
+ colored_log_1.successLog('miscellaneous migrated');
34
58
  ng_morph_1.saveActiveProject();
35
59
  });
36
60
  }
37
61
  exports.updateToV3 = updateToV3;
62
+ function getFileSystem(tree) {
63
+ const project = ng_morph_1.createProject(tree, '/', '**/**.{html,ts}');
64
+ ng_morph_1.setActiveProject(project);
65
+ return project.getFileSystem().fs;
66
+ }
@@ -1,3 +1,3 @@
1
- import { Tree } from '@angular-devkit/schematics';
1
+ import { DevkitFileSystem } from 'ng-morph/project/classes/devkit-file-system';
2
2
  export declare const DEPRECATED_PROGRESS_PIPES_REG: RegExp;
3
- export declare function migrateProgress(tree: Tree): void;
3
+ export declare function migrateProgress(fileSystem: DevkitFileSystem): void;
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ng_morph_1 = require("ng-morph");
4
- const devkit_file_system_1 = require("ng-morph/project/classes/devkit-file-system");
5
4
  const get_component_templates_1 = require("../../utils/templates/get-component-templates");
6
5
  const elements_1 = require("../../utils/templates/elements");
7
6
  const template_resource_1 = require("../../utils/templates/template-resource");
8
7
  exports.DEPRECATED_PROGRESS_PIPES_REG = /\s*\|\s*tuiProgressColorSegments(Async\s*\|\s*async)?/gi;
9
8
  const PROPERTY_FOR_DEPRECATED_PIPES = '[color]';
10
- function migrateProgress(tree) {
11
- const fileSystem = new devkit_file_system_1.DevkitFileSystem(tree);
9
+ function migrateProgress(fileSystem) {
12
10
  const templateResources = get_component_templates_1.getComponentTemplates('**/**');
13
11
  for (const templateResource of templateResources) {
14
12
  replaceProgressColorSegmentsPipe(templateResource, fileSystem);
@@ -1,2 +1,2 @@
1
- import { Tree } from '@angular-devkit/schematics';
2
- export declare function migrateSliders(tree: Tree): void;
1
+ import { DevkitFileSystem } from 'ng-morph/project/classes/devkit-file-system';
2
+ export declare function migrateSliders(fileSystem: DevkitFileSystem): void;
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const migrate_input_slider_1 = require("./migrate-input-slider");
4
4
  const migrate_input_range_1 = require("./migrate-input-range");
5
- function migrateSliders(tree) {
6
- migrate_input_slider_1.migrateInputSlider(tree);
7
- migrate_input_range_1.migrateInputRange(tree);
5
+ function migrateSliders(fileSystem) {
6
+ migrate_input_slider_1.migrateInputSlider(fileSystem);
7
+ migrate_input_range_1.migrateInputRange(fileSystem);
8
8
  }
9
9
  exports.migrateSliders = migrateSliders;
@@ -1,2 +1,2 @@
1
- import { Tree } from '@angular-devkit/schematics';
2
- export declare function migrateInputRange(tree: Tree): void;
1
+ import { DevkitFileSystem } from 'ng-morph/project/classes/devkit-file-system';
2
+ export declare function migrateInputRange(fileSystem: DevkitFileSystem): void;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const devkit_file_system_1 = require("ng-morph/project/classes/devkit-file-system");
4
3
  const get_component_templates_1 = require("../../../utils/templates/get-component-templates");
5
4
  const ng_component_input_manipulations_1 = require("../../../utils/templates/ng-component-input-manipulations");
6
5
  const ng_morph_1 = require("ng-morph");
@@ -8,8 +7,7 @@ const ng_component_1 = require("../../../utils/angular/ng-component");
8
7
  const add_unique_import_1 = require("../../../utils/add-unique-import");
9
8
  const MIN_LABELS_MIGRATION_METHOD_NAME = 'tuiMigrationInputRangeMinLabel';
10
9
  const MAX_LABELS_MIGRATION_METHOD_NAME = 'tuiMigrationInputRangeMaxLabel';
11
- function migrateInputRange(tree) {
12
- const fileSystem = new devkit_file_system_1.DevkitFileSystem(tree);
10
+ function migrateInputRange(fileSystem) {
13
11
  const templateResources = get_component_templates_1.getComponentTemplates('**/**');
14
12
  const COMPONENTS_WITH_MIN_LABELS = new Set();
15
13
  const COMPONENTS_WITH_MAX_LABELS = new Set();
@@ -1,2 +1,2 @@
1
- import { Tree } from '@angular-devkit/schematics';
2
- export declare function migrateInputSlider(tree: Tree): void;
1
+ import { DevkitFileSystem } from 'ng-morph/project/classes/devkit-file-system';
2
+ export declare function migrateInputSlider(fileSystem: DevkitFileSystem): void;
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ng_morph_1 = require("ng-morph");
4
- const devkit_file_system_1 = require("ng-morph/project/classes/devkit-file-system");
5
4
  const ng_component_input_manipulations_1 = require("../../../utils/templates/ng-component-input-manipulations");
6
5
  const ng_component_1 = require("../../../utils/angular/ng-component");
7
6
  const add_unique_import_1 = require("../../../utils/add-unique-import");
8
7
  const get_component_templates_1 = require("../../../utils/templates/get-component-templates");
9
8
  const elements_1 = require("../../../utils/templates/elements");
10
- function migrateInputSlider(tree) {
11
- const fileSystem = new devkit_file_system_1.DevkitFileSystem(tree);
9
+ function migrateInputSlider(fileSystem) {
12
10
  const templateResources = get_component_templates_1.getComponentTemplates('**/**');
13
11
  const COMPONENTS_WITH_MIN_MAX_LABELS = new Set();
14
12
  for (const templateResource of templateResources) {
@@ -1,2 +1,2 @@
1
- import { Tree } from '@angular-devkit/schematics';
2
- export declare function migrateTemplates(tree: Tree): void;
1
+ import { DevkitFileSystem } from 'ng-morph/project/classes/devkit-file-system';
2
+ export declare function migrateTemplates(fileSystem: DevkitFileSystem): void;
@@ -3,15 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const get_component_templates_1 = require("../../utils/templates/get-component-templates");
4
4
  const templates_1 = require("../constants/templates");
5
5
  const elements_1 = require("../../utils/templates/elements");
6
- const devkit_file_system_1 = require("ng-morph/project/classes/devkit-file-system");
7
6
  const ng_component_input_manipulations_1 = require("../../utils/templates/ng-component-input-manipulations");
8
7
  const template_resource_1 = require("../../utils/templates/template-resource");
9
8
  const ng_morph_1 = require("ng-morph");
9
+ const ng_component_1 = require("../../utils/angular/ng-component");
10
+ const add_unique_import_1 = require("../../utils/add-unique-import");
10
11
  const START_TAG_OFFSET = 1;
11
12
  const END_TAG_OFFSET = 2;
12
- function migrateTemplates(tree) {
13
- const fileSystem = new devkit_file_system_1.DevkitFileSystem(tree);
14
- const componentWithTemplatesPaths = get_component_templates_1.getComponentTemplates('**/**').map(({ componentPath }) => componentPath);
13
+ function migrateTemplates(fileSystem) {
14
+ const componentWithTemplatesPaths = get_component_templates_1.getComponentTemplates('**/**');
15
15
  const actions = [
16
16
  replaceTags,
17
17
  replaceAttrs,
@@ -19,28 +19,17 @@ function migrateTemplates(tree) {
19
19
  replaceBreadcrumbs,
20
20
  replaceFieldError,
21
21
  addHTMLCommentTags,
22
+ addEditorProviders,
22
23
  ];
23
- actions.forEach(action => {
24
- componentWithTemplatesPaths.forEach(componentPath => {
25
- // get updated version of template after the previous action
26
- const [resource] = get_component_templates_1.getComponentTemplates(componentPath);
27
- const path = fileSystem.resolve(template_resource_1.getPathFromTemplateResource(resource));
28
- const recorder = fileSystem.edit(path);
24
+ componentWithTemplatesPaths.forEach(resource => {
25
+ const path = fileSystem.resolve(template_resource_1.getPathFromTemplateResource(resource));
26
+ const recorder = fileSystem.edit(path);
27
+ actions.forEach(action => {
29
28
  action({ resource, fileSystem, recorder });
30
29
  });
31
- save(fileSystem);
32
30
  });
33
31
  }
34
32
  exports.migrateTemplates = migrateTemplates;
35
- /**
36
- * We should update virtual file tree
37
- * otherwise all following ng-morph commands will overwrite all previous template manipulations
38
- * */
39
- function save(fileSystem) {
40
- fileSystem.commitEdits();
41
- ng_morph_1.saveActiveProject();
42
- ng_morph_1.setActiveProject(ng_morph_1.createProject(fileSystem.tree, '/', '**/**'));
43
- }
44
33
  function replaceAttrsByDirective({ resource, fileSystem, }) {
45
34
  templates_1.ATTR_TO_DIRECTIVE.forEach(({ componentSelector, directiveModule, directive, inputProperty }) => {
46
35
  ng_component_input_manipulations_1.replaceInputPropertyByDirective({
@@ -62,7 +51,7 @@ function replaceAttrs({ resource, recorder, fileSystem, }) {
62
51
  ...elements_1.findAttributeOnElementWithAttrs(template, from.attrName, from.withAttrsNames || []),
63
52
  ];
64
53
  offsets.forEach(offset => {
65
- recorder.remove(offset + templateOffset, from.attrName.length + (to.attrName.length ? 0 : 1));
54
+ recorder.remove(offset + templateOffset, from.attrName.length);
66
55
  recorder.insertRight(offset + templateOffset, to.attrName);
67
56
  });
68
57
  });
@@ -147,3 +136,17 @@ function replaceTag(recorder, sourceCodeLocation, from, to, templateOffset = 0,
147
136
  recorder.remove(startTagOffset + templateOffset + START_TAG_OFFSET, from.length);
148
137
  recorder.insertRight(startTagOffset + templateOffset + START_TAG_OFFSET, `${to} ${addAttributes.join(' ')}`);
149
138
  }
139
+ function addEditorProviders({ resource, fileSystem, }) {
140
+ const template = template_resource_1.getTemplateFromTemplateResource(resource, fileSystem);
141
+ const elements = elements_1.findElementsByTagName(template, 'tui-editor').filter(element => !elements_1.hasElementAttribute(element, 'new'));
142
+ if (elements.length) {
143
+ const componentPath = resource.componentPath;
144
+ const componentClass = ng_component_1.getNgComponents(componentPath);
145
+ ng_morph_1.addProviderToComponent(componentClass[0], `{
146
+ provide: TUI_EDITOR_EXTENSIONS,
147
+ useValue: defaultEditorExtensions
148
+ }`, { unique: true });
149
+ add_unique_import_1.addUniqueImport(componentPath, 'TUI_EDITOR_EXTENSIONS', '@taiga-ui/addon-editor');
150
+ add_unique_import_1.addUniqueImport(componentPath, 'defaultEditorExtensions', '@taiga-ui/addon-editor');
151
+ }
152
+ }
@@ -6,7 +6,10 @@ const ng_morph_1 = require("ng-morph");
6
6
  const import_manipulations_1 = require("../../utils/import-manipulations");
7
7
  const add_unique_import_1 = require("../../utils/add-unique-import");
8
8
  function replaceServices() {
9
- services_1.SERVICES_TO_REPLACE.forEach(service => replaceService(service));
9
+ services_1.SERVICES_TO_REPLACE.forEach(service => {
10
+ console.info('\x1b[34m', `replacing ${service.from.name}`);
11
+ replaceService(service);
12
+ });
10
13
  }
11
14
  exports.replaceServices = replaceServices;
12
15
  function replaceService({ from, to, replaceMethods }) {
@@ -0,0 +1,2 @@
1
+ export declare function successLog(message: string): void;
2
+ export declare function infoLog(message: string): void;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function successLog(message) {
4
+ console.info('\x1B[32m%s\x1B[0m', message, '\u2713');
5
+ }
6
+ exports.successLog = successLog;
7
+ function infoLog(message) {
8
+ console.info('\x1B[34m%s\x1B[0m', message);
9
+ }
10
+ exports.infoLog = infoLog;