@taiga-ui/cdk 4.0.0-rc.4 → 4.0.0-rc.6

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 (44) hide show
  1. package/classes/index.d.ts +0 -1
  2. package/constants/version.d.ts +1 -1
  3. package/constants/version.js +1 -1
  4. package/esm2022/classes/index.mjs +1 -2
  5. package/esm2022/constants/version.mjs +2 -2
  6. package/esm2022/tokens/environment.mjs +9 -1
  7. package/fesm2022/taiga-ui-cdk-classes.mjs +1 -15
  8. package/fesm2022/taiga-ui-cdk-classes.mjs.map +1 -1
  9. package/fesm2022/taiga-ui-cdk-constants.mjs +1 -1
  10. package/fesm2022/taiga-ui-cdk-constants.mjs.map +1 -1
  11. package/fesm2022/taiga-ui-cdk-tokens.mjs +9 -2
  12. package/fesm2022/taiga-ui-cdk-tokens.mjs.map +1 -1
  13. package/package.json +5 -5
  14. package/schematics/ng-update/interfaces/replacement-identifier.d.ts +2 -1
  15. package/schematics/ng-update/steps/replace-identifier.js +12 -2
  16. package/schematics/ng-update/steps/replace-package-name.js +4 -5
  17. package/schematics/ng-update/v4/index.js +6 -1
  18. package/schematics/ng-update/v4/migrate-icons/rename-icons.js +8 -0
  19. package/schematics/ng-update/v4/steps/constants/attrs-to-replace.js +30 -2
  20. package/schematics/ng-update/v4/steps/constants/identifiers-to-replace.js +182 -48
  21. package/schematics/ng-update/v4/steps/constants/index.d.ts +1 -0
  22. package/schematics/ng-update/v4/steps/constants/index.js +1 -0
  23. package/schematics/ng-update/v4/steps/constants/modules-to-remove.js +8 -0
  24. package/schematics/ng-update/v4/steps/constants/modules-to-replace.d.ts +7 -6
  25. package/schematics/ng-update/v4/steps/constants/modules-to-replace.js +1 -0
  26. package/schematics/ng-update/v4/steps/constants/services.d.ts +2 -0
  27. package/schematics/ng-update/v4/steps/constants/services.js +15 -0
  28. package/schematics/ng-update/v4/steps/migrate-root.d.ts +3 -0
  29. package/schematics/ng-update/v4/steps/migrate-root.js +56 -0
  30. package/schematics/ng-update/v4/steps/migrate-styles.js +1 -0
  31. package/schematics/ng-update/v4/steps/migrate-templates.js +2 -2
  32. package/schematics/ng-update/v4/steps/templates/index.d.ts +2 -0
  33. package/schematics/ng-update/v4/steps/templates/index.js +2 -0
  34. package/schematics/ng-update/v4/steps/templates/migrate-badge.js +8 -0
  35. package/schematics/ng-update/v4/steps/templates/migrate-label.d.ts +8 -0
  36. package/schematics/ng-update/v4/steps/templates/migrate-label.js +39 -0
  37. package/schematics/ng-update/v4/steps/templates/migrate-labeled.js +4 -4
  38. package/schematics/ng-update/v4/steps/update-packages.js +6 -0
  39. package/schematics/ng-update/v4/steps/utils/replace-modules-with-providers.d.ts +1 -11
  40. package/schematics/ng-update/v4/steps/utils/replace-modules-with-providers.js +8 -4
  41. package/schematics/utils/get-named-import-references.js +4 -2
  42. package/tokens/environment.d.ts +1 -0
  43. package/classes/controller.d.ts +0 -9
  44. package/esm2022/classes/controller.mjs +0 -18
@@ -3,6 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.migrateBadge = void 0;
4
4
  const elements_1 = require("../../../../utils/templates/elements");
5
5
  const template_resource_1 = require("../../../../utils/templates/template-resource");
