@taiga-ui/cdk 2.37.0 → 2.39.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 (52) hide show
  1. package/abstract/interactive.d.ts +8 -0
  2. package/abstract/taiga-ui-cdk-abstract.metadata.json +1 -1
  3. package/bundles/taiga-ui-cdk-abstract.umd.js +9 -0
  4. package/bundles/taiga-ui-cdk-abstract.umd.js.map +1 -1
  5. package/bundles/taiga-ui-cdk-abstract.umd.min.js.map +1 -1
  6. package/bundles/taiga-ui-cdk-components-dialog-host.umd.js +5 -9
  7. package/bundles/taiga-ui-cdk-components-dialog-host.umd.js.map +1 -1
  8. package/bundles/taiga-ui-cdk-components-dialog-host.umd.min.js +2 -2
  9. package/bundles/taiga-ui-cdk-components-dialog-host.umd.min.js.map +1 -1
  10. package/components/dialog-host/taiga-ui-cdk-components-dialog-host.metadata.json +1 -1
  11. package/esm2015/abstract/interactive.js +10 -1
  12. package/esm2015/components/dialog-host/dialog-host.component.js +4 -9
  13. package/esm5/abstract/interactive.js +10 -1
  14. package/esm5/components/dialog-host/dialog-host.component.js +4 -9
  15. package/fesm2015/taiga-ui-cdk-abstract.js +9 -0
  16. package/fesm2015/taiga-ui-cdk-abstract.js.map +1 -1
  17. package/fesm2015/taiga-ui-cdk-components-dialog-host.js +3 -8
  18. package/fesm2015/taiga-ui-cdk-components-dialog-host.js.map +1 -1
  19. package/fesm5/taiga-ui-cdk-abstract.js +9 -0
  20. package/fesm5/taiga-ui-cdk-abstract.js.map +1 -1
  21. package/fesm5/taiga-ui-cdk-components-dialog-host.js +3 -8
  22. package/fesm5/taiga-ui-cdk-components-dialog-host.js.map +1 -1
  23. package/package.json +20 -1
  24. package/schematics/collection.json +16 -0
  25. package/schematics/migration.json +10 -0
  26. package/schematics/ng-add/constants/modules.d.ts +8 -0
  27. package/schematics/ng-add/constants/modules.js +34 -0
  28. package/schematics/ng-add/constants/packages.d.ts +2 -0
  29. package/schematics/ng-add/constants/packages.js +13 -0
  30. package/schematics/ng-add/constants/versions.d.ts +4 -0
  31. package/schematics/ng-add/constants/versions.js +7 -0
  32. package/schematics/ng-add/index.d.ts +3 -0
  33. package/schematics/ng-add/index.js +66 -0
  34. package/schematics/ng-add/schema.d.ts +7 -0
  35. package/schematics/ng-add/schema.js +2 -0
  36. package/schematics/ng-add/schema.json +86 -0
  37. package/schematics/ng-add/setup-project.d.ts +3 -0
  38. package/schematics/ng-add/setup-project.js +16 -0
  39. package/schematics/ng-add/steps/add-taiga-icons.d.ts +5 -0
  40. package/schematics/ng-add/steps/add-taiga-icons.js +40 -0
  41. package/schematics/ng-add/steps/add-taiga-modules.d.ts +3 -0
  42. package/schematics/ng-add/steps/add-taiga-modules.js +76 -0
  43. package/schematics/ng-add/steps/add-taiga-styles.d.ts +5 -0
  44. package/schematics/ng-add/steps/add-taiga-styles.js +38 -0
  45. package/schematics/ng-add/steps/wrap-with-tui-root.d.ts +3 -0
  46. package/schematics/ng-add/steps/wrap-with-tui-root.js +82 -0
  47. package/schematics/ng-update/index.d.ts +3 -0
  48. package/schematics/ng-update/index.js +18 -0
  49. package/schematics/utils/get-project-target-options.d.ts +2 -0
  50. package/schematics/utils/get-project-target-options.js +12 -0
  51. package/schematics/utils/get-project.d.ts +3 -0
  52. package/schematics/utils/get-project.js +12 -0
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schematics_1 = require("@angular-devkit/schematics");
4
+ const add_taiga_icons_1 = require("./steps/add-taiga-icons");
5
+ const add_taiga_modules_1 = require("./steps/add-taiga-modules");
6
+ const add_taiga_styles_1 = require("./steps/add-taiga-styles");
7
+ const wrap_with_tui_root_1 = require("./steps/wrap-with-tui-root");
8
+ function ngAddSetupProject(options) {
9
+ return schematics_1.chain([
10
+ add_taiga_styles_1.addTaigaStyles(options),
11
+ add_taiga_modules_1.addTaigaModules(options),
12
+ add_taiga_icons_1.addTaigaIcons(options),
13
+ wrap_with_tui_root_1.wrapWithTuiRootComponent(options),
14
+ ]);
15
+ }
16
+ exports.default = ngAddSetupProject;
@@ -0,0 +1,5 @@
1
+ import { workspaces } from '@angular-devkit/core';
2
+ import { Rule } from '@angular-devkit/schematics';
3
+ import { Schema } from '../schema';
4
+ export declare function addTaigaIcons(options: Schema): Rule;
5
+ export declare function addTaigaStylesToAngularJson(workspace: workspaces.WorkspaceDefinition, project: workspaces.ProjectDefinition): Rule;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const workspace_1 = require("@schematics/angular/utility/workspace");
13
+ const workspace_2 = require("@schematics/angular/utility/workspace");
14
+ const get_project_1 = require("../../utils/get-project");
15
+ const get_project_target_options_1 = require("../../utils/get-project-target-options");
16
+ const ICON_ASSETS = {
17
+ glob: '**/*',
18
+ input: 'node_modules/@taiga-ui/icons/src',
19
+ output: 'assets/taiga-ui/icons',
20
+ };
21
+ function addTaigaIcons(options) {
22
+ return (tree) => __awaiter(this, void 0, void 0, function* () {
23
+ const workspace = yield workspace_2.getWorkspace(tree);
24
+ const project = get_project_1.getProject(options, workspace);
25
+ return addTaigaStylesToAngularJson(workspace, project);
26
+ });
27
+ }
28
+ exports.addTaigaIcons = addTaigaIcons;
29
+ function addTaigaStylesToAngularJson(workspace, project) {
30
+ const targetOptions = get_project_target_options_1.getProjectTargetOptions(project, 'build');
31
+ const assets = targetOptions.assets;
32
+ if (!assets) {
33
+ targetOptions.assets = [ICON_ASSETS];
34
+ }
35
+ else {
36
+ targetOptions.assets = [...assets, ICON_ASSETS];
37
+ }
38
+ return workspace_1.updateWorkspace(workspace);
39
+ }
40
+ exports.addTaigaStylesToAngularJson = addTaigaStylesToAngularJson;
@@ -0,0 +1,3 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ import { Schema } from '../schema';
3
+ export declare function addTaigaModules(options: Schema): Rule;
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const workspace_1 = require("@schematics/angular/utility/workspace");
13
+ const ng_morph_1 = require("ng-morph");
14
+ const get_project_1 = require("../../utils/get-project");
15
+ const get_project_target_options_1 = require("../../utils/get-project-target-options");
16
+ const modules_1 = require("../constants/modules");
17
+ function addTaigaModules(options) {
18
+ return (tree, context) => __awaiter(this, void 0, void 0, function* () {
19
+ const workspace = yield workspace_1.getWorkspace(tree);
20
+ const project = get_project_1.getProject(options, workspace);
21
+ const buildOptions = get_project_target_options_1.getProjectTargetOptions(project, 'build');
22
+ ng_morph_1.setActiveProject(ng_morph_1.createProject(tree, '/', ['**/*.ts', '**/*.json']));
23
+ const mainModule = ng_morph_1.getMainModule(buildOptions.main);
24
+ addTuiModules(mainModule, options, context);
25
+ addTuiProviders(mainModule, options);
26
+ ng_morph_1.saveActiveProject();
27
+ });
28
+ }
29
+ exports.addTaigaModules = addTaigaModules;
30
+ function addTuiModules(mainModule, options, context) {
31
+ const modules = [
32
+ ...modules_1.MAIN_MODULES,
33
+ ...(options.addDialogsModule ? modules_1.DIALOG_MODULES : []),
34
+ ...(options.addNotificationsModule ? modules_1.NOTIFICATION_MODULES : []),
35
+ ];
36
+ const mainModulePath = mainModule.getSourceFile().getFilePath();
37
+ modules.forEach(module => {
38
+ ng_morph_1.addImportToNgModule(mainModule, module.name, { unique: true });
39
+ addUniqueImport(mainModulePath, module.name, module.packageName);
40
+ });
41
+ context.logger.info(`${modules.map(module => module.name)} was added to ${mainModulePath}`);
42
+ }
43
+ function addTuiProviders(mainModule, options) {
44
+ if (!options.addSanitizer) {
45
+ return;
46
+ }
47
+ ng_morph_1.addProviderToNgModule(mainModule, '{provide: TUI_SANITIZER, useClass: NgDompurifySanitizer}', { unique: true });
48
+ modules_1.SANITIZER_MODULES.forEach(module => {
49
+ addUniqueImport(mainModule.getSourceFile().getFilePath(), module.name, module.packageName);
50
+ });
51
+ }
52
+ function addUniqueImport(filePath, namedImport, packageName) {
53
+ const existingNamedImport = ng_morph_1.getImports(filePath, {
54
+ namedImports: namedImport,
55
+ moduleSpecifier: packageName,
56
+ });
57
+ if (existingNamedImport.length) {
58
+ return;
59
+ }
60
+ const existingDeclaration = ng_morph_1.getImports(filePath, {
61
+ moduleSpecifier: packageName,
62
+ });
63
+ if (existingDeclaration.length) {
64
+ const modules = existingDeclaration[0]
65
+ .getNamedImports()
66
+ .map(namedImport => namedImport.getText());
67
+ ng_morph_1.editImports(existingDeclaration, () => ({
68
+ namedImports: [...modules, namedImport],
69
+ }));
70
+ return;
71
+ }
72
+ ng_morph_1.addImports(filePath, {
73
+ moduleSpecifier: packageName,
74
+ namedImports: [namedImport],
75
+ });
76
+ }
@@ -0,0 +1,5 @@
1
+ import { workspaces } from '@angular-devkit/core';
2
+ import { Rule } from '@angular-devkit/schematics';
3
+ import { Schema } from '../schema';
4
+ export declare function addTaigaStyles(options: Schema): Rule;
5
+ export declare function addTaigaStylesToAngularJson(workspace: workspaces.WorkspaceDefinition, project: workspaces.ProjectDefinition): Rule;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const workspace_1 = require("@schematics/angular/utility/workspace");
13
+ const workspace_2 = require("@schematics/angular/utility/workspace");
14
+ const get_project_1 = require("../../utils/get-project");
15
+ const get_project_target_options_1 = require("../../utils/get-project-target-options");
16
+ const TAIGA_GLOBAL_STYLE = 'node_modules/@taiga-ui/core/styles/taiga-ui-global.less';
17
+ const TAIGA_THEME_STYLE = 'node_modules/@taiga-ui/core/styles/taiga-ui-theme.less';
18
+ function addTaigaStyles(options) {
19
+ return (tree) => __awaiter(this, void 0, void 0, function* () {
20
+ const workspace = yield workspace_2.getWorkspace(tree);
21
+ const project = get_project_1.getProject(options, workspace);
22
+ return addTaigaStylesToAngularJson(workspace, project);
23
+ });
24
+ }
25
+ exports.addTaigaStyles = addTaigaStyles;
26
+ function addTaigaStylesToAngularJson(workspace, project) {
27
+ const targetOptions = get_project_target_options_1.getProjectTargetOptions(project, 'build');
28
+ const styles = targetOptions.styles;
29
+ const taigaStyles = [TAIGA_GLOBAL_STYLE, TAIGA_THEME_STYLE];
30
+ if (!styles) {
31
+ targetOptions.styles = taigaStyles;
32
+ }
33
+ else {
34
+ targetOptions.styles = Array.from(new Set([...taigaStyles, ...styles]));
35
+ }
36
+ return workspace_1.updateWorkspace(workspace);
37
+ }
38
+ exports.addTaigaStylesToAngularJson = addTaigaStylesToAngularJson;
@@ -0,0 +1,3 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ import { Schema } from '../schema';
3
+ export declare function wrapWithTuiRootComponent(options: Schema): Rule;
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const workspace_1 = require("@schematics/angular/utility/workspace");
13
+ const ng_morph_1 = require("ng-morph");
14
+ const get_project_1 = require("../../utils/get-project");
15
+ const get_project_target_options_1 = require("../../utils/get-project-target-options");
16
+ function wrapWithTuiRootComponent(options) {
17
+ return (tree, context) => __awaiter(this, void 0, void 0, function* () {
18
+ const workspace = yield workspace_1.getWorkspace(tree);
19
+ const project = get_project_1.getProject(options, workspace);
20
+ const buildOptions = get_project_target_options_1.getProjectTargetOptions(project, 'build');
21
+ const appTemplatePath = getAppTemplatePath(tree, buildOptions.main);
22
+ if (!appTemplatePath) {
23
+ context.logger.error('Could not find the default main template file for this project.');
24
+ context.logger.info('Consider manually wrapping content of your app with tui-root');
25
+ context.logger.info('More information at https://taiga-ui.dev/getting-started');
26
+ return;
27
+ }
28
+ addTuiRootComponent(appTemplatePath, context, tree);
29
+ });
30
+ }
31
+ exports.wrapWithTuiRootComponent = wrapWithTuiRootComponent;
32
+ function addTuiRootComponent(filePath, context, tree) {
33
+ const buffer = tree.read(filePath);
34
+ if (!buffer) {
35
+ context.logger.error(`Could not read the default template file within the project ${filePath}`);
36
+ context.logger.info('Consider manually wrapping content of your app with tui-root');
37
+ return;
38
+ }
39
+ const htmlContent = buffer.toString();
40
+ const openTag = '<tui-root>' + '\n';
41
+ const closeTag = '\n' + '</tui-root>';
42
+ if (htmlContent.includes(openTag)) {
43
+ return;
44
+ }
45
+ const recorder = tree.beginUpdate(filePath);
46
+ recorder.insertLeft(0, openTag);
47
+ recorder.insertLeft(htmlContent.length, closeTag);
48
+ tree.commitUpdate(recorder);
49
+ context.logger.info(`Content of the app was wrapped with tui-root component in ${filePath}`);
50
+ }
51
+ function getAppTemplatePath(tree, mainPath) {
52
+ ng_morph_1.setActiveProject(ng_morph_1.createProject(tree, '/', ['**/*.ts', '**/*.json']));
53
+ const mainModule = ng_morph_1.getMainModule(mainPath);
54
+ const mainInitializer = getInitializer(mainModule, 'NgModule', 'declarations');
55
+ if (!ng_morph_1.Node.isArrayLiteralExpression(mainInitializer)) {
56
+ return;
57
+ }
58
+ const appIdentifier = mainInitializer.getElements()[0];
59
+ const appComponent = appIdentifier.getDefinitionNodes()[0];
60
+ const templateInitializer = getInitializer(appComponent, 'Component', 'templateUrl');
61
+ const appComponentPath = appComponent.getSourceFile().getFilePath().split('/');
62
+ const templateUrlPath = `${appComponentPath
63
+ .splice(0, appComponentPath.length - 1)
64
+ .join('/')}/${templateInitializer === null || templateInitializer === void 0 ? void 0 : templateInitializer.getText().replace(/['"]/g, '')}`;
65
+ ng_morph_1.saveActiveProject();
66
+ return templateUrlPath;
67
+ }
68
+ function getInitializer(classDeclaration, decoratorName, propertyName) {
69
+ const decorator = classDeclaration.getDecorator(decoratorName);
70
+ if (!decorator) {
71
+ return;
72
+ }
73
+ const [metadata] = decorator.getArguments();
74
+ if (!ng_morph_1.Node.isObjectLiteralExpression(metadata)) {
75
+ return;
76
+ }
77
+ const property = metadata.getProperty(propertyName);
78
+ if (!ng_morph_1.Node.isPropertyAssignment(property)) {
79
+ return;
80
+ }
81
+ return property.getInitializer();
82
+ }
@@ -0,0 +1,3 @@
1
+ import { SchematicContext } from '@angular-devkit/schematics';
2
+ import { Schema } from '../ng-add/schema';
3
+ export declare function updateToV3(_: Schema): (_: any, context: SchematicContext) => Promise<void>;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const versions_1 = require("../ng-add/constants/versions");
13
+ function updateToV3(_) {
14
+ return (_, context) => __awaiter(this, void 0, void 0, function* () {
15
+ context.logger.info(`taiga packages will be updated to ${versions_1.TAIGA_VERSION}`);
16
+ });
17
+ }
18
+ exports.updateToV3 = updateToV3;
@@ -0,0 +1,2 @@
1
+ import { JsonArray, JsonObject, workspaces } from '@angular-devkit/core';
2
+ export declare function getProjectTargetOptions(project: workspaces.ProjectDefinition, buildTarget: string): Record<string, string | number | boolean | JsonArray | JsonObject | undefined | null>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schematics_1 = require("@angular-devkit/schematics");
4
+ function getProjectTargetOptions(project, buildTarget) {
5
+ var _a;
6
+ const buildTargetObject = (_a = project.targets) === null || _a === void 0 ? void 0 : _a.get(buildTarget);
7
+ if (buildTargetObject && buildTargetObject.options) {
8
+ return buildTargetObject.options;
9
+ }
10
+ throw new schematics_1.SchematicsException(`Cannot determine project target configuration for: ${buildTarget}.`);
11
+ }
12
+ exports.getProjectTargetOptions = getProjectTargetOptions;
@@ -0,0 +1,3 @@
1
+ import { workspaces } from '@angular-devkit/core';
2
+ import { Schema } from '../ng-add/schema';
3
+ export declare function getProject(options: Schema, workspace: workspaces.WorkspaceDefinition): workspaces.ProjectDefinition;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schematics_1 = require("@angular-devkit/schematics");
4
+ function getProject(options, workspace) {
5
+ const projectName = options.project || workspace.extensions.defaultProject.toString();
6
+ const project = workspace.projects.get(projectName);
7
+ if (!project) {
8
+ throw new schematics_1.SchematicsException(`Unable to find project '${projectName}' in the workspace`);
9
+ }
10
+ return project;
11
+ }
12
+ exports.getProject = getProject;