@taiga-ui/cdk 3.44.1 → 3.45.0-canary.1c27922

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 (122) hide show
  1. package/bundles/taiga-ui-cdk-abstract.umd.js +4 -1
  2. package/bundles/taiga-ui-cdk-abstract.umd.js.map +1 -1
  3. package/bundles/taiga-ui-cdk-constants.umd.js +1 -1
  4. package/bundles/taiga-ui-cdk-constants.umd.js.map +1 -1
  5. package/bundles/taiga-ui-cdk-directives-hovered.umd.js +6 -1
  6. package/bundles/taiga-ui-cdk-directives-hovered.umd.js.map +1 -1
  7. package/bundles/taiga-ui-cdk-tokens.umd.js +86 -123
  8. package/bundles/taiga-ui-cdk-tokens.umd.js.map +1 -1
  9. package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.js +6 -10
  10. package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.js.map +1 -1
  11. package/constants/version.d.ts +1 -1
  12. package/constants/version.js +1 -1
  13. package/esm2015/abstract/interactive.js +5 -2
  14. package/esm2015/constants/version.js +2 -2
  15. package/esm2015/directives/hovered/hovered.service.js +7 -2
  16. package/esm2015/tokens/active-element.js +38 -40
  17. package/esm2015/tokens/default-renderer.js +6 -6
  18. package/esm2015/tokens/ensure-base-href.js +12 -13
  19. package/esm2015/tokens/is-android.js +4 -5
  20. package/esm2015/tokens/is-apple.js +4 -6
  21. package/esm2015/tokens/is-chromium.js +4 -5
  22. package/esm2015/tokens/is-cypress.js +4 -5
  23. package/esm2015/tokens/is-e2e.js +4 -5
  24. package/esm2015/tokens/is-firefox.js +6 -7
  25. package/esm2015/tokens/is-ios.js +4 -6
  26. package/esm2015/tokens/is-mobile.js +5 -6
  27. package/esm2015/tokens/is-playwright.js +3 -5
  28. package/esm2015/tokens/is-stackblitz.js +4 -5
  29. package/esm2015/tokens/is-webkit.js +6 -7
  30. package/esm2015/tokens/range.js +4 -5
  31. package/esm2015/tokens/removed-element.js +13 -14
  32. package/esm2015/tokens/take-only-trusted-events.js +3 -5
  33. package/esm2015/tokens/touch-supported.js +4 -5
  34. package/esm2015/tokens/window-height.js +4 -5
  35. package/esm2015/utils/miscellaneous/create-options.js +3 -5
  36. package/esm2015/utils/miscellaneous/create-token.js +2 -4
  37. package/fesm2015/taiga-ui-cdk-abstract.js +5 -2
  38. package/fesm2015/taiga-ui-cdk-abstract.js.map +1 -1
  39. package/fesm2015/taiga-ui-cdk-constants.js +1 -1
  40. package/fesm2015/taiga-ui-cdk-constants.js.map +1 -1
  41. package/fesm2015/taiga-ui-cdk-directives-hovered.js +6 -1
  42. package/fesm2015/taiga-ui-cdk-directives-hovered.js.map +1 -1
  43. package/fesm2015/taiga-ui-cdk-tokens.js +79 -116
  44. package/fesm2015/taiga-ui-cdk-tokens.js.map +1 -1
  45. package/fesm2015/taiga-ui-cdk-utils-miscellaneous.js +6 -10
  46. package/fesm2015/taiga-ui-cdk-utils-miscellaneous.js.map +1 -1
  47. package/package.json +1 -1
  48. package/schematics/ng-add/tests/schematic-ng-add-standalone.spec.d.ts +1 -0
  49. package/schematics/ng-add/tests/schematic-ng-add-standalone.spec.js +381 -0
  50. package/schematics/ng-add/tests/schematic-ng-add.spec.d.ts +1 -0
  51. package/schematics/ng-add/tests/schematic-ng-add.spec.js +270 -0
  52. package/schematics/ng-update/v3/tests/schematic-date-time.spec.d.ts +1 -0
  53. package/schematics/ng-update/v3/tests/schematic-date-time.spec.js +117 -0
  54. package/schematics/ng-update/v3/tests/schematic-migrate-hints.spec.d.ts +1 -0
  55. package/schematics/ng-update/v3/tests/schematic-migrate-hints.spec.js +102 -0
  56. package/schematics/ng-update/v3/tests/schematic-migrate-polymorpheus.spec.d.ts +1 -0
  57. package/schematics/ng-update/v3/tests/schematic-migrate-polymorpheus.spec.js +107 -0
  58. package/schematics/ng-update/v3/tests/schematic-migrate-progress.spec.d.ts +1 -0
  59. package/schematics/ng-update/v3/tests/schematic-migrate-progress.spec.js +113 -0
  60. package/schematics/ng-update/v3/tests/schematic-migrate-sliders.spec.d.ts +1 -0
  61. package/schematics/ng-update/v3/tests/schematic-migrate-sliders.spec.js +380 -0
  62. package/schematics/ng-update/v3/tests/schematic-migrate-tds.spec.d.ts +1 -0
  63. package/schematics/ng-update/v3/tests/schematic-migrate-tds.spec.js +119 -0
  64. package/schematics/ng-update/v3/tests/schematic-migrate-textfields.spec.d.ts +1 -0
  65. package/schematics/ng-update/v3/tests/schematic-migrate-textfields.spec.js +123 -0
  66. package/schematics/ng-update/v3/tests/schematic-miscellaneous.spec.d.ts +1 -0
  67. package/schematics/ng-update/v3/tests/schematic-miscellaneous.spec.js +81 -0
  68. package/schematics/ng-update/v3/tests/schematic-rename-types.spec.d.ts +1 -0
  69. package/schematics/ng-update/v3/tests/schematic-rename-types.spec.js +157 -0
  70. package/schematics/ng-update/v3/tests/schematic-replace-consts.spec.d.ts +1 -0
  71. package/schematics/ng-update/v3/tests/schematic-replace-consts.spec.js +135 -0
  72. package/schematics/ng-update/v3/tests/schematic-replace-deep-imports.spec.d.ts +1 -0
  73. package/schematics/ng-update/v3/tests/schematic-replace-deep-imports.spec.js +53 -0
  74. package/schematics/ng-update/v3/tests/schematic-replace-deprecated-functions.spec.d.ts +1 -0
  75. package/schematics/ng-update/v3/tests/schematic-replace-deprecated-functions.spec.js +835 -0
  76. package/schematics/ng-update/v3/tests/schematic-replace-enums.spec.d.ts +1 -0
  77. package/schematics/ng-update/v3/tests/schematic-replace-enums.spec.js +68 -0
  78. package/schematics/ng-update/v3/tests/schematic-replace-functions.spec.d.ts +1 -0
  79. package/schematics/ng-update/v3/tests/schematic-replace-functions.spec.js +195 -0
  80. package/schematics/ng-update/v3/tests/schematic-replace-html.spec.d.ts +1 -0
  81. package/schematics/ng-update/v3/tests/schematic-replace-html.spec.js +611 -0
  82. package/schematics/ng-update/v3/tests/schematic-replace-proprietary-consts.spec.d.ts +1 -0
  83. package/schematics/ng-update/v3/tests/schematic-replace-proprietary-consts.spec.js +100 -0
  84. package/schematics/ng-update/v3/tests/schematic-replace-services.spec.d.ts +1 -0
  85. package/schematics/ng-update/v3/tests/schematic-replace-services.spec.js +102 -0
  86. package/schematics/ng-update/v3/tests/schematic-replace-styles.spec.d.ts +1 -0
  87. package/schematics/ng-update/v3/tests/schematic-replace-styles.spec.js +286 -0
  88. package/schematics/ng-update/v3/tests/schematic-textfield-icon.spec.d.ts +1 -0
  89. package/schematics/ng-update/v3/tests/schematic-textfield-icon.spec.js +141 -0
  90. package/schematics/ng-update/v3/tests/schematic-warnings.spec.d.ts +1 -0
  91. package/schematics/ng-update/v3/tests/schematic-warnings.spec.js +104 -0
  92. package/schematics/ng-update/v3-30/tests/schematic-migrate-icons.spec.d.ts +1 -0
  93. package/schematics/ng-update/v3-30/tests/schematic-migrate-icons.spec.js +87 -0
  94. package/schematics/ng-update/v3-35/tests/schematic-migrate-icons.spec.d.ts +1 -0
  95. package/schematics/ng-update/v3-35/tests/schematic-migrate-icons.spec.js +101 -0
  96. package/schematics/ng-update/v3-36/tests/schematic-migrate-editor.spec.d.ts +1 -0
  97. package/schematics/ng-update/v3-36/tests/schematic-migrate-editor.spec.js +117 -0
  98. package/schematics/ng-update/v3-40/tests/schematic-migrate-textarea.spec.d.ts +1 -0
  99. package/schematics/ng-update/v3-40/tests/schematic-migrate-textarea.spec.js +90 -0
  100. package/schematics/ng-update/v3-5/tests/schematic-migrate-templates.spec.d.ts +1 -0
  101. package/schematics/ng-update/v3-5/tests/schematic-migrate-templates.spec.js +74 -0
  102. package/schematics/ng-update/v4/tests/schematic-migrate-thumbnail-card.spec.d.ts +1 -0
  103. package/schematics/ng-update/v4/tests/schematic-migrate-thumbnail-card.spec.js +72 -0
  104. package/tokens/active-element.d.ts +1 -2
  105. package/tokens/default-renderer.d.ts +2 -2
  106. package/tokens/ensure-base-href.d.ts +1 -2
  107. package/tokens/is-android.d.ts +1 -2
  108. package/tokens/is-apple.d.ts +1 -2
  109. package/tokens/is-chromium.d.ts +1 -2
  110. package/tokens/is-cypress.d.ts +1 -2
  111. package/tokens/is-e2e.d.ts +1 -2
  112. package/tokens/is-firefox.d.ts +1 -2
  113. package/tokens/is-ios.d.ts +1 -2
  114. package/tokens/is-mobile.d.ts +1 -2
  115. package/tokens/is-playwright.d.ts +1 -2
  116. package/tokens/is-stackblitz.d.ts +1 -2
  117. package/tokens/is-webkit.d.ts +1 -2
  118. package/tokens/range.d.ts +1 -2
  119. package/tokens/removed-element.d.ts +1 -3
  120. package/tokens/take-only-trusted-events.d.ts +1 -2
  121. package/tokens/touch-supported.d.ts +1 -2
  122. package/tokens/window-height.d.ts +1 -3