6
+ const common_1 = require("./toggles/common");
7
+ const badgeSizeMap = {
8
+ xs: 's',
9
+ s: 'm',
10
+ m: 'l',
11
+ l: 'xl',
12
+ };
6
13
  function migrateBadge({ resource, recorder, fileSystem, }) {
7
14
  const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
8
15
  const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
@@ -11,6 +18,7 @@ function migrateBadge({ resource, recorder, fileSystem, }) {
11
18
  if (!sourceCodeLocation) {
12
19
  return;
13
20
  }
21
+ (0, common_1.replaceSizeAttr)(attrs, sourceCodeLocation, recorder, templateOffset, badgeSizeMap);
14
22
  const valueAttr = attrs.find((attr) => attr.name === '[value]' || attr.name === 'value');
15
23
  // migration for icon-only badges
16
24
  if (!valueAttr) {
@@ -0,0 +1,8 @@
1
+ import type { UpdateRecorder } from '@angular-devkit/schematics';
2
+ import type { DevkitFileSystem } from 'ng-morph';
3
+ import type { TemplateResource } from '../../../interfaces';
4
+ export declare function migrateLabel({ resource, recorder, fileSystem, }: {
5
+ fileSystem: DevkitFileSystem;
6
+ recorder: UpdateRecorder;
7
+ resource: TemplateResource;
8
+ }): void;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateLabel = void 0;
4
+ const elements_1 = require("../../../../utils/templates/elements");
5
+ const inputs_1 = require("../../../../utils/templates/inputs");
6
+ const template_resource_1 = require("../../../../utils/templates/template-resource");
7
+ function migrateLabel({ resource, recorder, fileSystem, }) {
8
+ const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
9
+ const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
10
+ const labelElements = (0, elements_1.findElementsByTagName)(template, 'label', ({ attrs }) => attrs.some(({ name }) => name === 'tuilabel' || name === '[tuilabel]'));
11
+ labelElements.forEach(({ attrs, sourceCodeLocation }) => {
12
+ const labelAttr = (0, inputs_1.findAttr)(attrs, 'tuilabel');
13
+ if (!labelAttr || !sourceCodeLocation) {
14
+ return;
15
+ }
16
+ migrateValue({
17
+ valueAttr: labelAttr,
18
+ sourceCodeLocation,
19
+ recorder,
20
+ templateOffset,
21
+ });
22
+ });
23
+ }
24
+ exports.migrateLabel = migrateLabel;
25
+ function migrateValue({ valueAttr, sourceCodeLocation, recorder, templateOffset, }) {
26
+ var _a, _b, _c;
27
+ const attrValue = valueAttr === null || valueAttr === void 0 ? void 0 : valueAttr.value;
28
+ const insertTo = (_b = (_a = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.startTag) === null || _a === void 0 ? void 0 : _a.endOffset) !== null && _b !== void 0 ? _b : 0;
29
+ if (!attrValue || !insertTo) {
30
+ return;
31
+ }
32
+ recorder.insertRight(insertTo + templateOffset, valueAttr.name === 'tuilabel' ? attrValue : `{{ ${attrValue} }}`);
33
+ const attrOffset = (_c = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.attrs) === null || _c === void 0 ? void 0 : _c[valueAttr.name];
34
+ if (attrOffset) {
35
+ const { startOffset, endOffset } = attrOffset;
36
+ recorder.remove(templateOffset + startOffset, endOffset - startOffset);
37
+ recorder.insertRight(templateOffset + startOffset, 'tuiLabel');
38
+ }
39
+ }
@@ -28,14 +28,14 @@ function migrateLabeled({ resource, recorder, fileSystem, }) {
28
28
  'tui-radio-labeled',
29
29
  ]);
30
30
  elements.forEach(({ sourceCodeLocation, tagName }) => {
31
- var _a, _b, _c, _d, _e, _f;
31
+ var _a, _b, _c, _d;
32
32
  if (!sourceCodeLocation) {
33
33
  return;
34
34
  }
35
35
  (0, add_import_to_closest_module_1.addImportToClosestModule)(resource.componentPath, tagName === 'tui-checkbox-labeled' ? 'TuiCheckbox' : 'TuiRadio', '@taiga-ui/kit');
36
- recorder.insertRight(templateOffset + ((_b = (_a = sourceCodeLocation.startTag) === null || _a === void 0 ? void 0 : _a.startOffset) !== null && _b !== void 0 ? _b : 1) - 1, '<label tuiLabel>');
37
- recorder.insertRight(templateOffset + ((_d = (_c = sourceCodeLocation.endTag) === null || _c === void 0 ? void 0 : _c.startOffset) !== null && _d !== void 0 ? _d : 1) - 1, '\n</label>');
38
- recorder.remove(templateOffset + ((_f = (_e = sourceCodeLocation.endTag) === null || _e === void 0 ? void 0 : _e.startOffset) !== null && _f !== void 0 ? _f : 0), tagName === 'tui-checkbox-labeled'
36
+ recorder.insertRight(templateOffset + (((_a = sourceCodeLocation.startTag) === null || _a === void 0 ? void 0 : _a.startOffset) || 1) - 1, '<label tuiLabel>');
37
+ recorder.insertRight(templateOffset + (((_b = sourceCodeLocation.endTag) === null || _b === void 0 ? void 0 : _b.startOffset) || 1) - 1, '\n</label>');
38
+ recorder.remove(templateOffset + ((_d = (_c = sourceCodeLocation.endTag) === null || _c === void 0 ? void 0 : _c.startOffset) !== null && _d !== void 0 ? _d : 0), tagName === 'tui-checkbox-labeled'
39
39
  ? '<tui-checkbox-labeled/>'.length
40
40
  : '<tui-radio-labeled/>'.length);
41
41
  });
@@ -25,5 +25,11 @@ function updatePackages({ tree }, _) {
25
25
  name: '@taiga-ui/editor',
26
26
  version: '^2.0.0',
27
27
  }, tree);
28
+ if (!(0, ng_morph_1.getPackageJsonDependency)(tree, '@taiga-ui/event-plugins')) {
29
+ (0, ng_morph_1.addPackageJsonDependency)(tree, {
30
+ name: '@taiga-ui/event-plugins',
31
+ version: '^4.0.1',
32
+ });
33
+ }
28
34
  }
29
35
  exports.updatePackages = updatePackages;
@@ -1,13 +1,3 @@
1
1
  import type { TuiSchema } from '../../../../ng-add/schema';
2
- interface ModuleToReplace {
3
- from: {
4
- name: string;
5
- moduleSpecifier: string;
6
- };
7
- to: {
8
- name: string;
9
- providerSpecifier: string;
10
- };
11
- }
2
+ import type { ModuleToReplace } from '../constants/modules-to-replace';
12
3
  export declare const replaceModulesWithProviders: (options: TuiSchema, list: ModuleToReplace[]) => void;
13
- export {};
@@ -16,6 +16,7 @@ const replaceModulesWithProviders = (options, list) => {
16
16
  exports.replaceModulesWithProviders = replaceModulesWithProviders;
17
17
  function replaceModule({ from, to }) {
18
18
  const references = (0, get_named_import_references_1.getNamedImportReferences)(from.name, from.moduleSpecifier);
19
+ const toReplace = Array.isArray(to) ? to : [to];
19
20
  references.forEach((ref) => {
20
21
  if (ref.wasForgotten()) {
21
22
  return;
@@ -23,11 +24,14 @@ function replaceModule({ from, to }) {
23
24
  const parent = ref.getParent();
24
25
  if (ng_morph_1.Node.isImportSpecifier(parent)) {
25
26
  (0, import_manipulations_1.removeImport)(parent);
26
- addImport(to, parent.getSourceFile().getFilePath());
27
+ toReplace.forEach((provider) => addImport(provider, parent.getSourceFile().getFilePath()));
27
28
  }
28
29
  else if (ng_morph_1.Node.isArrayLiteralExpression(parent)) {
29
- parent.removeElement(ref.getChildIndex());
30
- addProvider(to, parent.getSourceFile().getFilePath());
30
+ const index = parent
31
+ .getElements()
32
+ .findIndex((el) => el.getText() === from.name);
33
+ parent.removeElement(index);
34
+ toReplace.forEach((provider) => addProvider(provider, parent.getSourceFile().getFilePath()));
31
35
  }
32
36
  });
33
37
  }
@@ -35,7 +39,7 @@ function addImport(identifier, filePath) {
35
39
  (0, add_unique_import_1.addUniqueImport)(filePath, identifier.name, identifier.providerSpecifier);
36
40
  }
37
41
  function addProvider(identifier, filePath) {
38
- const provider = `${identifier.name}()`;
42
+ const provider = `${identifier.name}${identifier.isFunction ? '()' : ''}`;
39
43
  const componentClass = (0, ng_morph_1.getNgComponents)(filePath)[0];
40
44
  if (componentClass) {
41
45
  (0, ng_morph_1.addProviderToComponent)(componentClass, provider);
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNamedImportReferences = void 0;
4
4
  const ng_morph_1 = require("ng-morph");
5
5
  const constants_1 = require("../constants");
6
- function getNamedImportReferences(namedImport, moduleSpecifier = '**/**', files = constants_1.ALL_TS_FILES) {
6
+ function getNamedImportReferences(namedImport, moduleSpecifier = ['**/**'], files = constants_1.ALL_TS_FILES) {
7
7
  const importDeclarations = (0, ng_morph_1.getImports)(files, {
8
8
  namedImports: [namedImport],
9
- moduleSpecifier,
9
+ moduleSpecifier: Array.isArray(moduleSpecifier)
10
+ ? moduleSpecifier
11
+ : [moduleSpecifier, `${moduleSpecifier}/**`],
10
12
  });
11
13
  const namedImports = importDeclarations.map((declaration) => {
12
14
  var _a;
@@ -3,6 +3,7 @@ export declare const TUI_IS_IOS: import("@angular/core").InjectionToken<boolean>
3
3
  export declare const TUI_IS_ANDROID: import("@angular/core").InjectionToken<boolean>;
4
4
  export declare const TUI_IS_WEBKIT: import("@angular/core").InjectionToken<boolean>;
5
5
  export declare const TUI_PLATFORM: import("@angular/core").InjectionToken<"android" | "ios" | "web">;
6
+ export declare const TUI_IS_TOUCH: import("@angular/core").InjectionToken<import("@angular/core").Signal<boolean>>;
6
7
  /**
7
8
  * Detect if app is running under Cypress
8
9
  * {@link https://docs.cypress.io/faq/questions/using-cypress-faq#Is-there-any-way-to-detect-if-my-app-is-running-under-Cypress Cypress docs}
@@ -1,9 +0,0 @@
1
- import type { OnChanges } from '@angular/core';
2
- import { Subject } from 'rxjs';
3
- import * as i0 from "@angular/core";
4
- export declare abstract class AbstractTuiController implements OnChanges {
5
- readonly change$: Subject<void>;
6
- ngOnChanges(): void;
7
- static ɵfac: i0.ɵɵFactoryDeclaration<AbstractTuiController, never>;
8
- static ɵdir: i0.ɵɵDirectiveDeclaration<AbstractTuiController, never, never, {}, {}, never, never, false, never>;
9
- }
@@ -1,18 +0,0 @@
1
- import { Directive } from '@angular/core';
2
- import { Subject } from 'rxjs';
3
- import * as i0 from "@angular/core";
4
- class AbstractTuiController {
5
- constructor() {
6
- this.change$ = new Subject();
7
- }
8
- ngOnChanges() {
9
- this.change$.next();
10
- }
11
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AbstractTuiController, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
12
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: AbstractTuiController, usesOnChanges: true, ngImport: i0 }); }
13
- }
14
- export { AbstractTuiController };
15
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: AbstractTuiController, decorators: [{
16
- type: Directive
17
- }] });
18
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29udHJvbGxlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3Byb2plY3RzL2Nkay9jbGFzc2VzL2NvbnRyb2xsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxFQUFDLFNBQVMsRUFBQyxNQUFNLGVBQWUsQ0FBQztBQUN4QyxPQUFPLEVBQUMsT0FBTyxFQUFDLE1BQU0sTUFBTSxDQUFDOztBQUU3QixNQUNzQixxQkFBcUI7SUFEM0M7UUFFb0IsWUFBTyxHQUFHLElBQUksT0FBTyxFQUFRLENBQUM7S0FLakQ7SUFIVSxXQUFXO1FBQ2QsSUFBSSxDQUFDLE9BQU8sQ0FBQyxJQUFJLEVBQUUsQ0FBQztJQUN4QixDQUFDOytHQUxpQixxQkFBcUI7bUdBQXJCLHFCQUFxQjs7U0FBckIscUJBQXFCOzRGQUFyQixxQkFBcUI7a0JBRDFDLFNBQVMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgdHlwZSB7T25DaGFuZ2VzfSBmcm9tICdAYW5ndWxhci9jb3JlJztcbmltcG9ydCB7RGlyZWN0aXZlfSBmcm9tICdAYW5ndWxhci9jb3JlJztcbmltcG9ydCB7U3ViamVjdH0gZnJvbSAncnhqcyc7XG5cbkBEaXJlY3RpdmUoKVxuZXhwb3J0IGFic3RyYWN0IGNsYXNzIEFic3RyYWN0VHVpQ29udHJvbGxlciBpbXBsZW1lbnRzIE9uQ2hhbmdlcyB7XG4gICAgcHVibGljIHJlYWRvbmx5IGNoYW5nZSQgPSBuZXcgU3ViamVjdDx2b2lkPigpO1xuXG4gICAgcHVibGljIG5nT25DaGFuZ2VzKCk6IHZvaWQge1xuICAgICAgICB0aGlzLmNoYW5nZSQubmV4dCgpO1xuICAgIH1cbn1cbiJdfQ==