@taiga-ui/cdk 3.54.0 → 3.55.0-canary.6883895

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 (125) hide show
  1. package/bundles/taiga-ui-cdk-components-dialog-host.umd.js +2 -2
  2. package/bundles/taiga-ui-cdk-components-dialog-host.umd.js.map +1 -1
  3. package/bundles/taiga-ui-cdk-components-scroll-controls.umd.js +10 -10
  4. package/bundles/taiga-ui-cdk-components-scroll-controls.umd.js.map +1 -1
  5. package/bundles/taiga-ui-cdk-constants.umd.js +14 -14
  6. package/bundles/taiga-ui-cdk-constants.umd.js.map +1 -1
  7. package/bundles/taiga-ui-cdk-date-time.umd.js +2 -4
  8. package/bundles/taiga-ui-cdk-date-time.umd.js.map +1 -1
  9. package/bundles/taiga-ui-cdk-decorators.umd.js +12 -12
  10. package/bundles/taiga-ui-cdk-decorators.umd.js.map +1 -1
  11. package/bundles/taiga-ui-cdk-directives-auto-focus.umd.js +4 -16
  12. package/bundles/taiga-ui-cdk-directives-auto-focus.umd.js.map +1 -1
  13. package/bundles/taiga-ui-cdk-directives-focus-trap.umd.js +1 -4
  14. package/bundles/taiga-ui-cdk-directives-focus-trap.umd.js.map +1 -1
  15. package/bundles/taiga-ui-cdk-directives-media.umd.js +1 -2
  16. package/bundles/taiga-ui-cdk-directives-media.umd.js.map +1 -1
  17. package/bundles/taiga-ui-cdk-directives-platform.umd.js +4 -1
  18. package/bundles/taiga-ui-cdk-directives-platform.umd.js.map +1 -1
  19. package/bundles/taiga-ui-cdk-services.umd.js +10 -10
  20. package/bundles/taiga-ui-cdk-services.umd.js.map +1 -1
  21. package/bundles/taiga-ui-cdk-tokens.umd.js +23 -23
  22. package/bundles/taiga-ui-cdk-tokens.umd.js.map +1 -1
  23. package/bundles/taiga-ui-cdk-utils-color.umd.js +12 -12
  24. package/bundles/taiga-ui-cdk-utils-color.umd.js.map +1 -1
  25. package/bundles/taiga-ui-cdk-utils-dom.umd.js +5 -5
  26. package/bundles/taiga-ui-cdk-utils-dom.umd.js.map +1 -1
  27. package/bundles/taiga-ui-cdk-utils-math.umd.js +16 -16
  28. package/bundles/taiga-ui-cdk-utils-math.umd.js.map +1 -1
  29. package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.js +3 -3
  30. package/bundles/taiga-ui-cdk-utils-miscellaneous.umd.js.map +1 -1
  31. package/bundles/taiga-ui-cdk-utils-svg.umd.js +33 -24
  32. package/bundles/taiga-ui-cdk-utils-svg.umd.js.map +1 -1
  33. package/constants/used-icons.d.ts +1 -1
  34. package/constants/version.d.ts +1 -1
  35. package/constants/version.js +1 -1
  36. package/esm2015/components/dialog-host/dialog-host.component.js +3 -3
  37. package/esm2015/components/scroll-controls/scrollbar.directive.js +7 -7
  38. package/esm2015/constants/empty.js +9 -9
  39. package/esm2015/constants/matcher.js +4 -4
  40. package/esm2015/constants/used-icons.js +3 -3
  41. package/esm2015/constants/version.js +2 -2
  42. package/esm2015/date-time/day-range.js +2 -4
  43. package/esm2015/date-time/day.js +2 -2
  44. package/esm2015/decorators/default-prop.js +10 -10
  45. package/esm2015/decorators/required-setter.js +4 -4
  46. package/esm2015/directives/auto-focus/autofocus.options.js +1 -2
  47. package/esm2015/directives/auto-focus/handlers/ios.handler.js +3 -4
  48. package/esm2015/directives/focus-trap/focus-trap.directive.js +2 -5
  49. package/esm2015/directives/media/media.directive.js +2 -3
  50. package/esm2015/directives/platform/platform.directive.js +6 -3
  51. package/esm2015/services/scroll.service.js +11 -11
  52. package/esm2015/tokens/active-element.js +14 -14
  53. package/esm2015/utils/color/hex-to-rgba.js +9 -9
  54. package/esm2015/utils/color/hsv-to-rgb.js +5 -5
  55. package/esm2015/utils/dom/can-scroll.js +6 -6
  56. package/esm2015/utils/math/round.js +13 -13
  57. package/esm2015/utils/miscellaneous/clean-object.js +4 -4
  58. package/esm2015/utils/svg/svg-linear-gradient-processor.js +34 -25
  59. package/fesm2015/taiga-ui-cdk-components-dialog-host.js +2 -2
  60. package/fesm2015/taiga-ui-cdk-components-dialog-host.js.map +1 -1
  61. package/fesm2015/taiga-ui-cdk-components-scroll-controls.js +6 -6
  62. package/fesm2015/taiga-ui-cdk-components-scroll-controls.js.map +1 -1
  63. package/fesm2015/taiga-ui-cdk-constants.js +14 -14
  64. package/fesm2015/taiga-ui-cdk-constants.js.map +1 -1
  65. package/fesm2015/taiga-ui-cdk-date-time.js +2 -4
  66. package/fesm2015/taiga-ui-cdk-date-time.js.map +1 -1
  67. package/fesm2015/taiga-ui-cdk-decorators.js +12 -12
  68. package/fesm2015/taiga-ui-cdk-decorators.js.map +1 -1
  69. package/fesm2015/taiga-ui-cdk-directives-auto-focus.js +2 -3
  70. package/fesm2015/taiga-ui-cdk-directives-auto-focus.js.map +1 -1
  71. package/fesm2015/taiga-ui-cdk-directives-focus-trap.js +1 -4
  72. package/fesm2015/taiga-ui-cdk-directives-focus-trap.js.map +1 -1
  73. package/fesm2015/taiga-ui-cdk-directives-media.js +1 -2
  74. package/fesm2015/taiga-ui-cdk-directives-media.js.map +1 -1
  75. package/fesm2015/taiga-ui-cdk-directives-platform.js +5 -2
  76. package/fesm2015/taiga-ui-cdk-directives-platform.js.map +1 -1
  77. package/fesm2015/taiga-ui-cdk-services.js +10 -10
  78. package/fesm2015/taiga-ui-cdk-services.js.map +1 -1
  79. package/fesm2015/taiga-ui-cdk-tokens.js +15 -15
  80. package/fesm2015/taiga-ui-cdk-tokens.js.map +1 -1
  81. package/fesm2015/taiga-ui-cdk-utils-color.js +12 -12
  82. package/fesm2015/taiga-ui-cdk-utils-color.js.map +1 -1
  83. package/fesm2015/taiga-ui-cdk-utils-dom.js +5 -5
  84. package/fesm2015/taiga-ui-cdk-utils-dom.js.map +1 -1
  85. package/fesm2015/taiga-ui-cdk-utils-math.js +12 -12
  86. package/fesm2015/taiga-ui-cdk-utils-math.js.map +1 -1
  87. package/fesm2015/taiga-ui-cdk-utils-miscellaneous.js +3 -3
  88. package/fesm2015/taiga-ui-cdk-utils-miscellaneous.js.map +1 -1
  89. package/fesm2015/taiga-ui-cdk-utils-svg.js +33 -24
  90. package/fesm2015/taiga-ui-cdk-utils-svg.js.map +1 -1
  91. package/package.json +69 -68
  92. package/schematics/ng-add/index.js +10 -10
  93. package/schematics/ng-add/steps/add-taiga-modules.js +36 -36
  94. package/schematics/ng-add/steps/wrap-with-tui-root.js +21 -21
  95. package/schematics/ng-update/steps/rename-types.js +8 -8
  96. package/schematics/ng-update/steps/replace-enums.js +8 -8
  97. package/schematics/ng-update/steps/replace-services.js +8 -8
  98. package/schematics/ng-update/steps/show-warnings.js +4 -4
  99. package/schematics/ng-update/utils/templates/template-comments.d.ts +1 -2
  100. package/schematics/ng-update/v3/index.js +17 -17
  101. package/schematics/ng-update/v3/steps/migrate-date-time.js +92 -92
  102. package/schematics/ng-update/v3/steps/migrate-polymorpheus.js +35 -35
  103. package/schematics/ng-update/v3/steps/migrate-progress.d.ts +4 -0
  104. package/schematics/ng-update/v3/steps/migrate-progress.js +20 -20
  105. package/schematics/ng-update/v3/steps/migrate-sliders/migrate-input-range.js +44 -46
  106. package/schematics/ng-update/v3/steps/migrate-sliders/migrate-input-slider.js +28 -29
  107. package/schematics/ng-update/v3/steps/migrate-templates.js +37 -36
  108. package/schematics/ng-update/v3/steps/migrate-textfield-controller.js +21 -21
  109. package/schematics/ng-update/v3/steps/miscellaneous.js +32 -32
  110. package/schematics/ng-update/v3/steps/replace-functions.js +18 -18
  111. package/schematics/ng-update/v3-30/index.js +3 -4
  112. package/schematics/ng-update/v3-35/index.js +3 -4
  113. package/schematics/ng-update/v3-36/index.js +0 -1
  114. package/schematics/ng-update/v3-40/index.js +11 -13
  115. package/schematics/ng-update/v3-5/index.js +0 -1
  116. package/schematics/ng-update/v3-5/steps/migrate-expand-templates.js +17 -17
  117. package/schematics/ng-update/v4/index.js +12 -12
  118. package/schematics/ng-update/v4/steps/migrate-templates.js +3 -3
  119. package/schematics/ng-update/v4/steps/restore-tui-mapper.js +6 -6
  120. package/schematics/ng-update/v4/steps/restore-tui-matcher.js +6 -6
  121. package/schematics/ng-update/v4/steps/templates/migrate-avatar.js +24 -24
  122. package/schematics/ng-update/v4/steps/utils/replace-substrings.js +2 -2
  123. package/schematics/utils/angular-json-manipulations.js +8 -9
  124. package/schematics/utils/templates/get-component-templates.js +8 -8
  125. package/utils/svg/svg-linear-gradient-processor.d.ts +6 -1