@@ -0,0 +1,380 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ /* eslint-disable rxjs/no-topromise */
5
+ const schematics_1 = require("@angular-devkit/schematics");
6
+ const testing_1 = require("@angular-devkit/schematics/testing");
7
+ const ng_morph_1 = require("ng-morph");
8
+ const path_1 = require("path");
9
+ const create_angular_json_1 = require("../../../utils/create-angular-json");
10
+ const collectionPath = path_1.join(__dirname, `../../../migration.json`);
11
+ const APP_MODULE = `
12
+ import {CommonModule} from '@angular/common';
13
+ import {NgModule} from '@angular/core';
14
+ import {FormsModule} from '@angular/forms';
15
+ import {TuiSliderModule} from '@taiga-ui/kit';
16
+ import {AppComponent} from './app.component';
17
+
18
+ @NgModule({
19
+ imports: [
20
+ CommonModule,
21
+ FormsModule,
22
+ TuiSliderModule
23
+ ],
24
+ declarations: [AppComponent],
25
+ })
26
+ export class AppModule {}
27
+ `;
28
+ const APP_COMPONENT = `
29
+ @Component({templateUrl: './app.template.html'})
30
+ export class AppComponent {
31
+ value = 4;
32
+ }
33
+ `;
34
+ const APP_TEMPLATE = `
35
+ <h1>Title</h1>
36
+ <inline-html-child></inline-html-child>
37
+
38
+ <tui-input-slider [max]="100" [(ngModel)]="value" [min]="0" valueContent="TOP SECRET">
39
+ Usage of the component without deprecated props
40
+ </tui-input-slider>
41
+
42
+ <tui-input-range
43
+ [min]="0"
44
+ [max]="100"
45
+ [leftValueContent]="valueContent"
46
+ [rightValueContent]="valueContent"
47
+ [formControl]="control"
48
+ >
49
+ Desired departure day
50
+ </tui-input-range>
51
+
52
+ <file-html-child></file-html-child>
53
+ <footer>123</footer>
54
+ `;
55
+ /** ___test/file-html-child/*___ */
56
+ const FILE_HTML_CHILD_COMPONENT_BEFORE = `
57
+ @Component({
58
+ selector: 'file-html-child',
59
+ templateUrl: './file-html-child.template.html'
60
+ })
61
+ export class FileHtmlChildComponent {}
62
+ `;
63
+ const FILE_HTML_CHILD_COMPONENT_AFTER = `import { TuiContextWithImplicit } from "@taiga-ui/cdk";
64
+
65
+ @Component({
66
+ selector: 'file-html-child',
67
+ templateUrl: './file-html-child.template.html'
68
+ })
69
+ export class FileHtmlChildComponent {
70
+ tuiMigrationMinMaxLabel(context: TuiContextWithImplicit<number>): string {
71
+ const currentValue = context.$implicit;
72
+ const maxValue = 100; // TODO: (Taiga UI migration) replace with the MAX value of the input
73
+ const maxLabelText = "Max"; // TODO: (Taiga UI migration) replace with the required label
74
+ const minValue = 0; // TODO: (Taiga UI migration) replace with the MIN value of the input
75
+ const minLabelText = "Min"; // TODO: (Taiga UI migration) replace with the required label
76
+ if (currentValue === maxValue) return maxLabelText;
77
+ if (currentValue === minValue) return minLabelText;
78
+ return String(currentValue);
79
+ }
80
+
81
+ tuiMigrationInputRangeMinLabel(context: TuiContextWithImplicit<number>): string {
82
+ const currentValue = context.$implicit;
83
+ const minValue = 0; // TODO: (Taiga UI migration) replace with the MIN value of the input-range
84
+ const minLabelText = "Min"; // TODO: (Taiga UI migration) replace with the required label
85
+ if (currentValue === minValue) return minLabelText;
86
+ return String(currentValue);
87
+ }
88
+
89
+ tuiMigrationInputRangeMaxLabel(context: TuiContextWithImplicit<number>): string {
90
+ const currentValue = context.$implicit;
91
+ const maxValue = 100; // TODO: (Taiga UI migration) replace with the MAX value of the input
92
+ const maxLabelText = "Max"; // TODO: (Taiga UI migration) replace with the required label
93
+ if (currentValue === maxValue) return maxLabelText;
94
+ return String(currentValue);
95
+ }
96
+ }
97
+ `;
98
+ const FILE_HTML_CHILD_TEMPLATE_BEFORE = `
99
+ <tui-input-slider
100
+ tuiHintContent="Select the answer to see how the right custom content changes"
101
+ maxLabel="MAX(string property)"
102
+ minLabel="MIN(string property)"
103
+ class="control"
104
+ [min]="0"
105
+ [max]="10"
106
+ [secondary]="userAnswer === 4 ? 'right' : 'wrong'"
107
+ [pluralize]="pluralForms"
108
+ [segmentsPluralize]="pluralForms"
109
+ [(ngModel)]="userAnswer"
110
+ >
111
+ 2+2=?
112
+ </tui-input-slider>
113
+
114
+ <tui-input-range
115
+ new
116
+ [min]="0"
117
+ [max]="100"
118
+ [segments]="5"
119
+ [steps]="5"
120
+ [size]="size"
121
+ [maxLabel]="Maxxxxx"
122
+ minLabel="min!!!"
123
+ [formControl]="control"
124
+ [segmentsPluralize]="someVariable"
125
+ >
126
+ Select volume range
127
+ </tui-input-range>
128
+
129
+ <tui-slider [min]="100" [max]="1000" size="m" [segments]="5" [quantum]="0.01"></tui-slider>
130
+ `;
131
+ const FILE_HTML_CHILD_TEMPLATE_AFTER = `
132
+ <!-- TODO: (Taiga UI migration) [pluralize] => Use [postfix] instead. See https://taiga-ui.dev/components/input-slider/API?postfix=apples -->
133
+ <!-- TODO: (Taiga UI migration) See examples how create labels for ticks without this property (outside the component): https://taiga-ui.dev/components/input-slider#slider-segments -->
134
+ <tui-input-slider
135
+ tuiHintContent="Select the answer to see how the right custom content changes"
136
+ [valueContent]="tuiMigrationMinMaxLabel"
137
+ ${``}
138
+ class="control"
139
+ [min]="0"
140
+ [max]="10"
141
+ [tuiTextfieldCustomContent]="userAnswer === 4 ? 'right' : 'wrong'"
142
+ [pluralize]="pluralForms"
143
+ [segmentsPluralize]="pluralForms"
144
+ [(ngModel)]="userAnswer"
145
+ >
146
+ 2+2=?
147
+ </tui-input-slider>
148
+
149
+ <!-- TODO: (Taiga UI migration) See examples how create labels for ticks without this property (outside the component): https://taiga-ui.dev/components/input-range#segments -->
150
+ <tui-input-range
151
+ ${``}
152
+ [min]="0"
153
+ [max]="100"
154
+ [segments]="5"
155
+ [steps]="5"
156
+ [tuiTextfieldSize]="size"
157
+ [rightValueContent]="tuiMigrationInputRangeMaxLabel"
158
+ [leftValueContent]="tuiMigrationInputRangeMinLabel"
159
+ [formControl]="control"
160
+ [segmentsPluralize]="someVariable"
161
+ >
162
+ Select volume range
163
+ </tui-input-range>
164
+
165
+ <input tuiSlider type="range" [min]="100" [max]="1000" size="m" [segments]="5" [step]="0.01"></input>
166
+ `;
167
+ const FILE_HTML_CHILD_MODULE_BEFORE = `
168
+ import {CommonModule} from '@angular/common';
169
+ import {NgModule} from '@angular/core';
170
+ import {TuiButtonModule, TuiLinkModule} from '@taiga-ui/core';
171
+ import {TuiSliderModule} from '@taiga-ui/kit';
172
+
173
+ import {TuiMediaExample1} from './examples/1';
174
+ import {FileHtmlChildComponent} from './file-html-child.component';
175
+ import {ExampleTuiMediaComponent} from './media.component';
176
+
177
+ @NgModule({
178
+ imports: [
179
+ CommonModule,
180
+ TuiButtonModule,
181
+ TuiSliderModule,
182
+ TuiLinkModule,
183
+ ],
184
+ declarations: [
185
+ ExampleTuiMediaComponent,
186
+ FileHtmlChildComponent,
187
+ TuiMediaExample1,
188
+ ],
189
+ exports: [ExampleTuiMediaComponent],
190
+ })
191
+ export class ExampleTuiMediaModule {}
192
+ `;
193
+ const FILE_HTML_CHILD_MODULE_AFTER = `
194
+ import {CommonModule} from '@angular/common';
195
+ import {NgModule} from '@angular/core';
196
+ import { TuiButtonModule, TuiLinkModule, TuiTextfieldControllerModule } from '@taiga-ui/core';
197
+ import {TuiSliderModule} from '@taiga-ui/kit';
198
+
199
+ import {TuiMediaExample1} from './examples/1';
200
+ import {FileHtmlChildComponent} from './file-html-child.component';
201
+ import {ExampleTuiMediaComponent} from './media.component';
202
+
203
+ @NgModule({
204
+ imports: [
205
+ CommonModule,
206
+ TuiButtonModule,
207
+ TuiSliderModule,
208
+ TuiLinkModule,
209
+ TuiTextfieldControllerModule
210
+ ],
211
+ declarations: [
212
+ ExampleTuiMediaComponent,
213
+ FileHtmlChildComponent,
214
+ TuiMediaExample1,
215
+ ],
216
+ exports: [ExampleTuiMediaComponent],
217
+ })
218
+ export class ExampleTuiMediaModule {}
219
+ `;
220
+ const DUMMY_MODULE = `
221
+ import {NgModule} from '@angular/core';
222
+ import {RouterModule} from '@angular/router';
223
+ import {TuiDocCodeModule} from '@taiga-ui/addon-doc';
224
+ import {TuiSliderModule} from '@taiga-ui/kit';
225
+ import {TuiLinkModule, TuiNotificationModule} from '@taiga-ui/core';
226
+
227
+ import {HomeComponent} from './home.component';
228
+
229
+ @NgModule({
230
+ imports: [RouterModule, TuiDocCodeModule, TuiSliderModule, TuiNotificationModule, TuiLinkModule],
231
+ entryComponents: [HomeComponent],
232
+ declarations: [HomeComponent],
233
+ exports: [HomeComponent],
234
+ })
235
+ export class HomeModule {}
236
+ `;
237
+ /** ___test/inline-html-child/*___ */
238
+ const INLINE_HTML_CHILD_MODULE_BEFORE = `
239
+ import {NgModule} from '@angular/core';
240
+ import {FormsModule} from '@angular/forms';
241
+ import {TuiHintModule} from '@taiga-ui/core';
242
+ import {TuiSliderModule} from '@taiga-ui/kit';
243
+ import {InlineHtmlChildComponent} from './inline-html-child.component';
244
+
245
+ @NgModule({
246
+ imports: [FormsModule, TuiSliderModule, TuiHintModule],
247
+ declarations: [InlineHtmlChildComponent]
248
+ })
249
+ export class ChildModule {}
250
+ `;
251
+ const INLINE_HTML_CHILD_MODULE_AFTER = `
252
+ import {NgModule} from '@angular/core';
253
+ import {FormsModule} from '@angular/forms';
254
+ import { TuiHintModule, TuiTextfieldControllerModule } from '@taiga-ui/core';
255
+ import {TuiSliderModule} from '@taiga-ui/kit';
256
+ import {InlineHtmlChildComponent} from './inline-html-child.component';
257
+
258
+ @NgModule({
259
+ imports: [FormsModule, TuiSliderModule, TuiHintModule, TuiTextfieldControllerModule],
260
+ declarations: [InlineHtmlChildComponent]
261
+ })
262
+ export class ChildModule {}
263
+ `;
264
+ const INLINE_HTML_CHILD_COMPONENT_BEFORE = `
265
+ @Component({
266
+ selector: 'inline-html-child',
267
+ template: '<tui-input-slider new secondary="123" size="m" [maxLabel]="maxLabel"></tui-input-slider>'
268
+ })
269
+ export class InlineHtmlChildComponent {
270
+ readonly maxLabel = 'MAX (property binding)';
271
+ }
272
+ `;
273
+ const INLINE_HTML_CHILD_COMPONENT_AFTER = `import { TuiContextWithImplicit } from "@taiga-ui/cdk";
274
+
275
+ @Component({
276
+ selector: 'inline-html-child',
277
+ template: '<tui-input-slider tuiTextfieldCustomContent="123" tuiTextfieldSize="m" [valueContent]="tuiMigrationMinMaxLabel"></tui-input-slider>'
278
+ })
279
+ export class InlineHtmlChildComponent {
280
+ readonly maxLabel = 'MAX (property binding)';
281
+
282
+ tuiMigrationMinMaxLabel(context: TuiContextWithImplicit<number>): string {
283
+ const currentValue = context.$implicit;
284
+ const maxValue = 100; // TODO: (Taiga UI migration) replace with the MAX value of the input
285
+ const maxLabelText = "Max"; // TODO: (Taiga UI migration) replace with the required label
286
+ const minValue = 0; // TODO: (Taiga UI migration) replace with the MIN value of the input
287
+ const minLabelText = "Min"; // TODO: (Taiga UI migration) replace with the required label
288
+ if (currentValue === maxValue) return maxLabelText;
289
+ if (currentValue === minValue) return minLabelText;
290
+ return String(currentValue);
291
+ }
292
+ }
293
+ `;
294
+ describe(`ng-update`, () => {
295
+ let host;
296
+ let runner;
297
+ beforeEach(() => {
298
+ host = new testing_1.UnitTestTree(new schematics_1.HostTree());
299
+ runner = new testing_1.SchematicTestRunner(`schematics`, collectionPath);
300
+ ng_morph_1.setActiveProject(ng_morph_1.createProject(host));
301
+ createMainFiles();
302
+ ng_morph_1.saveActiveProject();
303
+ });
304
+ describe(`no deprecations inside AppComponent`, () => {
305
+ it(`no imports of the new module inside app.module.ts`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
306
+ const tree = yield runner
307
+ .runSchematicAsync(`updateToV3`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
308
+ .toPromise();
309
+ expect(tree.readContent(`test/app/app.module.ts`)).toBe(APP_MODULE);
310
+ }));
311
+ it(`no changes in app.template.ts`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
312
+ const tree = yield runner
313
+ .runSchematicAsync(`updateToV3`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
314
+ .toPromise();
315
+ expect(tree.readContent(`test/app/app.template.html`)).toBe(APP_TEMPLATE);
316
+ }));
317
+ it(`no changes in app.component.ts`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
318
+ const tree = yield runner
319
+ .runSchematicAsync(`updateToV3`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
320
+ .toPromise();
321
+ expect(tree.readContent(`test/app/app.component.ts`)).toBe(APP_COMPONENT);
322
+ }));
323
+ });
324
+ describe(`component with a inline html template`, () => {
325
+ it(`adds TuiTextfieldControllerModule to the required module`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
326
+ const tree = yield runner
327
+ .runSchematicAsync(`updateToV3`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
328
+ .toPromise();
329
+ expect(tree.readContent(`test/inline-html-child/inline-html-child.module.ts`)).toBe(INLINE_HTML_CHILD_MODULE_AFTER);
330
+ }));
331
+ it(`replace deprecated attributes inside inline template (+ adds required class-methods)`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
332
+ const tree = yield runner
333
+ .runSchematicAsync(`updateToV3`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
334
+ .toPromise();
335
+ expect(tree.readContent(`test/inline-html-child/inline-html-child.component.ts`)).toEqual(INLINE_HTML_CHILD_COMPONENT_AFTER);
336
+ }));
337
+ });
338
+ describe(`component with a separate html-file template`, () => {
339
+ it(`replace deprecated attributes inside templates`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
340
+ const tree = yield runner
341
+ .runSchematicAsync(`updateToV3`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
342
+ .toPromise();
343
+ expect(tree.readContent(`test/file-html-child/file-html-child.template.html`)).toEqual(FILE_HTML_CHILD_TEMPLATE_AFTER);
344
+ }));
345
+ it(`adds required properties inside file-html-child.component.ts`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
346
+ const tree = yield runner
347
+ .runSchematicAsync(`updateToV3`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
348
+ .toPromise();
349
+ expect(tree.readContent(`test/file-html-child/file-html-child.component.ts`)).toBe(FILE_HTML_CHILD_COMPONENT_AFTER);
350
+ }));
351
+ it(`adds TuiTextfieldControllerModule to the required module`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
352
+ const tree = yield runner
353
+ .runSchematicAsync(`updateToV3`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
354
+ .toPromise();
355
+ expect(tree.readContent(`test/file-html-child/file-html-child.module.ts`)).toBe(FILE_HTML_CHILD_MODULE_AFTER);
356
+ }));
357
+ it(`does not add any imports in dummy.module.ts`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
358
+ const tree = yield runner
359
+ .runSchematicAsync(`updateToV3`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
360
+ .toPromise();
361
+ expect(tree.readContent(`test/file-html-child/dummy.module.ts`)).toBe(DUMMY_MODULE);
362
+ }));
363
+ });
364
+ afterEach(() => {
365
+ ng_morph_1.resetActiveProject();
366
+ });
367
+ });
368
+ function createMainFiles() {
369
+ ng_morph_1.createSourceFile(`test/app/app.module.ts`, APP_MODULE);
370
+ ng_morph_1.createSourceFile(`test/app/app.component.ts`, APP_COMPONENT);
371
+ ng_morph_1.createSourceFile(`test/app/app.template.html`, APP_TEMPLATE);
372
+ ng_morph_1.createSourceFile(`test/file-html-child/dummy.module.ts`, DUMMY_MODULE);
373
+ ng_morph_1.createSourceFile(`test/file-html-child/file-html-child.module.ts`, FILE_HTML_CHILD_MODULE_BEFORE);
374
+ ng_morph_1.createSourceFile(`test/file-html-child/file-html-child.component.ts`, FILE_HTML_CHILD_COMPONENT_BEFORE);
375
+ ng_morph_1.createSourceFile(`test/file-html-child/file-html-child.template.html`, FILE_HTML_CHILD_TEMPLATE_BEFORE);
376
+ ng_morph_1.createSourceFile(`test/inline-html-child/inline-html-child.module.ts`, INLINE_HTML_CHILD_MODULE_BEFORE);
377
+ ng_morph_1.createSourceFile(`test/inline-html-child/inline-html-child.component.ts`, INLINE_HTML_CHILD_COMPONENT_BEFORE);
378
+ create_angular_json_1.createAngularJson();
379
+ ng_morph_1.createSourceFile(`package.json`, `{"dependencies": {"@angular/core": "~13.0.0"}}`);
380
+ }
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ /* eslint-disable rxjs/no-topromise */
5
+ const schematics_1 = require("@angular-devkit/schematics");
6
+ const testing_1 = require("@angular-devkit/schematics/testing");
7
+ const ng_morph_1 = require("ng-morph");
8
+ const path_1 = require("path");
9
+ const versions_1 = require("../../../ng-add/constants/versions");
10
+ const collectionPath = path_1.join(__dirname, `../../../migration.json`);
11
+ describe(`ng-update angular.json`, () => {
12
+ let host;
13
+ let runner;
14
+ beforeEach(() => {
15
+ host = new testing_1.UnitTestTree(new schematics_1.HostTree());
16
+ runner = new testing_1.SchematicTestRunner(`schematics`, collectionPath);
17
+ });
18
+ it(`include @taiga-ui/proprietary-icons inside a package.json`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
19
+ ng_morph_1.setActiveProject(ng_morph_1.createProject(host));
20
+ ng_morph_1.createSourceFile(`package.json`, `{"dependencies": {"@angular/core": "~13.0.0", "@taiga-ui/proprietary-icons": "${versions_1.TAIGA_VERSION}"}}`, { overwrite: true });
21
+ ng_morph_1.createSourceFile(`angular.json`, makeAngularJsonWithAssets(`
22
+ {
23
+ "glob": "**/*",
24
+ "input": "node_modules/@taiga-ui/proprietary-icons/src",
25
+ "output": "assets/taiga-ui/icons"
26
+ }`));
27
+ ng_morph_1.saveActiveProject();
28
+ const tree = yield runner
29
+ .runSchematicAsync(`updateToV3`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
30
+ .toPromise();
31
+ expect(tree.readContent(`angular.json`)).toEqual(makeAngularJsonWithAssets(`
32
+ {
33
+ "glob": "**/*",
34
+ "input": "node_modules/@taiga-ui/proprietary-icons/src",
35
+ "output": "assets/taiga-ui/icons"
36
+ },
37
+ {
38
+ "glob": "**/*",
39
+ "input": "node_modules/@taiga-ui/proprietary-tds-icons/src",
40
+ "output": "assets/taiga-ui/icons"
41
+ }`));
42
+ }));
43
+ it(`it included proprietary-tds-icons now`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
44
+ ng_morph_1.setActiveProject(ng_morph_1.createProject(host));
45
+ ng_morph_1.createSourceFile(`package.json`, `{"dependencies": {"@angular/core": "~13.0.0", "@taiga-ui/proprietary-icons": "${versions_1.TAIGA_VERSION}"}}`);
46
+ ng_morph_1.createSourceFile(`angular.json`, makeAngularJsonWithAssets(`
47
+ {
48
+ "glob": "**/*",
49
+ "input": "node_modules/@taiga-ui/proprietary-tds-icons/src",
50
+ "output": "assets/taiga-ui/icons"
51
+ },
52
+ {
53
+ "glob": "**/*",
54
+ "input": "node_modules/@taiga-ui/proprietary-icons/src",
55
+ "output": "assets/taiga-ui/icons"
56
+ }`));
57
+ ng_morph_1.saveActiveProject();
58
+ const tree = yield runner
59
+ .runSchematicAsync(`updateToV3`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
60
+ .toPromise();
61
+ expect(tree.readContent(`angular.json`)).toEqual(makeAngularJsonWithAssets(`
62
+ {
63
+ "glob": "**/*",
64
+ "input": "node_modules/@taiga-ui/proprietary-tds-icons/src",
65
+ "output": "assets/taiga-ui/icons"
66
+ },
67
+ {
68
+ "glob": "**/*",
69
+ "input": "node_modules/@taiga-ui/proprietary-icons/src",
70
+ "output": "assets/taiga-ui/icons"
71
+ }`));
72
+ }));
73
+ it(`doesn't include @taiga-ui/proprietary-icons inside a package.json`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
74
+ ng_morph_1.setActiveProject(ng_morph_1.createProject(host));
75
+ ng_morph_1.createSourceFile(`package.json`, `{"dependencies": {"@angular/core": "~13.0.0"}}`);
76
+ ng_morph_1.createSourceFile(`angular.json`, makeAngularJsonWithAssets(`
77
+ {
78
+ "glob": "**/*",
79
+ "input": "node_modules/@taiga-ui/proprietary-icons/src",
80
+ "output": "assets/taiga-ui/icons"
81
+ }`));
82
+ ng_morph_1.saveActiveProject();
83
+ const tree = yield runner
84
+ .runSchematicAsync(`updateToV3`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
85
+ .toPromise();
86
+ expect(tree.readContent(`angular.json`)).toEqual(makeAngularJsonWithAssets(`
87
+ {
88
+ "glob": "**/*",
89
+ "input": "node_modules/@taiga-ui/proprietary-icons/src",
90
+ "output": "assets/taiga-ui/icons"
91
+ }`));
92
+ }));
93
+ afterEach(() => ng_morph_1.resetActiveProject());
94
+ });
95
+ function makeAngularJsonWithAssets(assets) {
96
+ return `
97
+ {
98
+ "version": 1,
99
+ "defaultProject": "demo",
100
+ "projects": {
101
+ "demo": {
102
+ "architect": {
103
+ "build": {
104
+ "options": {
105
+ "main": "test/main.ts",
106
+ "styles": [
107
+ "node_modules/@taiga-ui/core/styles/taiga-ui-fonts.less",
108
+ "node_modules/@taiga-ui/styles/taiga-ui-global.less",
109
+ "some.style"
110
+ ],
111
+ "assets": [${assets}
112
+ ]
113
+ }
114
+ }
115
+ }
116
+ }
117
+ }
118
+ }`;
119
+ }
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ /* eslint-disable rxjs/no-topromise */
5
+ const schematics_1 = require("@angular-devkit/schematics");
6
+ const testing_1 = require("@angular-devkit/schematics/testing");
7
+ const ng_morph_1 = require("ng-morph");
8
+ const path_1 = require("path");
9
+ const create_angular_json_1 = require("../../../utils/create-angular-json");
10
+ const collectionPath = path_1.join(__dirname, `../../../migration.json`);
11
+ const COMPONENT_WITH_TEMPLATE_URL = `
12
+ @Component({templateUrl: './test.template.html'})
13
+ export class TestComponent {}
14
+ `;
15
+ const TEMPLATE_BEFORE = `
16
+ <tui-input
17
+ tuiTextfieldSize="s"
18
+ formControlName="testValue"
19
+ tuiTextfieldExampleText="Test"
20
+ >
21
+ Type an email
22
+ </tui-input>
23
+
24
+ <tui-text-area
25
+ formControlName="testValue1"
26
+ tuiHintContent="it's just a joke"
27
+ [expandable]="true"
28
+ [tuiTextfieldMaxLength]="maxLength"
29
+ [tuiTextfieldLabelOutside]="true"
30
+ >
31
+ Type it
32
+ </tui-text-area>
33
+
34
+ <tui-input-count
35
+ formControlName="testValue1"
36
+ tuiTextfieldAutocomplete="off"
37
+ tuiTextfieldInputMode="numeric"
38
+ [min]="1"
39
+ [max]="200"
40
+ [tuiTextfieldMaxLength]="maxLength"
41
+ >
42
+ Count something
43
+ <input
44
+ tuiTextfield
45
+ placeholder="1.. 2.. 3.."
46
+ />
47
+ </tui-input-count>
48
+
49
+ <div
50
+ polymorpheus-outlet
51
+ [content]="content"
52
+ [context]="context"
53
+ ></div>
54
+ `;
55
+ const TEMPLATE_AFTER = `
56
+ <tui-input
57
+ tuiTextfieldSize="s"
58
+ formControlName="testValue"
59
+ ${``}
60
+ >
61
+ Type an email
62
+ <input tuiTextfield placeholder="Test"/> </tui-input>
63
+
64
+ <tui-text-area
65
+ formControlName="testValue1"
66
+ tuiHintContent="it's just a joke"
67
+ [expandable]="true"
68
+ [maxLength]="maxLength"
69
+ [tuiTextfieldLabelOutside]="true"
70
+ >
71
+ Type it
72
+ </tui-text-area>
73
+
74
+ <tui-input-count
75
+ formControlName="testValue1"
76
+ ${``}
77
+ ${``}
78
+ [min]="1"
79
+ [max]="200"
80
+ ${``}
81
+ >
82
+ Count something
83
+ <input
84
+ tuiTextfield autocomplete="off" inputmode="numeric" [attr.maxlength]="maxLength"
85
+ placeholder="1.. 2.. 3.."
86
+ />
87
+ </tui-input-count>
88
+
89
+ <div
90
+ ${``}
91
+ ${``}
92
+ ${``}
93
+ >
94
+ <ng-container *polymorpheusOutlet="content as text; context: context">
95
+ {{ text }}
96
+ </ng-container></div>
97
+ `;
98
+ describe(`ng-update (flat file structure)`, () => {
99
+ let host;
100
+ let runner;
101
+ beforeEach(() => {
102
+ host = new testing_1.UnitTestTree(new schematics_1.HostTree());
103
+ runner = new testing_1.SchematicTestRunner(`schematics`, collectionPath);
104
+ ng_morph_1.setActiveProject(ng_morph_1.createProject(host));
105
+ createMainFiles();
106
+ ng_morph_1.saveActiveProject();
107
+ });
108
+ it(`should migrate textfields`, () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
109
+ const tree = yield runner
110
+ .runSchematicAsync(`updateToV3`, { 'skip-logs': process.env[`TUI_CI`] === `true` }, host)
111
+ .toPromise();
112
+ expect(tree.readContent(`test.template.html`)).toEqual(TEMPLATE_AFTER);
113
+ }));
114
+ afterEach(() => {
115
+ ng_morph_1.resetActiveProject();
116
+ });
117
+ });
118
+ function createMainFiles() {
119
+ ng_morph_1.createSourceFile(`test.component.ts`, COMPONENT_WITH_TEMPLATE_URL);
120
+ ng_morph_1.createSourceFile(`test.template.html`, TEMPLATE_BEFORE);
121
+ create_angular_json_1.createAngularJson();
122
+ ng_morph_1.createSourceFile(`package.json`, `{"dependencies": {"@angular/core": "~13.0.0"}}`);
123
+ }