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

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 (48) hide show
  1. package/constants/version.d.ts +1 -1
  2. package/constants/version.js +1 -1
  3. package/esm2022/constants/version.mjs +2 -2
  4. package/esm2022/directives/auto-focus/autofocus.options.mjs +3 -3
  5. package/esm2022/directives/copy-processor/copy-processor.directive.mjs +3 -3
  6. package/esm2022/directives/high-dpi/high-dpi.directive.mjs +3 -3
  7. package/esm2022/directives/obscured/obscured.service.mjs +3 -3
  8. package/esm2022/services/scroll.service.mjs +4 -4
  9. package/esm2022/tokens/active-element.mjs +3 -3
  10. package/esm2022/tokens/environment.mjs +8 -8
  11. package/esm2022/tokens/removed-element.mjs +3 -3
  12. package/esm2022/tokens/window-size.mjs +3 -3
  13. package/fesm2022/taiga-ui-cdk-constants.mjs +1 -1
  14. package/fesm2022/taiga-ui-cdk-constants.mjs.map +1 -1
  15. package/fesm2022/taiga-ui-cdk-directives-auto-focus.mjs +2 -2
  16. package/fesm2022/taiga-ui-cdk-directives-auto-focus.mjs.map +1 -1
  17. package/fesm2022/taiga-ui-cdk-directives-copy-processor.mjs +2 -2
  18. package/fesm2022/taiga-ui-cdk-directives-copy-processor.mjs.map +1 -1
  19. package/fesm2022/taiga-ui-cdk-directives-high-dpi.mjs +2 -2
  20. package/fesm2022/taiga-ui-cdk-directives-high-dpi.mjs.map +1 -1
  21. package/fesm2022/taiga-ui-cdk-directives-obscured.mjs +2 -2
  22. package/fesm2022/taiga-ui-cdk-directives-obscured.mjs.map +1 -1
  23. package/fesm2022/taiga-ui-cdk-services.mjs +3 -3
  24. package/fesm2022/taiga-ui-cdk-services.mjs.map +1 -1
  25. package/fesm2022/taiga-ui-cdk-tokens.mjs +11 -11
  26. package/fesm2022/taiga-ui-cdk-tokens.mjs.map +1 -1
  27. package/package.json +4 -4
  28. package/schematics/ng-update/interfaces/replacement-type.d.ts +4 -0
  29. package/schematics/ng-update/steps/rename-types.js +6 -2
  30. package/schematics/ng-update/steps/replace-identifier.js +9 -1
  31. package/schematics/ng-update/v4/migrate-icons/rename-icons.js +5 -5
  32. package/schematics/ng-update/v4/steps/constants/attr-to-directive-replace.js +3 -2
  33. package/schematics/ng-update/v4/steps/constants/attr-with-values-to-replace.js +2 -1
  34. package/schematics/ng-update/v4/steps/constants/attrs-to-replace.js +23 -16
  35. package/schematics/ng-update/v4/steps/constants/identifiers-to-replace.js +186 -4
  36. package/schematics/ng-update/v4/steps/constants/modules-to-remove.js +4 -0
  37. package/schematics/ng-update/v4/steps/constants/tags-to-replace.js +11 -0
  38. package/schematics/ng-update/v4/steps/constants/types.js +4 -1
  39. package/schematics/ng-update/v4/steps/migrate-styles.js +6 -1
  40. package/schematics/ng-update/v4/steps/migrate-templates.js +3 -0
  41. package/schematics/ng-update/v4/steps/templates/index.d.ts +1 -0
  42. package/schematics/ng-update/v4/steps/templates/index.js +1 -0
  43. package/schematics/ng-update/v4/steps/templates/migrate-blocked.d.ts +8 -0
  44. package/schematics/ng-update/v4/steps/templates/migrate-blocked.js +34 -0
  45. package/schematics/ng-update/v4/steps/templates/migrate-button-appearance.d.ts +8 -0
  46. package/schematics/ng-update/v4/steps/templates/migrate-button-appearance.js +41 -0
  47. package/schematics/ng-update/v4/steps/templates/migrate-labeled.js +2 -4
  48. package/schematics/ng-update/v4/steps/templates/toggles/migrate-checkbox.js +35 -0
@@ -10,6 +10,20 @@ exports.ATTRS_TO_REPLACE = [
10
10
  },
11
11
  to: { attrName: 'iconStart' },
12
12
  },
