@taiga-ui/cdk 4.6.0 → 4.7.0-canary.5ce088a

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 (47) hide show
  1. package/classes/control.d.ts +1 -1
  2. package/constants/used-icons.d.ts +1 -1
  3. package/constants/version.d.ts +1 -1
  4. package/constants/version.js +1 -1
  5. package/esm2022/classes/control.mjs +1 -1
  6. package/esm2022/constants/used-icons.mjs +3 -2
  7. package/esm2022/constants/version.mjs +2 -2
  8. package/esm2022/directives/pan/pan.service.mjs +10 -12
  9. package/esm2022/directives/swipe/swipe.service.mjs +23 -25
  10. package/esm2022/directives/zoom/zoom.service.mjs +27 -29
  11. package/esm2022/services/scroll.service.mjs +5 -3
  12. package/esm2022/tokens/active-element.mjs +5 -4
  13. package/esm2022/tokens/environment.mjs +7 -3
  14. package/esm2022/types/index.mjs +2 -1
  15. package/esm2022/types/loose-union.mjs +2 -0
  16. package/esm2022/utils/browser/is-safari.mjs +2 -2
  17. package/esm2022/utils/color/hex-to-rgba.mjs +2 -2
  18. package/fesm2022/taiga-ui-cdk-classes.mjs.map +1 -1
  19. package/fesm2022/taiga-ui-cdk-constants.mjs +3 -2
  20. package/fesm2022/taiga-ui-cdk-constants.mjs.map +1 -1
  21. package/fesm2022/taiga-ui-cdk-directives-pan.mjs +9 -11
  22. package/fesm2022/taiga-ui-cdk-directives-pan.mjs.map +1 -1
  23. package/fesm2022/taiga-ui-cdk-directives-swipe.mjs +22 -24
  24. package/fesm2022/taiga-ui-cdk-directives-swipe.mjs.map +1 -1
  25. package/fesm2022/taiga-ui-cdk-directives-zoom.mjs +26 -28
  26. package/fesm2022/taiga-ui-cdk-directives-zoom.mjs.map +1 -1
  27. package/fesm2022/taiga-ui-cdk-services.mjs +4 -2
  28. package/fesm2022/taiga-ui-cdk-services.mjs.map +1 -1
  29. package/fesm2022/taiga-ui-cdk-tokens.mjs +10 -5
  30. package/fesm2022/taiga-ui-cdk-tokens.mjs.map +1 -1
  31. package/fesm2022/taiga-ui-cdk-utils-browser.mjs +1 -1
  32. package/fesm2022/taiga-ui-cdk-utils-browser.mjs.map +1 -1
  33. package/fesm2022/taiga-ui-cdk-utils-color.mjs +1 -1
  34. package/fesm2022/taiga-ui-cdk-utils-color.mjs.map +1 -1
  35. package/package.json +362 -362
  36. package/schematics/ng-update/v4/index.js +3 -1
  37. package/schematics/ng-update/v4/steps/constants/attr-with-values-to-replace.js +1 -1
  38. package/schematics/ng-update/v4/steps/constants/identifiers-to-replace.js +20 -20
  39. package/schematics/ng-update/v4/steps/constants/modules-to-remove.js +8 -0
  40. package/schematics/ng-update/v4/steps/migrate-providers-from.d.ts +2 -0
  41. package/schematics/ng-update/v4/steps/migrate-providers-from.js +32 -0
  42. package/schematics/ng-update/v4/steps/templates/migrate-button-appearance.js +2 -2
  43. package/schematics/ng-update/v4/steps/update-packages.d.ts +1 -2
  44. package/schematics/ng-update/v4/steps/update-packages.js +14 -12
  45. package/services/scroll.service.d.ts +1 -0
  46. package/types/index.d.ts +1 -0
  47. package/types/loose-union.d.ts +36 -0
@@ -18,11 +18,13 @@ const modules_to_replace_1 = require("./steps/constants/modules-to-replace");
18
18
  const types_1 = require("./steps/constants/types");
19
19
  const drop_universal_mock_1 = require("./steps/drop-universal-mock");
20
20
  const migrate_editor_1 = require("./steps/migrate-editor");
21
+ const migrate_providers_from_1 = require("./steps/migrate-providers-from");
21
22
  const migrate_root_1 = require("./steps/migrate-root");
22
23
  const replace_modules_with_providers_1 = require("./steps/utils/replace-modules-with-providers");