@@ -7,98 +7,6 @@ const colored_log_1 = require("../../../utils/colored-log");
7
7
  const get_execution_time_1 = require("../../../utils/get-execution-time");
8
8
  const get_named_import_references_1 = require("../../../utils/get-named-import-references");
9
9
  const insert_todo_1 = require("../../../utils/insert-todo");
10
- function dateTimeMigrations(options) {
11
- !options[`skip-logs`] &&
12
- colored_log_1.infoLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} migrating taiga date/time...`);
13
- let start = perf_hooks_1.performance.now();
14
- migrateProperty({
15
- namedImport: `TuiDay`,
16
- moduleSpecifier: `@taiga-ui/cdk`,
17
- from: `formattedDay`,
18
- callback: node => node.replaceWithText(node.getText().replace(`formattedDay`, `getFormattedDay("DMY", ".")`)),
19
- });
20
- !options[`skip-logs`] &&
21
- colored_log_1.processLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.PROCESSING_SYMBOL}TuiDay.formattedDay ` +
22
- `(${get_execution_time_1.getExecutionTime(start, perf_hooks_1.performance.now())})`);
23
- start = perf_hooks_1.performance.now();
24
- migrateProperty({
25
- namedImport: `TuiDayRange`,
26
- moduleSpecifier: `@taiga-ui/cdk`,
27
- from: `formattedDayRange`,
28
- callback: node => node.replaceWithText(node
29
- .getText()
30
- .replace(`formattedDayRange`, `getFormattedDayRange("DMY", ".")`)),
31
- });
32
- !options[`skip-logs`] &&
33
- colored_log_1.processLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.PROCESSING_SYMBOL}TuiDayRange.formattedDayRange ` +
34
- `(${get_execution_time_1.getExecutionTime(start, perf_hooks_1.performance.now())})`);
35
- start = perf_hooks_1.performance.now();
36
- migrateProperty({
37
- namedImport: `TuiDayRange`,
38
- moduleSpecifier: `@taiga-ui/cdk`,
39
- from: `normalizeParse`,
40
- callback: node => {
41
- const parent = node.getParent();
42
- if (ng_morph_1.Node.isCallExpression(parent)) {
43
- changeNormalizeArgs(parent);
44
- }
45
- },
46
- });
47
- !options[`skip-logs`] &&
48
- colored_log_1.processLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.PROCESSING_SYMBOL}TuiDayRange.normalizeParse ` +
49
- `(${get_execution_time_1.getExecutionTime(start, perf_hooks_1.performance.now())})`);
50
- [
51
- {
52
- namedImport: `TuiMonthRange`,
53
- field: `formattedMonthRange`,
54
- message: `formattedMonthRange has been removed in 3.0. Please use TUI_MONTH_FORMATTER from @taiga-ui/kit`,
55
- },
56
- {
57
- namedImport: `TuiMonth`,
58
- field: `formattedMonth`,
59
- message: `formattedMonth has been removed in 3.0. Please use TUI_MONTH_FORMATTER from @taiga-ui/kit`,
60
- },
61
- {
62
- namedImport: `TuiDay`,
63
- field: `getDayFromMonthRowCol`,
64
- message: `getDayFromMonthRowCol has been removed in 3.0. If you need this utils check out this pipe https://github.com/taiga-family/taiga-ui/tree/main/projects/core/pipes/calendar-sheet`,
65
- },
66
- {
67
- namedImport: `TuiMonth`,
68
- field: `monthStartDaysOffset`,
69
- message: `monthStartDaysOffset has been removed in 3.0. If you need this utils check out this pipe https://github.com/taiga-family/taiga-ui/tree/main/projects/core/pipes/calendar-sheet`,
70
- },
71
- {
72
- namedImport: `TuiMonth`,
73
- field: `weeksRowsCount`,
74
- message: `weeksRowsCount has been removed in 3.0. If you need this utils check out this pipe https://github.com/taiga-family/taiga-ui/tree/main/projects/core/pipes/calendar-sheet`,
75
- },
76
- {
77
- namedImport: `TuiYear`,
78
- field: `getYearStartDaysOffset`,
79
- message: `getYearStartDaysOffset has been removed in 3.0. If you need this utils check out this pipe https://github.com/taiga-family/taiga-ui/tree/main/projects/core/pipes/calendar-sheet`,
80
- },
81
- {
82
- namedImport: `TuiYear`,
83
- field: `weeksRowsCount`,
84
- message: `weeksRowsCount has been removed in 3.0. If you need this utils check out this pipe https://github.com/taiga-family/taiga-ui/tree/main/projects/core/pipes/calendar-sheet`,
85
- },
86
- ].forEach(({ namedImport, field, message }) => {
87
- start = perf_hooks_1.performance.now();
88
- migrateProperty({
89
- namedImport,
90
- moduleSpecifier: `@taiga-ui/cdk`,
91
- from: field,
92
- callback: node => insertTodoBeforeNode(node, message),
93
- });
94
- !options[`skip-logs`] &&
95
- colored_log_1.processLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.PROCESSING_SYMBOL}${namedImport}.${field} ` +
96
- `(${get_execution_time_1.getExecutionTime(start, perf_hooks_1.performance.now())})`);
97
- });
98
- !options[`skip-logs`] &&
99
- colored_log_1.successLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SUCCESS_SYMBOL} date/time migrated \n`);
100
- }
101
- exports.dateTimeMigrations = dateTimeMigrations;
102
10
  function migrateProperty({ namedImport, moduleSpecifier, from, callback, }) {
103
11
  const references = get_named_import_references_1.getNamedImportReferences(namedImport, moduleSpecifier);
104
12
  references.forEach(ref => {
@@ -205,3 +113,95 @@ function areBothObjectDestructuring(ref, identifier) {
205
113
  return Boolean(identifier.getFirstAncestorByKind(ng_morph_1.SyntaxKind.BindingElement) &&
206
114
  ref.getFirstAncestorByKind(ng_morph_1.SyntaxKind.BindingElement));
207
115
  }
116
+ function dateTimeMigrations(options) {
117
+ !options[`skip-logs`] &&
118
+ colored_log_1.infoLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} migrating taiga date/time...`);
119
+ let start = perf_hooks_1.performance.now();
120
+ migrateProperty({
121
+ namedImport: `TuiDay`,
122
+ moduleSpecifier: `@taiga-ui/cdk`,
123
+ from: `formattedDay`,
124
+ callback: node => node.replaceWithText(node.getText().replace(`formattedDay`, `getFormattedDay("DMY", ".")`)),
125
+ });
126
+ !options[`skip-logs`] &&
127
+ colored_log_1.processLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.PROCESSING_SYMBOL}TuiDay.formattedDay ` +
128
+ `(${get_execution_time_1.getExecutionTime(start, perf_hooks_1.performance.now())})`);
129
+ start = perf_hooks_1.performance.now();
130
+ migrateProperty({
131
+ namedImport: `TuiDayRange`,
132
+ moduleSpecifier: `@taiga-ui/cdk`,
133
+ from: `formattedDayRange`,
134
+ callback: node => node.replaceWithText(node
135
+ .getText()
136
+ .replace(`formattedDayRange`, `getFormattedDayRange("DMY", ".")`)),
137
+ });
138
+ !options[`skip-logs`] &&
139
+ colored_log_1.processLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.PROCESSING_SYMBOL}TuiDayRange.formattedDayRange ` +
140
+ `(${get_execution_time_1.getExecutionTime(start, perf_hooks_1.performance.now())})`);
141
+ start = perf_hooks_1.performance.now();
142
+ migrateProperty({
143
+ namedImport: `TuiDayRange`,
144
+ moduleSpecifier: `@taiga-ui/cdk`,
145
+ from: `normalizeParse`,
146
+ callback: node => {
147
+ const parent = node.getParent();
148
+ if (ng_morph_1.Node.isCallExpression(parent)) {
149
+ changeNormalizeArgs(parent);
150
+ }
151
+ },
152
+ });
153
+ !options[`skip-logs`] &&
154
+ colored_log_1.processLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.PROCESSING_SYMBOL}TuiDayRange.normalizeParse ` +
155
+ `(${get_execution_time_1.getExecutionTime(start, perf_hooks_1.performance.now())})`);
156
+ [
157
+ {
158
+ namedImport: `TuiMonthRange`,
159
+ field: `formattedMonthRange`,
160
+ message: `formattedMonthRange has been removed in 3.0. Please use TUI_MONTH_FORMATTER from @taiga-ui/kit`,
161
+ },
162
+ {
163
+ namedImport: `TuiMonth`,
164
+ field: `formattedMonth`,
165
+ message: `formattedMonth has been removed in 3.0. Please use TUI_MONTH_FORMATTER from @taiga-ui/kit`,
166
+ },
167
+ {
168
+ namedImport: `TuiDay`,
169
+ field: `getDayFromMonthRowCol`,
170
+ message: `getDayFromMonthRowCol has been removed in 3.0. If you need this utils check out this pipe https://github.com/taiga-family/taiga-ui/tree/main/projects/core/pipes/calendar-sheet`,
171
+ },
172
+ {
173
+ namedImport: `TuiMonth`,
174
+ field: `monthStartDaysOffset`,
175
+ message: `monthStartDaysOffset has been removed in 3.0. If you need this utils check out this pipe https://github.com/taiga-family/taiga-ui/tree/main/projects/core/pipes/calendar-sheet`,
176
+ },
177
+ {
178
+ namedImport: `TuiMonth`,
179
+ field: `weeksRowsCount`,
180
+ message: `weeksRowsCount has been removed in 3.0. If you need this utils check out this pipe https://github.com/taiga-family/taiga-ui/tree/main/projects/core/pipes/calendar-sheet`,
181
+ },
182
+ {
183
+ namedImport: `TuiYear`,
184
+ field: `getYearStartDaysOffset`,
185
+ message: `getYearStartDaysOffset has been removed in 3.0. If you need this utils check out this pipe https://github.com/taiga-family/taiga-ui/tree/main/projects/core/pipes/calendar-sheet`,
186
+ },
187
+ {
188
+ namedImport: `TuiYear`,
189
+ field: `weeksRowsCount`,
190
+ message: `weeksRowsCount has been removed in 3.0. If you need this utils check out this pipe https://github.com/taiga-family/taiga-ui/tree/main/projects/core/pipes/calendar-sheet`,
191
+ },
192
+ ].forEach(({ namedImport, field, message }) => {
193
+ start = perf_hooks_1.performance.now();
194
+ migrateProperty({
195
+ namedImport,
196
+ moduleSpecifier: `@taiga-ui/cdk`,
197
+ from: field,
198
+ callback: node => insertTodoBeforeNode(node, message),
199
+ });
200
+ !options[`skip-logs`] &&
201
+ colored_log_1.processLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.PROCESSING_SYMBOL}${namedImport}.${field} ` +
202
+ `(${get_execution_time_1.getExecutionTime(start, perf_hooks_1.performance.now())})`);
203
+ });
204
+ !options[`skip-logs`] &&
205
+ colored_log_1.successLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SUCCESS_SYMBOL} date/time migrated \n`);
206
+ }
207
+ exports.dateTimeMigrations = dateTimeMigrations;
@@ -5,41 +5,6 @@ const elements_1 = require("../../../utils/templates/elements");
5
5
  const ng_component_input_manipulations_1 = require("../../../utils/templates/ng-component-input-manipulations");