13
+ {
14
+ from: {
15
+ attrName: 'src',
16
+ withTagNames: ['tui-svg'],
17
+ },
18
+ to: { attrName: 'icon' },
19
+ },
20
+ {
21
+ from: {
22
+ attrName: '[src]',
23
+ withTagNames: ['tui-svg'],
24
+ },
25
+ to: { attrName: '[icon]' },
26
+ },
13
27
  {
14
28
  from: {
15
29
  attrName: '[brandLogo]',
@@ -34,14 +48,14 @@ exports.ATTRS_TO_REPLACE = [
34
48
  {
35
49
  from: {
36
50
  attrName: 'item',
37
- withTagNames: ['tui-radio'],
51
+ withTagNames: ['tui-radio', 'tui-radio-labeled', 'tui-radio-block'],
38
52
  },
39
53
  to: { attrName: 'value' },
40
54
  },
41
55
  {
42
56
  from: {
43
57
  attrName: '[item]',
44
- withTagNames: ['tui-radio'],
58
+ withTagNames: ['tui-radio', 'tui-radio-labeled', 'tui-radio-block'],
45
59
  },
46
60
  to: { attrName: '[value]' },
47
61
  },
@@ -59,20 +73,6 @@ exports.ATTRS_TO_REPLACE = [
59
73
  },
60
74
  to: { attrName: '(waResizeObserver)' },
61
75
  },
62
- {
63
- from: {
64
- attrName: 'item',
65
- withTagNames: ['tui-radio-labeled'],
66
- },
67
- to: { attrName: 'value' },
68
- },
69
- {
70
- from: {
71
- attrName: '[item]',
72
- withTagNames: ['tui-radio-labeled'],
73
- },
74
- to: { attrName: '[value]' },
75
- },
76
76
  // Hosted dropdown
77
77
  {
78
78
  from: {
@@ -234,4 +234,11 @@ exports.ATTRS_TO_REPLACE = [
234
234
  },
235
235
  to: { attrName: '' },
236
236
  },
237
+ {
238
+ from: {
239
+ attrName: 'tuiTextfield',
240
+ withTagNames: ['input', 'textarea'],
241
+ },
242
+ to: { attrName: 'tuiTextfieldLegacy' },
243
+ },
237
244
  ];
@@ -66,6 +66,10 @@ exports.IDENTIFIERS_TO_REPLACE = [
66
66
  from: { name: 'TUI_DIGIT_REGEXP', moduleSpecifier: '@taiga-ui/core' },
67
67
  to: { name: 'TUI_DIGIT_REGEXP', moduleSpecifier: '@taiga-ui/cdk' },
68
68
  },
69
+ {
70
+ from: { name: 'tuiCapitalizeFirstLetter', moduleSpecifier: '@taiga-ui/core' },
71
+ to: { name: 'tuiCapitalizeFirstLetter', moduleSpecifier: '@taiga-ui/legacy' },
72
+ },
69
73
  {
70
74
  from: { name: 'TUI_NON_DIGIT_REGEXP', moduleSpecifier: '@taiga-ui/core' },
71
75
  to: { name: 'TUI_NON_DIGIT_REGEXP', moduleSpecifier: '@taiga-ui/cdk' },
@@ -383,6 +387,10 @@ exports.IDENTIFIERS_TO_REPLACE = [
383
387
  from: { name: 'TuiCheckboxModule', moduleSpecifier: '@taiga-ui/kit' },
384
388
  to: { name: 'TuiCheckbox', moduleSpecifier: '@taiga-ui/kit' },
385
389
  },
390
+ {
391
+ from: { name: 'TuiPrimitiveCheckboxModule', moduleSpecifier: '@taiga-ui/core' },
392
+ to: { name: 'TuiCheckbox', moduleSpecifier: '@taiga-ui/kit' },
393
+ },
386
394
  {
387
395
  from: { name: 'TuiSwipeActionsModule', moduleSpecifier: '@taiga-ui/experimental' },
388
396
  to: [
@@ -394,6 +402,10 @@ exports.IDENTIFIERS_TO_REPLACE = [
394
402
  from: { name: 'TuiRadioModule', moduleSpecifier: '@taiga-ui/experimental' },
395
403
  to: { name: 'TuiRadio', moduleSpecifier: '@taiga-ui/kit', spreadInModule: true },
396
404
  },
405
+ {
406
+ from: { name: 'TuiRadioModule', moduleSpecifier: '@taiga-ui/core' },
407
+ to: { name: 'TuiRadio', moduleSpecifier: '@taiga-ui/kit', spreadInModule: true },
408
+ },
397
409
  {
398
410
  from: { name: 'TuiAvatarModule', moduleSpecifier: '@taiga-ui/experimental' },
399
411
  to: { name: 'TuiAvatar', moduleSpecifier: '@taiga-ui/kit' },
@@ -436,7 +448,11 @@ exports.IDENTIFIERS_TO_REPLACE = [
436
448
  },
437
449
  {
438
450
  from: { name: 'TuiBadgedContentModule', moduleSpecifier: '@taiga-ui/kit' },
439
- to: { name: 'TuiBadgedContent', moduleSpecifier: '@taiga-ui/kit' },
451
+ to: {
452
+ name: 'TuiBadgedContent',
453
+ moduleSpecifier: '@taiga-ui/kit',
454
+ spreadInModule: true,
455
+ },
440
456
  },
441
457
  {
442
458
  from: {
@@ -562,7 +578,7 @@ exports.IDENTIFIERS_TO_REPLACE = [
562
578
  {
563
579
  from: { name: 'TuiResizeModule', moduleSpecifier: '@taiga-ui/cdk' },
564
580
  to: {
565
- name: 'ResizeObserverDirective',
581
+ name: 'WaResizeObserver',
566
582
  moduleSpecifier: '@ng-web-apis/resize-observer',
567
583
  },
568
584
  },
@@ -645,6 +661,14 @@ exports.IDENTIFIERS_TO_REPLACE = [
645
661
  from: { name: 'TuiIconModule', moduleSpecifier: '@taiga-ui/experimental' },
646
662
  to: { name: 'TuiIcon', moduleSpecifier: '@taiga-ui/core' },
647
663
  },
664
+ {
665
+ from: { name: 'TuiCheckboxComponent', moduleSpecifier: '@taiga-ui/kit' },
666
+ to: { name: 'TuiCheckbox', moduleSpecifier: '@taiga-ui/kit' },
667
+ },
668
+ {
669
+ from: { name: 'TuiCheckboxLabeledComponent', moduleSpecifier: '@taiga-ui/kit' },
670
+ to: { name: 'TuiCheckbox', moduleSpecifier: '@taiga-ui/kit' },
671
+ },
648
672
  {
649
673
  from: { name: 'TuiCheckboxLabeledModule', moduleSpecifier: '@taiga-ui/kit' },
650
674
  to: { name: 'TuiLabel', moduleSpecifier: '@taiga-ui/core' },
@@ -653,13 +677,35 @@ exports.IDENTIFIERS_TO_REPLACE = [
653
677
  from: { name: 'TuiRadioLabeledModule', moduleSpecifier: '@taiga-ui/kit' },
654
678
  to: { name: 'TuiLabel', moduleSpecifier: '@taiga-ui/core' },
655
679
  },
680
+ {
681
+ from: { name: 'TuiRadioLabeledComponent', moduleSpecifier: '@taiga-ui/kit' },
682
+ to: { name: 'TuiRadioComponent', moduleSpecifier: '@taiga-ui/kit' },
683
+ },
684
+ {
685
+ from: { name: 'TuiCheckboxBlockModule', moduleSpecifier: '@taiga-ui/kit' },
686
+ to: [
687
+ { name: 'TuiBlock', moduleSpecifier: '@taiga-ui/kit' },
688
+ { name: 'TuiCheckbox', moduleSpecifier: '@taiga-ui/kit' },
689
+ ],
690
+ },
691
+ {
692
+ from: { name: 'TuiRadioBlockModule', moduleSpecifier: '@taiga-ui/kit' },
693
+ to: [
694
+ { name: 'TuiBlock', moduleSpecifier: '@taiga-ui/kit' },
695
+ { name: 'TuiRadio', moduleSpecifier: '@taiga-ui/kit', spreadInModule: true },
696
+ ],
697
+ },
656
698
  {
657
699
  from: { name: 'TuiTabsModule', moduleSpecifier: '@taiga-ui/kit' },
658
700
  to: { name: 'TuiTabs', moduleSpecifier: '@taiga-ui/kit', spreadInModule: true },
659
701
  },
660
702
  {
661
703
  from: { name: 'TuiHostedDropdownModule', moduleSpecifier: '@taiga-ui/core' },
662
- to: { name: 'TuiDropdown', moduleSpecifier: '@taiga-ui/core' },
704
+ to: {
705
+ name: 'TuiDropdown',
706
+ moduleSpecifier: '@taiga-ui/core',
707
+ spreadInModule: true,
708
+ },
663
709
  },
664
710
  {
665
711
  from: { name: 'TuiTitleModule', moduleSpecifier: '@taiga-ui/experimental' },
@@ -699,7 +745,7 @@ exports.IDENTIFIERS_TO_REPLACE = [
699
745
  },
700
746
  {
701
747
  from: { name: 'TuiSvgModule', moduleSpecifier: '@taiga-ui/core' },
702
- to: { name: 'TuiSvgComponent', moduleSpecifier: '@taiga-ui/legacy' },
748
+ to: { name: 'TuiIcon', moduleSpecifier: '@taiga-ui/core' },
703
749
  },
704
750
  {
705
751
  from: { name: 'TuiCellModule', moduleSpecifier: '@taiga-ui/experimental' },
@@ -784,6 +830,16 @@ exports.IDENTIFIERS_TO_REPLACE = [
784
830
  moduleSpecifier: '@taiga-ui/core',
785
831
  },
786
832
  },
833
+ {
834
+ from: {
835
+ name: 'tuiButtonOptionsProvider',
836
+ moduleSpecifier: '@taiga-ui/experimental',
837
+ },
838
+ to: {
839
+ name: 'tuiButtonOptionsProvider',
840
+ moduleSpecifier: '@taiga-ui/core',
841
+ },
842
+ },
787
843
  {
788
844
  from: { name: 'TuiLetModule', moduleSpecifier: '@taiga-ui/cdk' },
789
845
  to: { name: 'TuiLet', moduleSpecifier: '@taiga-ui/cdk' },
@@ -1244,6 +1300,26 @@ exports.IDENTIFIERS_TO_REPLACE = [
1244
1300
  moduleSpecifier: '@taiga-ui/kit',
1245
1301
  },
1246
1302
  },
1303
+ {
1304
+ from: {
1305
+ name: 'TuiButtonGroupModule',
1306
+ moduleSpecifier: '@taiga-ui/experimental',
1307
+ },
1308
+ to: {
1309
+ name: 'TuiButtonGroup',
1310
+ moduleSpecifier: '@taiga-ui/kit',
1311
+ },
1312
+ },
1313
+ {
1314
+ from: {
1315
+ name: 'TuiButtonVerticalModule',
1316
+ moduleSpecifier: '@taiga-ui/experimental',
1317
+ },
1318
+ to: {
1319
+ name: 'TuiButtonVertical',
1320
+ moduleSpecifier: '@taiga-ui/kit',
1321
+ },
1322
+ },
1247
1323
  {
1248
1324
  from: {
1249
1325
  name: 'TuiPreviewModule',
@@ -2419,4 +2495,110 @@ exports.IDENTIFIERS_TO_REPLACE = [
2419
2495
  moduleSpecifier: '@taiga-ui/core',
2420
2496
  },
2421
2497
  },
2498
+ {
2499
+ from: {
2500
+ name: 'ResizeObserverModule',
2501
+ moduleSpecifier: '@ng-web-apis/resize-observer',
2502
+ },
2503
+ to: {
2504
+ name: 'WaResizeObserver',
2505
+ moduleSpecifier: '@ng-web-apis/resize-observer',
2506
+ },
2507
+ },
2508
+ {
2509
+ from: {
2510
+ name: 'IntersectionObserverModule',
2511
+ moduleSpecifier: '@ng-web-apis/intersection-observer',
2512
+ },
2513
+ to: {
2514
+ name: 'WaIntersectionObserver',
2515
+ moduleSpecifier: '@ng-web-apis/intersection-observer',
2516
+ },
2517
+ },
2518
+ {
2519
+ from: {
2520
+ name: 'INTERSECTION_THRESHOLD',
2521
+ moduleSpecifier: '@ng-web-apis/intersection-observer',
2522
+ },
2523
+ to: {
2524
+ name: 'WA_INTERSECTION_THRESHOLD',
2525
+ moduleSpecifier: '@ng-web-apis/intersection-observer',
2526
+ },
2527
+ },
2528
+ {
2529
+ from: {
2530
+ name: 'INTERSECTION_ROOT_MARGIN',
2531
+ moduleSpecifier: '@ng-web-apis/intersection-observer',
2532
+ },
2533
+ to: {
2534
+ name: 'WA_INTERSECTION_ROOT_MARGIN',
2535
+ moduleSpecifier: '@ng-web-apis/intersection-observer',
2536
+ },
2537
+ },
2538
+ {
2539
+ from: {
2540
+ name: 'INTERSECTION_ROOT',
2541
+ moduleSpecifier: '@ng-web-apis/intersection-observer',
2542
+ },
2543
+ to: {
2544
+ name: 'WA_INTERSECTION_ROOT',
2545
+ moduleSpecifier: '@ng-web-apis/intersection-observer',
2546
+ },
2547
+ },
2548
+ {
2549
+ from: {
2550
+ name: 'MUTATION_OBSERVER_INIT',
2551
+ moduleSpecifier: '@ng-web-apis/mutation-observer',
2552
+ },
2553
+ to: {
2554
+ name: 'WA_MUTATION_OBSERVER_INIT',
2555
+ moduleSpecifier: '@ng-web-apis/mutation-observer',
2556
+ },
2557
+ },
2558
+ {
2559
+ from: {
2560
+ name: 'MutationObserverDirective',
2561
+ moduleSpecifier: '@ng-web-apis/mutation-observer',
2562
+ },
2563
+ to: {
2564
+ name: 'WaMutationObserver',
2565
+ moduleSpecifier: '@ng-web-apis/mutation-observer',
2566
+ },
2567
+ },
2568
+ {
2569
+ from: { name: 'WINDOW', moduleSpecifier: '@ng-web-apis/common' },
2570
+ to: { name: 'WA_WINDOW', moduleSpecifier: '@ng-web-apis/common' },
2571
+ },
2572
+ {
2573
+ from: { name: 'USER_AGENT', moduleSpecifier: '@ng-web-apis/common' },
2574
+ to: { name: 'WA_USER_AGENT', moduleSpecifier: '@ng-web-apis/common' },
2575
+ },
2576
+ {
2577
+ from: { name: 'NAVIGATOR', moduleSpecifier: '@ng-web-apis/common' },
2578
+ to: { name: 'WA_NAVIGATOR', moduleSpecifier: '@ng-web-apis/common' },
2579
+ },
2580
+ {
2581
+ from: { name: 'SESSION_STORAGE', moduleSpecifier: '@ng-web-apis/common' },
2582
+ to: { name: 'WA_SESSION_STORAGE', moduleSpecifier: '@ng-web-apis/common' },
2583
+ },
2584
+ {
2585
+ from: { name: 'PAGE_VISIBILITY', moduleSpecifier: '@ng-web-apis/common' },
2586
+ to: { name: 'WA_PAGE_VISIBILITY', moduleSpecifier: '@ng-web-apis/common' },
2587
+ },
2588
+ {
2589
+ from: { name: 'LOCATION', moduleSpecifier: '@ng-web-apis/common' },
2590
+ to: { name: 'WA_LOCATION', moduleSpecifier: '@ng-web-apis/common' },
2591
+ },
2592
+ {
2593
+ from: { name: 'PERFORMANCE', moduleSpecifier: '@ng-web-apis/common' },
2594
+ to: { name: 'WA_PERFORMANCE', moduleSpecifier: '@ng-web-apis/common' },
2595
+ },
2596
+ {
2597
+ from: { name: 'LOCAL_STORAGE', moduleSpecifier: '@ng-web-apis/common' },
2598
+ to: { name: 'WA_LOCAL_STORAGE', moduleSpecifier: '@ng-web-apis/common' },
2599
+ },
2600
+ {
2601
+ from: { name: 'ANIMATION_FRAME', moduleSpecifier: '@ng-web-apis/common' },
2602
+ to: { name: 'WA_ANIMATION_FRAME', moduleSpecifier: '@ng-web-apis/common' },
2603
+ },
2422
2604
  ];
@@ -34,4 +34,8 @@ exports.MODULES_TO_REMOVE = [
34
34
  name: 'TuiModeModule',
35
35
  moduleSpecifier: '@taiga-ui/core',
36
36
  },
37
+ {
38
+ name: 'TuiIconsModule',
39
+ moduleSpecifier: '@taiga-ui/experimental',
40
+ },
37
41
  ];
@@ -4,6 +4,7 @@ exports.TAGS_TO_REPLACE = void 0;
4
4
  exports.TAGS_TO_REPLACE = [
5
5
  { from: 'tui-card', to: 'tui-thumbnail-card' },
6
6
  { from: 'tui-text-area', to: 'tui-textarea' },
7
+ { from: 'tui-svg', to: 'tui-icon' },
7
8
  {
8
9
  from: 'tui-input-count',
9
10
  to: 'tui-input-number',
@@ -30,6 +31,16 @@ exports.TAGS_TO_REPLACE = [
30
31
  to: 'input',
31
32
  addAttributes: ['tuiRadio', 'type="radio"'],
32
33
  },
34
+ {
35
+ from: 'tui-checkbox-block',
36
+ to: 'input',
37
+ addAttributes: ['tuiCheckbox', 'type="checkbox"'],
38
+ },
39
+ {
40
+ from: 'tui-radio-block',
41
+ to: 'input',
42
+ addAttributes: ['tuiRadio', 'type="radio"'],
43
+ },
33
44
  {
34
45
  from: 'tui-hosted-dropdown',
35
46
  to: 'div',
@@ -4,9 +4,12 @@ exports.TYPES_TO_RENAME = void 0;
4
4
  exports.TYPES_TO_RENAME = [
5
5
  {
6
6
  from: 'TuiDocExample',
7
- to: 'Record<string, string | Promise<unknown>>',
7
+ to: 'Record<string, TuiRawLoaderContent>',
8
8
  moduleSpecifier: ['@taiga-ui/addon-doc'],
9
9
  removeImport: true,
10
+ newImports: [
11
+ { name: 'TuiRawLoaderContent', moduleSpecifier: '@taiga-ui/addon-doc' },
12
+ ],
10
13
  },
11
14
  {
12
15
  from: 'TuiBrightness',
@@ -13,7 +13,12 @@ function migrateStyles() {
13
13
  .replace(/^(.*--tui-rating-size.*)$/gm, `${exports.TUI_RATING_WARNING}\n$1`)
14
14
  // eslint-disable-next-line
15
15
  .replace(/^(.*--tui-rating-gap.*)$/gm, `${exports.TUI_RATING_WARNING}\n$1`)
16
- .replaceAll('--tui-link-icon-size', '--tui-icon-size');
16
+ .replaceAll('--tui-link-icon-size', '--tui-icon-size')
17
+ .replaceAll('@taiga-ui/proprietary-core/styles/tinkoff-fonts', '@taiga-ui/proprietary/styles/tbank-fonts')
18
+ .replaceAll('@taiga-ui/proprietary-core/styles/theme-tinkoff-2023', '@taiga-ui/proprietary/styles/tbank-theme')
19
+ .replaceAll('@taiga-ui/proprietary-core/styles/theme-tinkoff-mobile-2023', '@taiga-ui/proprietary/styles/tbank-theme-mobile.less')
20
+ .replaceAll('@taiga-ui/proprietary-core/styles/theme-tinkoff-mobile', '@taiga-ui/proprietary/styles/tbank-theme-mobile.less')
21
+ .replaceAll('@taiga-ui/proprietary-core/styles/theme-tinkoff', '@taiga-ui/proprietary/styles/tbank-theme');
17
22
  sourceFile.replaceWithText(fullText);
18
23
  });
19
24
  (0, ng_morph_1.saveActiveProject)();
@@ -10,6 +10,7 @@ const templates_1 = require("../../utils/templates");
10
10
  const replace_attrs_by_directives_1 = require("../../utils/templates/replace-attrs-by-directives");
11
11
  const constants_2 = require("./constants");
12
12
  const templates_2 = require("./templates");
13
+ const migrate_blocked_1 = require("./templates/migrate-blocked");
13
14
  function getAction({ action, requiredData, }) {
14
15
  return ({ resource, fileSystem, recorder, }) => action({ resource, fileSystem, recorder, data: requiredData });
15
16
  }
@@ -38,9 +39,11 @@ function migrateTemplates(fileSystem, options) {
38
39
  templates_2.migratePreventDefault,
39
40
  templates_2.migrateMoney,
40
41
  templates_2.migrateLabeled,
42
+ migrate_blocked_1.migrateBlocked,
41
43
  templates_2.migrateProgressSegmented,
42
44
  templates_2.migrateThumbnailCard,
43
45
  templates_2.migrateOverscroll,
46
+ templates_2.migrateButtonAppearance,
44
47
  templates_2.migrateLabel,
45
48
  ];
46
49
  const progressLog = (0, progress_1.setupProgressLogger)({
@@ -1,6 +1,7 @@
1
1
  export * from './migrate-avatar';
2
2
  export * from './migrate-badge';
3
3
  export * from './migrate-badged-content';
4
+ export * from './migrate-button-appearance';
4
5
  export * from './migrate-expandable';
5
6
  export * from './migrate-focusable';
6
7
  export * from './migrate-label';
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./migrate-avatar"), exports);
5
5
  tslib_1.__exportStar(require("./migrate-badge"), exports);
6
6
  tslib_1.__exportStar(require("./migrate-badged-content"), exports);
7
+ tslib_1.__exportStar(require("./migrate-button-appearance"), exports);
7
8
  tslib_1.__exportStar(require("./migrate-expandable"), exports);
8
9
  tslib_1.__exportStar(require("./migrate-focusable"), exports);
9
10
  tslib_1.__exportStar(require("./migrate-label"), exports);
@@ -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 migrateBlocked({ resource, recorder, fileSystem, }: {
5
+ fileSystem: DevkitFileSystem;
6
+ recorder: UpdateRecorder;
7
+ resource: TemplateResource;
8
+ }): void;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateBlocked = void 0;
4
+ const elements_1 = require("../../../../utils/templates/elements");
5
+ const template_resource_1 = require("../../../../utils/templates/template-resource");
6
+ function migrateBlocked({ resource, recorder, fileSystem, }) {
7
+ const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
8
+ const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
9
+ const elements = (0, elements_1.findElementsByTagNames)(template, [
10
+ 'tui-checkbox-block',
11
+ 'tui-radio-block',
12
+ ]);
13
+ elements.forEach(({ sourceCodeLocation, tagName, attrs }) => {
14
+ var _a, _b, _c, _d;
15
+ if (!sourceCodeLocation) {
16
+ return;
17
+ }
18
+ const [, hideIconAttrLocation] = Object.entries(sourceCodeLocation.attrs || {}).find(([name]) => name.includes('hideCheckbox'.toLowerCase()) ||
19
+ name.includes('hideRadio'.toLowerCase())) || [];
20
+ const [, sizeAttrLocation] = Object.entries(sourceCodeLocation.attrs || {}).find(([name]) => name.includes('size')) || [];
21
+ const sizeAttr = attrs.find(({ name }) => name.includes('size'));
22
+ const newBlockAttr = `tuiBlock${sizeAttr ? `="${sizeAttr.value === 'xs' ? 's' : sizeAttr.value}"` : ''}`;
23
+ recorder.insertRight(templateOffset + (((_a = sourceCodeLocation.startTag) === null || _a === void 0 ? void 0 : _a.startOffset) || 1) - 1, `<label ${newBlockAttr}${hideIconAttrLocation ? ' appearance=""' : ''}>`);
24
+ recorder.remove(templateOffset + ((_c = (_b = sourceCodeLocation.endTag) === null || _b === void 0 ? void 0 : _b.startOffset) !== null && _c !== void 0 ? _c : 0), `<${tagName}/>`.length);
25
+ recorder.insertRight(templateOffset + (((_d = sourceCodeLocation.endTag) === null || _d === void 0 ? void 0 : _d.startOffset) || 1), '</label>');
26
+ if (hideIconAttrLocation) {
27
+ recorder.remove(templateOffset + hideIconAttrLocation.startOffset, hideIconAttrLocation.endOffset - hideIconAttrLocation.startOffset);
28
+ }
29
+ if (sizeAttrLocation) {
30
+ recorder.remove(templateOffset + sizeAttrLocation.startOffset, sizeAttrLocation.endOffset - sizeAttrLocation.startOffset);
31
+ }
32
+ });
33
+ }
34
+ exports.migrateBlocked = migrateBlocked;
@@ -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 migrateButtonAppearance({ resource, recorder, fileSystem, }: {
5
+ fileSystem: DevkitFileSystem;
6
+ recorder: UpdateRecorder;
7
+ resource: TemplateResource;
8
+ }): void;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migrateButtonAppearance = void 0;
4
+ const elements_1 = require("../../../../utils/templates/elements");
5
+ const template_resource_1 = require("../../../../utils/templates/template-resource");
6
+ const remove_attrs_1 = require("../utils/remove-attrs");
7
+ const tuiButtonSelectors = ['tuiButton', 'tuiIconButton'];
8
+ const appearanceInputName = 'appearance';
9
+ const appearanceInputNameDict = {
10
+ [appearanceInputName]: true,
11
+ [`[${appearanceInputName}]`]: true,
12
+ };
13
+ function migrateButtonAppearance({ resource, recorder, fileSystem, }) {
14
+ const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
15
+ const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
16
+ const elements = tuiButtonSelectors.flatMap((selector) => (0, elements_1.findElementsWithDirective)(template, selector).filter(({ sourceCodeLocation, attrs }) => !!sourceCodeLocation &&
17
+ attrs.some(({ name }) => appearanceInputNameDict[name])));
18
+ if (!elements.length) {
19
+ return;
20
+ }
21
+ const whiteBlockValue = 'whiteblock-active';
22
+ elements.forEach(({ attrs, sourceCodeLocation }) => {
23
+ var _a;
24
+ const whiteBlockActiveAttr = attrs.find(({ value, name }) => appearanceInputNameDict[name] &&
25
+ (value === whiteBlockValue || value === `'${whiteBlockValue}'`));
26
+ if (whiteBlockActiveAttr) {
27
+ (0, remove_attrs_1.removeAttrs)([whiteBlockActiveAttr], sourceCodeLocation, recorder, templateOffset);
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
+ recorder.insertLeft(startOffset + templateOffset, ` ${appearanceInputName}="whiteblock"`);
30
+ recorder.insertLeft(startOffset + templateOffset, ' data-mode="checked"');
31
+ }
32
+ });
33
+ const elementWithConditionAppearance = elements.find(({ attrs }) => attrs.some(({ name, value }) => name === `[${appearanceInputName}]` && !value.trim().startsWith("'")));
34
+ if (elementWithConditionAppearance) {
35
+ addTodo(recorder, templateOffset);
36
+ }
37
+ }
38
+ exports.migrateButtonAppearance = migrateButtonAppearance;
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');
41
+ }
@@ -34,10 +34,8 @@ function migrateLabeled({ resource, recorder, fileSystem, }) {
34
34
  }
35
35
  (0, add_import_to_closest_module_1.addImportToClosestModule)(resource.componentPath, tagName === 'tui-checkbox-labeled' ? 'TuiCheckbox' : 'TuiRadio', '@taiga-ui/kit');
36
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
- ? '<tui-checkbox-labeled/>'.length
40
- : '<tui-radio-labeled/>'.length);
37
+ recorder.remove(templateOffset + ((_c = (_b = sourceCodeLocation.endTag) === null || _b === void 0 ? void 0 : _b.startOffset) !== null && _c !== void 0 ? _c : 0), `<${tagName}/>`.length);
38
+ recorder.insertRight(templateOffset + (((_d = sourceCodeLocation.endTag) === null || _d === void 0 ? void 0 : _d.startOffset) || 1), '</label>');
41
39
  });
42
40
  }
43
41
  exports.migrateLabeled = migrateLabeled;
@@ -21,5 +21,40 @@ function migrateCheckbox({ resource, recorder, fileSystem, }) {
21
21
  (0, common_1.closeStartTag)(sourceCodeLocation, recorder, templateOffset);
22
22
  (0, common_1.removeClosingTag)(sourceCodeLocation, recorder, templateOffset);
23
23
  });
24
+ (0, elements_1.findElementsByTagName)(template, 'tui-primitive-checkbox').forEach(({ attrs, sourceCodeLocation }) => {
25
+ if (!sourceCodeLocation) {
26
+ return;
27
+ }
28
+ (0, common_1.replaceSizeAttr)(attrs, sourceCodeLocation, recorder, templateOffset);
29
+ replaceValueAttr(attrs, sourceCodeLocation, recorder, templateOffset);
30
+ (0, common_1.replaceOpenTag)(sourceCodeLocation, recorder, templateOffset, {
31
+ tag: 'tui-primitive-checkbox',
32
+ directive: 'tuiCheckbox',
33
+ type: 'checkbox',
34
+ });
35
+ (0, common_1.closeStartTag)(sourceCodeLocation, recorder, templateOffset);
36
+ (0, common_1.removeClosingTag)(sourceCodeLocation, recorder, templateOffset);
37
+ });
24
38
  }
25
39
  exports.migrateCheckbox = migrateCheckbox;
40
+ function replaceValueAttr(attrs, sourceCodeLocation, recorder, templateOffset) {
41
+ var _a;
42
+ const valueAttr = attrs.find((attr) => attr.name === 'value' || attr.name === '[value]');
43
+ if (valueAttr) {
44
+ const { startOffset, endOffset } = ((_a = sourceCodeLocation.attrs) === null || _a === void 0 ? void 0 : _a[valueAttr.name]) || {
45
+ startOffset: 0,
46
+ endOffset: 0,
47
+ };
48
+ recorder.remove(templateOffset + startOffset, endOffset - startOffset);
49
+ switch (valueAttr.value) {
50
+ case 'false':
51
+ case 'null':
52
+ return;
53
+ case 'true':
54
+ recorder.insertRight(templateOffset + startOffset, 'checked ');
55
+ return;
56
+ default:
57
+ recorder.insertRight(templateOffset + startOffset, `[checked]="${valueAttr.value}" `);
58
+ }
59
+ }
60
+ }