23
24
  function main(options) {
24
25
  return (tree, context) => {
25
26
  const fileSystem = (0, get_file_system_1.getFileSystem)(tree);
27
+ (0, migrate_providers_from_1.migrateImportProvidersFrom)(options);
26
28
  (0, migrate_editor_1.migrateEditor)(fileSystem, options);
27
29
  (0, steps_1.replaceEnums)(options, enums_1.ENUMS_TO_REPLACE);
28
30
  (0, migrate_root_1.migrateRoot)(fileSystem, options);
@@ -49,7 +51,7 @@ function main(options) {
49
51
  (0, steps_2.removeDuplicates)(options);
50
52
  (0, steps_2.migrateStyles)();
51
53
  (0, steps_2.migrateProprietary)(fileSystem, options);
52
- (0, steps_2.updatePackages)(fileSystem, options);
54
+ (0, steps_2.updatePackages)(fileSystem);
53
55
  fileSystem.commitEdits();
54
56
  (0, ng_morph_1.saveActiveProject)();
55
57
  context.addTask(new tasks_1.NodePackageInstallTask());
@@ -42,7 +42,7 @@ exports.ATTR_WITH_VALUES_TO_REPLACE = [
42
42
  },
43
43
  {
44
44
  attrNames: ['[pseudoInvalid]'],
45
- newAttrName: '[attr.data-mode]',
45
+ newAttrName: '[tuiAppearanceMode]',
46
46
  withTagNames: hasPseudoInvalid,
47
47
  valueReplacer: (condition) => `${condition} ? 'invalid' : null`,
48
48
  },
@@ -1311,6 +1311,26 @@ exports.IDENTIFIERS_TO_REPLACE = [
1311
1311
  spreadInModule: true,
1312
1312
  },
1313
1313
  },
1314
+ {
1315
+ from: {
1316
+ name: 'TuiPreviewDialogModule',
1317
+ moduleSpecifier: '@taiga-ui/addon-preview',
1318
+ },
1319
+ to: {
1320
+ name: 'TuiPreviewDialog',
1321
+ moduleSpecifier: '@taiga-ui/kit',
1322
+ },
1323
+ },
1324
+ {
1325
+ from: {
1326
+ name: 'TuiPreviewDialogService',
1327
+ moduleSpecifier: '@taiga-ui/addon-preview',
1328
+ },
1329
+ to: {
1330
+ name: 'TuiPreviewDialogService',
1331
+ moduleSpecifier: '@taiga-ui/kit',
1332
+ },
1333
+ },
1314
1334
  {
1315
1335
  from: {
1316
1336
  name: 'TuiBlockStatusModule',
@@ -1376,26 +1396,6 @@ exports.IDENTIFIERS_TO_REPLACE = [
1376
1396
  spreadInModule: true,
1377
1397
  },
1378
1398
  },
1379
- {
1380
- from: {
1381
- name: 'TuiPreviewDialogModule',
1382
- moduleSpecifier: '@taiga-ui/addon-preview',
1383
- },
1384
- to: {
1385
- name: 'TuiPreviewDialog',
1386
- moduleSpecifier: '@taiga-ui/kit',
1387
- },
1388
- },
1389
- {
1390
- from: {
1391
- name: 'TuiPreviewDialogService',
1392
- moduleSpecifier: '@taiga-ui/addon-preview',
1393
- },
1394
- to: {
1395
- name: 'TuiPreviewDialogService',
1396
- moduleSpecifier: '@taiga-ui/kit',
1397
- },
1398
- },
1399
1399
  {
1400
1400
  from: {
1401
1401
  name: 'PolymorpheusModule',
@@ -22,6 +22,10 @@ exports.MODULES_TO_REMOVE = [
22
22
  name: 'TuiPromptModule',
23
23
  moduleSpecifier: '@taiga-ui/kit',
24
24
  },
25
+ {
26
+ name: 'TuiPdfViewerModule',
27
+ moduleSpecifier: '@taiga-ui/kit',
28
+ },
25
29
  {
26
30
  name: 'TuiThemeTinkoff2023NightModule',
27
31
  moduleSpecifier: '@taiga-ui/proprietary-core',
@@ -46,4 +50,8 @@ exports.MODULES_TO_REMOVE = [
46
50
  name: 'TuiMobileTabsModule',
47
51
  moduleSpecifier: '@taiga-ui/addon-mobile',
48
52
  },
53
+ {
54
+ name: 'TuiPreviewActionModule',
55
+ moduleSpecifier: '@taiga-ui/addon-preview',
56
+ },
49
57
  ];
@@ -0,0 +1,2 @@
1
+ import type { TuiSchema } from '../../../ng-add/schema';
2
+ export declare function migrateImportProvidersFrom(options: TuiSchema): void;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateImportProvidersFrom = void 0;
4
+ const ng_morph_1 = require("ng-morph");
5
+ const colored_log_1 = require("../../../utils/colored-log");
6
+ const get_named_import_references_1 = require("../../../utils/get-named-import-references");
7
+ function migrateImportProvidersFrom(options) {
8
+ !options['skip-logs'] &&
9
+ (0, colored_log_1.infoLog)(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} updating importProvidersFrom`);
10
+ const refs = [
11
+ ...(0, get_named_import_references_1.getNamedImportReferences)('TuiDialogModule', '@taiga-ui/core'),
12
+ ...(0, get_named_import_references_1.getNamedImportReferences)('TuiAlertModule', '@taiga-ui/core'),
13
+ ...(0, get_named_import_references_1.getNamedImportReferences)('TuiPushModule', '@taiga-ui/kit'),
14
+ ...(0, get_named_import_references_1.getNamedImportReferences)('TuiPdfViewerModule', '@taiga-ui/kit'),
15
+ ...(0, get_named_import_references_1.getNamedImportReferences)('TuiPreviewModule', '@taiga-ui/addon-preview'),
16
+ ];
17
+ for (const ref of refs) {
18
+ if (ref.wasForgotten()) {
19
+ return;
20
+ }
21
+ const callExpression = ref.getParentWhile(ng_morph_1.Node.isCallExpression);
22
+ if ((callExpression === null || callExpression === void 0 ? void 0 : callExpression.getExpression().getText()) === 'importProvidersFrom') {
23
+ const node = callExpression
24
+ .getArguments()
25
+ .find((arg) => arg.getText() === ref.getText());
26
+ if (node) {
27
+ callExpression.removeArgument(node);
28
+ }
29
+ }
30
+ }
31
+ }
32
+ exports.migrateImportProvidersFrom = migrateImportProvidersFrom;
@@ -27,7 +27,7 @@ function migrateButtonAppearance({ resource, recorder, fileSystem, }) {
27
27
  (0, remove_attrs_1.removeAttrs)([whiteBlockActiveAttr], sourceCodeLocation, recorder, templateOffset);
28
28
  const { startOffset } = ((_a = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[whiteBlockActiveAttr.name]) || { startOffset: 0, endOffset: 0 };
29
29
  recorder.insertLeft(startOffset + templateOffset, ` ${appearanceInputName}="whiteblock"`);
30
- recorder.insertLeft(startOffset + templateOffset, ' data-mode="checked"');
30
+ recorder.insertLeft(startOffset + templateOffset, ' tuiAppearanceMode="checked"');
31
31
  }
32
32
  });
33
33
  const elementWithConditionAppearance = elements.find(({ attrs }) => attrs.some(({ name, value }) => name === `[${appearanceInputName}]` && !value.trim().startsWith("'")));
@@ -37,5 +37,5 @@ function migrateButtonAppearance({ resource, recorder, fileSystem, }) {
37
37
  }
38
38
  exports.migrateButtonAppearance = migrateButtonAppearance;
39
39
  function addTodo(recorder, templateOffset) {
40
- recorder.insertRight(templateOffset, '<!-- Taiga migration TODO: tuiButton "whiteblock-active" appearance is no longer available. Use \'appearance="whiteblock" data-mode="checked"\' -->\n');
40
+ recorder.insertRight(templateOffset, '<!-- Taiga migration TODO: tuiButton "whiteblock-active" appearance is no longer available. Use \'appearance="whiteblock" tuiAppearanceMode="checked"\' -->\n');
41
41
  }
@@ -1,7 +1,6 @@
1
1
  /// <reference lib="es2021" />
2
2
  import type { DevkitFileSystem } from 'ng-morph';
3
- import type { TuiSchema } from '../../../ng-add/schema';
4
3
  export declare const TUI_POLYMORPHEUS_VERSION = "^4.6.4";
5
4
  export declare const TUI_DOMPURIFY_VERSION = "^4.1.2";
6
5
  export declare const TUI_EVENT_PLUGINS_VERSION = "^4.0.1";
7
- export declare function updatePackages({ tree }: DevkitFileSystem, _: TuiSchema): void;
6
+ export declare function updatePackages({ tree }: DevkitFileSystem): void;
@@ -4,11 +4,12 @@ exports.updatePackages = exports.TUI_EVENT_PLUGINS_VERSION = exports.TUI_DOMPURI
4
4
  const ng_morph_1 = require("ng-morph");
5
5
  const version_1 = require("../../../../constants/version");
6
6
  const constants_1 = require("../../../constants");
7
+ const colored_log_1 = require("../../../utils/colored-log");
7
8
  const steps_1 = require("../../steps");
8
9
  exports.TUI_POLYMORPHEUS_VERSION = '^4.6.4';
9
10
  exports.TUI_DOMPURIFY_VERSION = '^4.1.2';
10
11
  exports.TUI_EVENT_PLUGINS_VERSION = '^4.0.1';
11
- function updatePackages({ tree }, _) {
12
+ function updatePackages({ tree }) {
12
13
  const packagesToRemove = ['@taiga-ui/addon-tablebars', '@taiga-ui/addon-preview'];
13
14
  packagesToRemove.forEach((pkg) => {
14
15
  (0, ng_morph_1.removePackageJsonDependency)(tree, pkg);
@@ -33,19 +34,20 @@ function updatePackages({ tree }, _) {
33
34
  type: cdk === null || cdk === void 0 ? void 0 : cdk.type,
34
35
  });
35
36
  }
36
- if ((0, ng_morph_1.getImports)(constants_1.ALL_TS_FILES, { moduleSpecifier: '@taiga-ui/layout' }).length) {
37
- (0, ng_morph_1.addPackageJsonDependency)(tree, {
38
- name: '@taiga-ui/layout',
39
- version: version_1.TUI_VERSION,
40
- type: cdk === null || cdk === void 0 ? void 0 : cdk.type,
37
+ try {
38
+ ['@taiga-ui/layout', '@taiga-ui/legacy'].forEach((moduleSpecifier) => {
39
+ if ((0, ng_morph_1.getImports)(constants_1.ALL_TS_FILES, { moduleSpecifier }).length) {
40
+ (0, ng_morph_1.addPackageJsonDependency)(tree, {
41
+ name: moduleSpecifier,
42
+ version: version_1.TUI_VERSION,
43
+ type: cdk === null || cdk === void 0 ? void 0 : cdk.type,
44
+ });
45
+ }
41
46
  });
42
47
  }
43
- if ((0, ng_morph_1.getImports)(constants_1.ALL_TS_FILES, { moduleSpecifier: '@taiga-ui/legacy' }).length) {
44
- (0, ng_morph_1.addPackageJsonDependency)(tree, {
45
- name: '@taiga-ui/legacy',
46
- version: version_1.TUI_VERSION,
47
- type: cdk === null || cdk === void 0 ? void 0 : cdk.type,
48
- });
48
+ catch (e) {
49
+ const error = e;
50
+ (0, colored_log_1.errorLog)(`ATTENTION: An error occurred during migration: ${error.message}\n${error.stack}`);
49
51
  }
50
52
  }
51
53
  exports.updatePackages = updatePackages;
@@ -3,6 +3,7 @@ import * as i0 from "@angular/core";
3
3
  export declare class TuiScrollService {
4
4
  private readonly performanceRef;
5
5
  private readonly animationFrame$;
6
+ private readonly zone;
6
7
  scroll$(elementOrWindow: Element | Window, scrollTop: number, scrollLeft?: number, duration?: number): Observable<[number, number]>;
7
8
  static ɵfac: i0.ɵɵFactoryDeclaration<TuiScrollService, never>;
8
9
  static ɵprov: i0.ɵɵInjectableDeclaration<TuiScrollService>;
package/types/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from './context';
2
2
  export * from './handler';
3
+ export * from './loose-union';
3
4
  export * from './mapper';
4
5
  export * from './matcher';
5
6
  export * from './rounding';
@@ -0,0 +1,36 @@
1
+ /**
2
+ * @example
3
+ * type Color = 'primary' | 'secondary' | string;
4
+ *
5
+ * Your brand has some known colors, like `primary` and `secondary`.
6
+ * But you also want to make sure that users can specify any color they want.
7
+ *
8
+ * @Input() color: Color = '';
9
+ *
10
+ * <my-icon color="red" />
11
+ *
12
+ * But there's an issue. We aren't getting `color`
13
+ * suggestions when we use the `MyIcon` component.
14
+ * If we try to autocomplete the `color` prop, we get no suggestions.
15
+ * Ideally, we want `primary` and `secondary` to be part of that list.
16
+ * How do we manage that?
17
+ *
18
+ * This works because of a quirk of the TypeScript compiler.
19
+ * When you create a union between a string literal type and `string`,
20
+ * TypeScript will eagerly widen the type to `string`.
21
+ *
22
+ * But if we change type to
23
+ * type Color = 'primary' | 'secondary' | (string & {});
24
+ *
25
+ * TypeScript has already forgotten that `"primary"` and `"secondary"`
26
+ * were ever part of the type. But by intersecting `string` with
27
+ * an empty object, we trick TypeScript into retaining the string
28
+ * literal types for a bit longer.
29
+ *
30
+ * This might feel pretty fragile to you. This doesn't seem like
31
+ * intended behavior from TypeScript. Well, the team actually
32
+ * know about this trick. They test against it. And someday, they may make
33
+ * it so that a plain `string` type will just work.
34
+ * But until then, keep this in mind.
35
+ */
36
+ export type TuiLooseUnion<U> = U | (U extends string ? Record<never, never> & string : U extends number ? Record<never, never> & number : U extends symbol ? Record<never, never> & symbol : U extends bigint ? Record<never, never> & bigint : never);