6
6
  const template_resource_1 = require("../../../utils/templates/template-resource");
7
7
  const replace_tag_1 = require("../../utils/templates/replace-tag");
8
- function migratePolymorpheus({ resource, fileSystem, recorder, }) {
9
- const template = template_resource_1.getTemplateFromTemplateResource(resource, fileSystem);
10
- const templateOffset = template_resource_1.getTemplateOffset(resource);
11
- const elements = elements_1.findElementsWithAttribute(template, `polymorpheus-outlet`);
12
- elements.forEach(element => {
13
- var _a, _b;
14
- const contentVal = (_a = element.attrs.find(attr => attr.name === `[content]`)) === null || _a === void 0 ? void 0 : _a.value;
15
- const contextVal = (_b = element.attrs.find(attr => attr.name === `[context]`)) === null || _b === void 0 ? void 0 : _b.value;
16
- const defaultTemplateEl = elements_1.findElementsByFn(element.childNodes, el => el.tagName === `ng-template`)[0];
17
- if (!contentVal) {
18
- return;
19
- }
20
- if (defaultTemplateEl) {
21
- insertPolymorpheusWithDefault({
22
- template,
23
- defaultTemplateEl,
24
- recorder,
25
- templateOffset,
26
- contentVal,
27
- contextVal,
28
- });
29
- }
30
- else {
31
- insertPolymorpheus({
32
- element,
33
- contentVal,
34
- contextVal,
35
- recorder,
36
- templateOffset,
37
- });
38
- }
39
- });
40
- removeOldInputs(recorder, template, templateOffset);
41
- }
42
- exports.migratePolymorpheus = migratePolymorpheus;
43
8
  function insertPolymorpheus({ element, contentVal, contextVal, recorder, templateOffset, }) {
44
9
  var _a, _b;
45
10
  const content = `
@@ -76,3 +41,38 @@ function insertPolymorpheusWithDefault({ template, defaultTemplateEl, recorder,
76
41
  templateOffset, templateVar.name.length);
77
42
  }
78
43
  }
44
+ function migratePolymorpheus({ resource, fileSystem, recorder, }) {
45
+ const template = template_resource_1.getTemplateFromTemplateResource(resource, fileSystem);
46
+ const templateOffset = template_resource_1.getTemplateOffset(resource);
47
+ const elements = elements_1.findElementsWithAttribute(template, `polymorpheus-outlet`);
48
+ elements.forEach(element => {
49
+ var _a, _b;
50
+ const contentVal = (_a = element.attrs.find(attr => attr.name === `[content]`)) === null || _a === void 0 ? void 0 : _a.value;
51
+ const contextVal = (_b = element.attrs.find(attr => attr.name === `[context]`)) === null || _b === void 0 ? void 0 : _b.value;
52
+ const defaultTemplateEl = elements_1.findElementsByFn(element.childNodes, el => el.tagName === `ng-template`)[0];
53
+ if (!contentVal) {
54
+ return;
55
+ }
56
+ if (defaultTemplateEl) {
57
+ insertPolymorpheusWithDefault({
58
+ template,
59
+ defaultTemplateEl,
60
+ recorder,
61
+ templateOffset,
62
+ contentVal,
63
+ contextVal,
64
+ });
65
+ }
66
+ else {
67
+ insertPolymorpheus({
68
+ element,
69
+ contentVal,
70
+ contextVal,
71
+ recorder,
72
+ templateOffset,
73
+ });
74
+ }
75
+ });
76
+ removeOldInputs(recorder, template, templateOffset);
77
+ }
78
+ exports.migratePolymorpheus = migratePolymorpheus;
@@ -1,4 +1,8 @@
1
1
  import { DevkitFileSystem } from 'ng-morph';
2
+ import { Element } from 'parse5';
2
3
  import { TuiSchema } from '../../../ng-add/schema';
4
+ import { TemplateResource } from '../../interfaces/template-resource';
3
5
  export declare const DEPRECATED_PROGRESS_PIPES_REG: RegExp;
6
+ export declare function replaceProgressColorSegmentsPipe(templateResource: TemplateResource, fileSystem: DevkitFileSystem): void;
7
+ export declare function isProgressWithDeprecatedPipe(element: Element): boolean;
4
8
  export declare function migrateProgress(fileSystem: DevkitFileSystem, options: TuiSchema): void;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.migrateProgress = exports.DEPRECATED_PROGRESS_PIPES_REG = void 0;
3
+ exports.migrateProgress = exports.isProgressWithDeprecatedPipe = exports.replaceProgressColorSegmentsPipe = exports.DEPRECATED_PROGRESS_PIPES_REG = void 0;
4
4
  const ng_morph_1 = require("ng-morph");
5
5
  const constants_1 = require("../../../constants");
6
6
  const colored_log_1 = require("../../../utils/colored-log");
@@ -8,32 +8,19 @@ const project_root_1 = require("../../../utils/project-root");
8
8
  const elements_1 = require("../../../utils/templates/elements");
9
9
  const get_component_templates_1 = require("../../../utils/templates/get-component-templates");
10
10
  const template_resource_1 = require("../../../utils/templates/template-resource");
11
+ const PROPERTY_FOR_DEPRECATED_PIPES = `[color]`;
11
12
  exports.DEPRECATED_PROGRESS_PIPES_REG =
12
13
  // eslint-disable-next-line unicorn/no-unsafe-regex
13
14
  /\s*\|\s*tuiProgressColorSegments(Async\s*\|\s*async)?/gi;
14
- const PROPERTY_FOR_DEPRECATED_PIPES = `[color]`;
15
- function migrateProgress(fileSystem, options) {
16
- !options[`skip-logs`] &&
17
- colored_log_1.infoLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} migrating progress bars...`);
18
- const templateResources = get_component_templates_1.getComponentTemplates(constants_1.ALL_TS_FILES);
19
- for (const templateResource of templateResources) {
20
- replaceProgressColorSegmentsPipe(templateResource, fileSystem);
21
- }
22
- fileSystem.commitEdits();
23
- ng_morph_1.saveActiveProject();
24
- ng_morph_1.setActiveProject(ng_morph_1.createProject(fileSystem.tree, project_root_1.projectRoot(), constants_1.ALL_FILES));
25
- !options[`skip-logs`] &&
26
- colored_log_1.successLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SUCCESS_SYMBOL} progress bars migrated \n`);
27
- }
28
- exports.migrateProgress = migrateProgress;
29
15
  function replaceProgressColorSegmentsPipe(templateResource, fileSystem) {
30
- var _a, _b;
31
16
  const template = template_resource_1.getTemplateFromTemplateResource(templateResource, fileSystem);
32
17
  const templateOffset = template_resource_1.getTemplateOffset(templateResource);
33
18
  const path = fileSystem.resolve(template_resource_1.getPathFromTemplateResource(templateResource));
34
19
  const recorder = fileSystem.edit(path);
35
- const progressElements = elements_1.findElementsWithAttribute(template, PROPERTY_FOR_DEPRECATED_PIPES).filter(isProgressWithDeprecatedPipe);
36
- for (const progressEl of progressElements) {
20
+ elements_1.findElementsWithAttribute(template, PROPERTY_FOR_DEPRECATED_PIPES)
21
+ .filter(isProgressWithDeprecatedPipe)
22
+ .forEach(progressEl => {
23
+ var _a, _b;
37
24
  const oldValue = ((_a = progressEl.attrs.find(attr => attr.name === PROPERTY_FOR_DEPRECATED_PIPES)) === null || _a === void 0 ? void 0 : _a.value) || ``;
38
25
  const newValue = oldValue.replace(exports.DEPRECATED_PROGRESS_PIPES_REG, ``);
39
26
  const attrLocations = (_b = progressEl.sourceCodeLocation) === null || _b === void 0 ? void 0 : _b.attrs;
@@ -42,10 +29,23 @@ function replaceProgressColorSegmentsPipe(templateResource, fileSystem) {
42
29
  recorder.remove(templateOffset + startOffset, endOffset - startOffset);
43
30
  recorder.insertRight(templateOffset + startOffset, `[tuiProgressColorSegments]="${newValue}"`);
44
31
  }
45
- }
32
+ });
46
33
  }
34
+ exports.replaceProgressColorSegmentsPipe = replaceProgressColorSegmentsPipe;
47
35
  function isProgressWithDeprecatedPipe(element) {
48
36
  return (element.tagName === `progress` &&
49
37
  element.attrs.some(attr => attr.name === PROPERTY_FOR_DEPRECATED_PIPES &&
50
38
  attr.value.match(exports.DEPRECATED_PROGRESS_PIPES_REG)));
51
39
  }
40
+ exports.isProgressWithDeprecatedPipe = isProgressWithDeprecatedPipe;
41
+ function migrateProgress(fileSystem, options) {
42
+ !options[`skip-logs`] &&
43
+ colored_log_1.infoLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} migrating progress bars...`);
44
+ get_component_templates_1.getComponentTemplates(constants_1.ALL_TS_FILES).forEach(templateResource => replaceProgressColorSegmentsPipe(templateResource, fileSystem));
45
+ fileSystem.commitEdits();
46
+ ng_morph_1.saveActiveProject();
47
+ ng_morph_1.setActiveProject(ng_morph_1.createProject(fileSystem.tree, project_root_1.projectRoot(), constants_1.ALL_FILES));
48
+ !options[`skip-logs`] &&
49
+ colored_log_1.successLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SUCCESS_SYMBOL} progress bars migrated \n`);
50
+ }
51
+ exports.migrateProgress = migrateProgress;
@@ -11,52 +11,6 @@ const get_component_templates_1 = require("../../../../utils/templates/get-compo
11
11
  const ng_component_input_manipulations_1 = require("../../../../utils/templates/ng-component-input-manipulations");
12
12
  const MIN_LABELS_MIGRATION_METHOD_NAME = `tuiMigrationInputRangeMinLabel`;
13
13
  const MAX_LABELS_MIGRATION_METHOD_NAME = `tuiMigrationInputRangeMaxLabel`;
14
- function migrateInputRange(fileSystem, options) {
15
- const templateResources = get_component_templates_1.getComponentTemplates(constants_1.ALL_TS_FILES);
16
- // eslint-disable-next-line @typescript-eslint/naming-convention
17
- const COMPONENTS_WITH_MIN_LABELS = new Set();
18
- // eslint-disable-next-line @typescript-eslint/naming-convention
19
- const COMPONENTS_WITH_MAX_LABELS = new Set();
20
- let progressLog = progress_1.setupProgressLogger({
21
- total: templateResources.length,
22
- prefix: `[replaceMinMaxLabel]`,
23
- });
24
- for (const templateResource of templateResources) {
25
- !options[`skip-logs`] && progressLog(templateResource.componentPath);
26
- replaceMinLabel(templateResource, fileSystem, COMPONENTS_WITH_MIN_LABELS);
27
- replaceMaxLabel(templateResource, fileSystem, COMPONENTS_WITH_MAX_LABELS);
28
- }
29
- save(fileSystem);
30
- progressLog = progress_1.setupProgressLogger({
31
- total: COMPONENTS_WITH_MIN_LABELS.size,
32
- prefix: `[COMPONENTS_WITH_MIN_LABELS]`,
33
- });
34
- for (const componentPath of Array.from(COMPONENTS_WITH_MIN_LABELS)) {
35
- !options[`skip-logs`] && progressLog(componentPath);
36
- addMinMaxLabelMethod(componentPath, MIN_LABELS_MIGRATION_METHOD_NAME, [
37
- `const currentValue = context.$implicit;`,
38
- `const minValue = 0; // TODO: (Taiga UI migration) replace with the MIN value of the input-range`,
39
- `const minLabelText = "Min"; // TODO: (Taiga UI migration) replace with the required label`,
40
- `if (currentValue === minValue) return minLabelText;`,
41
- `return String(currentValue);`,
42
- ]);
43
- }
44
- progressLog = progress_1.setupProgressLogger({
45
- total: COMPONENTS_WITH_MAX_LABELS.size,
46
- prefix: `[COMPONENTS_WITH_MAX_LABELS]`,
47
- });
48
- for (const componentPath of Array.from(COMPONENTS_WITH_MAX_LABELS)) {
49
- !options[`skip-logs`] && progressLog(componentPath);
50
- addMinMaxLabelMethod(componentPath, MAX_LABELS_MIGRATION_METHOD_NAME, [
51
- `const currentValue = context.$implicit;`,
52
- `const maxValue = 100; // TODO: (Taiga UI migration) replace with the MAX value of the input`,
53
- `const maxLabelText = "Max"; // TODO: (Taiga UI migration) replace with the required label`,
54
- `if (currentValue === maxValue) return maxLabelText;`,
55
- `return String(currentValue);`,
56
- ]);
57
- }
58
- }
59
- exports.migrateInputRange = migrateInputRange;
60
14
  function replaceMinLabel(templateResource, fileSystem, modifiedComponentStorage) {
61
15
  const wasModified = ng_component_input_manipulations_1.replaceInputProperty({
62
16
  templateResource,
@@ -104,3 +58,47 @@ function save(fileSystem) {
104
58
  ng_morph_1.saveActiveProject();
105
59
  ng_morph_1.setActiveProject(ng_morph_1.createProject(fileSystem.tree, project_root_1.projectRoot(), constants_1.ALL_FILES));
106
60
  }
61
+ function migrateInputRange(fileSystem, options) {
62
+ const templateResources = get_component_templates_1.getComponentTemplates(constants_1.ALL_TS_FILES);
63
+ const COMPONENTS_WITH_MIN_LABELS = new Set();
64
+ const COMPONENTS_WITH_MAX_LABELS = new Set();
65
+ let progressLog = progress_1.setupProgressLogger({
66
+ total: templateResources.length,
67
+ prefix: `[replaceMinMaxLabel]`,
68
+ });
69
+ templateResources.forEach(templateResource => {
70
+ !options[`skip-logs`] && progressLog(templateResource.componentPath);
71
+ replaceMinLabel(templateResource, fileSystem, COMPONENTS_WITH_MIN_LABELS);
72
+ replaceMaxLabel(templateResource, fileSystem, COMPONENTS_WITH_MAX_LABELS);
73
+ });
74
+ save(fileSystem);
75
+ progressLog = progress_1.setupProgressLogger({
76
+ total: COMPONENTS_WITH_MIN_LABELS.size,
77
+ prefix: `[COMPONENTS_WITH_MIN_LABELS]`,
78
+ });
79
+ Array.from(COMPONENTS_WITH_MIN_LABELS).forEach(componentPath => {
80
+ !options[`skip-logs`] && progressLog(componentPath);
81
+ addMinMaxLabelMethod(componentPath, MIN_LABELS_MIGRATION_METHOD_NAME, [
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
+ progressLog = progress_1.setupProgressLogger({
90
+ total: COMPONENTS_WITH_MAX_LABELS.size,
91
+ prefix: `[COMPONENTS_WITH_MAX_LABELS]`,
92
+ });
93
+ Array.from(COMPONENTS_WITH_MAX_LABELS).forEach(componentPath => {
94
+ !options[`skip-logs`] && progressLog(componentPath);
95
+ addMinMaxLabelMethod(componentPath, MAX_LABELS_MIGRATION_METHOD_NAME, [
96
+ `const currentValue = context.$implicit;`,
97
+ `const maxValue = 100; // TODO: (Taiga UI migration) replace with the MAX value of the input`,
98
+ `const maxLabelText = "Max"; // TODO: (Taiga UI migration) replace with the required label`,
99
+ `if (currentValue === maxValue) return maxLabelText;`,
100
+ `return String(currentValue);`,
101
+ ]);
102
+ });
103
+ }
104
+ exports.migrateInputRange = migrateInputRange;
@@ -10,35 +10,6 @@ const project_root_1 = require("../../../../utils/project-root");
10
10
  const elements_1 = require("../../../../utils/templates/elements");
11
11
  const get_component_templates_1 = require("../../../../utils/templates/get-component-templates");
12
12
  const ng_component_input_manipulations_1 = require("../../../../utils/templates/ng-component-input-manipulations");
13
- function migrateInputSlider(fileSystem, options) {
14
- const templateResources = get_component_templates_1.getComponentTemplates(constants_1.ALL_TS_FILES);
15
- // eslint-disable-next-line @typescript-eslint/naming-convention
16
- const COMPONENTS_WITH_MIN_MAX_LABELS = new Set();
17
- let progressLog = progress_1.setupProgressLogger({
18
- total: templateResources.length,
19
- prefix: `[replaceMinMaxLabels]`,
20
- });
21
- for (const templateResource of templateResources) {
22
- !options[`skip-logs`] && progressLog(templateResource.componentPath);
23
- replaceMinMaxLabels(templateResource, fileSystem, COMPONENTS_WITH_MIN_MAX_LABELS);
24
- }
25
- /**
26
- * We should update virtual file tree
27
- * otherwise all following ng-morph commands will overwrite all previous template manipulations
28
- * */
29
- fileSystem.commitEdits();
30
- ng_morph_1.saveActiveProject();
31
- ng_morph_1.setActiveProject(ng_morph_1.createProject(fileSystem.tree, project_root_1.projectRoot(), constants_1.ALL_FILES));
32
- progressLog = progress_1.setupProgressLogger({
33
- total: COMPONENTS_WITH_MIN_MAX_LABELS.size,
34
- prefix: `[addMinMaxLabelMethod]`,
35
- });
36
- for (const componentPath of Array.from(COMPONENTS_WITH_MIN_MAX_LABELS)) {
37
- !options[`skip-logs`] && progressLog(componentPath);
38
- addMinMaxLabelMethod(componentPath);
39
- }
40
- }
41
- exports.migrateInputSlider = migrateInputSlider;
42
13
  const MIN_MAX_LABELS_MIGRATION_METHOD_NAME = `tuiMigrationMinMaxLabel`;
43
14
  function replaceMinMaxLabels(templateResource, fileSystem, modifiedComponentStorage) {
44
15
  const wasMaxLabelModified = ng_component_input_manipulations_1.replaceInputProperty({
@@ -90,3 +61,31 @@ function addMinMaxLabelMethod(componentPath) {
90
61
  });
91
62
  }
92
63
  }
64
+ function migrateInputSlider(fileSystem, options) {
65
+ const templateResources = get_component_templates_1.getComponentTemplates(constants_1.ALL_TS_FILES);
66
+ const COMPONENTS_WITH_MIN_MAX_LABELS = new Set();
67
+ let progressLog = progress_1.setupProgressLogger({
68
+ total: templateResources.length,
69
+ prefix: `[replaceMinMaxLabels]`,
70
+ });
71
+ templateResources.forEach(templateResource => {
72
+ !options[`skip-logs`] && progressLog(templateResource.componentPath);
73
+ replaceMinMaxLabels(templateResource, fileSystem, COMPONENTS_WITH_MIN_MAX_LABELS);
74
+ });
75
+ /**
76
+ * We should update virtual file tree
77
+ * otherwise all following ng-morph commands will overwrite all previous template manipulations
78
+ * */
79
+ fileSystem.commitEdits();
80
+ ng_morph_1.saveActiveProject();
81
+ ng_morph_1.setActiveProject(ng_morph_1.createProject(fileSystem.tree, project_root_1.projectRoot(), constants_1.ALL_FILES));
82
+ progressLog = progress_1.setupProgressLogger({
83
+ total: COMPONENTS_WITH_MIN_MAX_LABELS.size,
84
+ prefix: `[addMinMaxLabelMethod]`,
85
+ });
86
+ Array.from(COMPONENTS_WITH_MIN_MAX_LABELS).forEach(componentPath => {
87
+ !options[`skip-logs`] && progressLog(componentPath);
88
+ addMinMaxLabelMethod(componentPath);
89
+ });
90
+ }
91
+ exports.migrateInputSlider = migrateInputSlider;
@@ -21,42 +21,6 @@ const replace_tags_1 = require("../../utils/templates/replace-tags");
21
21
  const templates_1 = require("../constants/templates");
22
22
  const migrate_polymorpheus_1 = require("./migrate-polymorpheus");
23
23
  const migrate_textfield_controller_1 = require("./migrate-textfield-controller");
24
- function migrateTemplates(fileSystem, options) {
25
- !options[`skip-logs`] &&
26
- colored_log_1.infoLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} migrating templates...`);
27
- const componentWithTemplatesPaths = get_component_templates_1.getComponentTemplates(constants_1.ALL_TS_FILES);
28
- const actions = [
29
- replaceV3Tags,
30
- replaceV3Attrs,
31
- replaceAttrsByDirective,
32
- replaceBreadcrumbs,
33
- replaceFieldError,
34
- addHTMLCommentTags,
35
- addEditorProviders,
36
- migrateTuiHideSelectedPipe,
37
- removeV3Inputs,
38
- migrate_polymorpheus_1.migratePolymorpheus,
39
- migrate_textfield_controller_1.migrateTextfieldController,
40
- replaceInputValues,
41
- migrateBinaryAttributes,
42
- addWarningForFormatNumberPipe,
43
- ];
44
- const progressLog = progress_1.setupProgressLogger({
45
- total: componentWithTemplatesPaths.length,
46
- });
47
- componentWithTemplatesPaths.forEach(resource => {
48
- const path = fileSystem.resolve(template_resource_1.getPathFromTemplateResource(resource));
49
- const recorder = fileSystem.edit(path);
50
- actions.forEach((action, actionIndex) => {
51
- const isLastAction = actionIndex === actions.length - 1;
52
- !options[`skip-logs`] && progressLog(action.name, isLastAction);
53
- action({ resource, fileSystem, recorder });
54
- });
55
- });
56
- !options[`skip-logs`] &&
57
- colored_log_1.successLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SUCCESS_SYMBOL} templates migrated \n`);
58
- }
59
- exports.migrateTemplates = migrateTemplates;
60
24
  function replaceAttrsByDirective({ resource, fileSystem, }) {
61
25
  templates_1.ATTR_TO_DIRECTIVE.forEach(({ componentSelector, directiveModule, directive, inputProperty, filterFn }) => {
62
26
  ng_component_input_manipulations_1.replaceInputPropertyByDirective({
@@ -108,6 +72,7 @@ function replaceBreadcrumbs({ resource, recorder, fileSystem, }) {
108
72
  if (!itemsValue || !insertTo) {
109
73
  return;
110
74
  }
75
+ // noinspection AngularMissingRequiredDirectiveInputBinding
111
76
  recorder.insertRight(insertTo + templateOffset, `
112
77
  <ng-container *ngFor="let item of ${itemsValue}">
113
78
  <a
@@ -216,3 +181,39 @@ function replaceInputValues({ resource, recorder, fileSystem, }) {
216
181
  function removeV3Inputs({ resource, fileSystem, recorder, }) {
217
182
  remove_inputs_1.removeInputs({ resource, recorder, fileSystem, data: templates_1.INPUTS_TO_REMOVE });
218
183
  }
184
+ function migrateTemplates(fileSystem, options) {
185
+ !options[`skip-logs`] &&
186
+ colored_log_1.infoLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.REPLACE_SYMBOL} migrating templates...`);
187
+ const componentWithTemplatesPaths = get_component_templates_1.getComponentTemplates(constants_1.ALL_TS_FILES);
188
+ const actions = [
189
+ replaceV3Tags,
190
+ replaceV3Attrs,
191
+ replaceAttrsByDirective,
192
+ replaceBreadcrumbs,
193
+ replaceFieldError,
194
+ addHTMLCommentTags,
195
+ addEditorProviders,
196
+ migrateTuiHideSelectedPipe,
197
+ removeV3Inputs,
198
+ migrate_polymorpheus_1.migratePolymorpheus,
199
+ migrate_textfield_controller_1.migrateTextfieldController,
200
+ replaceInputValues,
201
+ migrateBinaryAttributes,
202
+ addWarningForFormatNumberPipe,
203
+ ];
204
+ const progressLog = progress_1.setupProgressLogger({
205
+ total: componentWithTemplatesPaths.length,
206
+ });
207
+ componentWithTemplatesPaths.forEach(resource => {
208
+ const path = fileSystem.resolve(template_resource_1.getPathFromTemplateResource(resource));
209
+ const recorder = fileSystem.edit(path);
210
+ actions.forEach((action, actionIndex) => {
211
+ const isLastAction = actionIndex === actions.length - 1;
212
+ !options[`skip-logs`] && progressLog(action.name, isLastAction);
213
+ action({ resource, fileSystem, recorder });
214
+ });
215
+ });
216
+ !options[`skip-logs`] &&
217
+ colored_log_1.successLog(`${colored_log_1.SMALL_TAB_SYMBOL}${colored_log_1.SUCCESS_SYMBOL} templates migrated \n`);
218
+ }
219
+ exports.migrateTemplates = migrateTemplates;
@@ -35,27 +35,6 @@ const ATTRS_MAP = {
35
35
  '[tuitextfieldexampletext]': `[attr.placeholder]`,
36
36
  };
37
37
  const CONTROLLER_ITEMS = Object.keys(ATTRS_MAP).map(attr => attr.toLowerCase());
38
- function migrateTextfieldController({ resource, fileSystem, recorder, }) {
39
- const template = template_resource_1.getTemplateFromTemplateResource(resource, fileSystem);
40
- const templateOffset = template_resource_1.getTemplateOffset(resource);
41
- const elements = elements_1.findElementsByTagNames(template, TEXTFIELDS);
42
- elements.forEach(element => {
43
- const attrs = element.attrs.filter(attr => CONTROLLER_ITEMS.includes(attr.name) && !exclusion(element, attr.name));
44
- if (!attrs.length) {
45
- return;
46
- }
47
- const existingInput = elements_1.findElementsByFn(element.childNodes, el => (el.tagName === `input` || el.tagName === `textarea`) &&
48
- elements_1.hasElementAttribute(el, `tuiTextfield`))[0];
49
- if (existingInput) {
50
- addAttrToExistingInput({ existingInput, attrs, recorder, templateOffset });
51
- }
52
- else {
53
- insertTuiTextfieldInput({ element, attrs, recorder, templateOffset });
54
- }
55
- });
56
- removeOldInputs(recorder, template, templateOffset);
57
- }
58
- exports.migrateTextfieldController = migrateTextfieldController;
59
38
  function insertTuiTextfieldInput({ element, attrs, recorder, templateOffset, }) {
60
39
  var _a, _b;
61
40
  const newAttrs = attrs
@@ -96,3 +75,24 @@ function exclusion({ tagName }, attrName) {
96
75
  var _a;
97
76
  return (_a = excludedAttrs[tagName]) === null || _a === void 0 ? void 0 : _a.includes(attrName);
98
77
  }
78
+ function migrateTextfieldController({ resource, fileSystem, recorder, }) {
79
+ const template = template_resource_1.getTemplateFromTemplateResource(resource, fileSystem);
80
+ const templateOffset = template_resource_1.getTemplateOffset(resource);
81
+ const elements = elements_1.findElementsByTagNames(template, TEXTFIELDS);
82
+ elements.forEach(element => {
83
+ const attrs = element.attrs.filter(attr => CONTROLLER_ITEMS.includes(attr.name) && !exclusion(element, attr.name));
84
+ if (!attrs.length) {
85
+ return;
86
+ }
87
+ const existingInput = elements_1.findElementsByFn(element.childNodes, el => (el.tagName === `input` || el.tagName === `textarea`) &&
88
+ elements_1.hasElementAttribute(el, `tuiTextfield`))[0];
89
+ if (existingInput) {
90
+ addAttrToExistingInput({ existingInput, attrs, recorder, templateOffset });
91
+ }
92
+ else {
93
+ insertTuiTextfieldInput({ element, attrs, recorder, templateOffset });
94
+ }
95
+ });
96
+ removeOldInputs(recorder, template, templateOffset);
97
+ }
98
+ exports.migrateTextfieldController = migrateTextfieldController;