@taiga-ui/cdk 5.1.0 → 5.2.0
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.
- package/constants/svg-node-filter.d.ts +3 -1
- package/constants/version.d.ts +1 -1
- package/constants/version.js +1 -1
- package/fesm2022/taiga-ui-cdk-constants.mjs +1 -1
- package/fesm2022/taiga-ui-cdk-constants.mjs.map +1 -1
- package/fesm2022/taiga-ui-cdk-directives-auto-focus.mjs.map +1 -1
- package/fesm2022/taiga-ui-cdk-directives-truncate.mjs +5 -4
- package/fesm2022/taiga-ui-cdk-directives-truncate.mjs.map +1 -1
- package/fesm2022/taiga-ui-cdk-utils-di.mjs.map +1 -1
- package/fesm2022/taiga-ui-cdk-utils-dom.mjs +0 -1
- package/fesm2022/taiga-ui-cdk-utils-dom.mjs.map +1 -1
- package/fesm2022/taiga-ui-cdk-utils-miscellaneous.mjs.map +1 -1
- package/package.json +2 -2
- package/schematics/ng-add/constants/versions.d.ts +1 -1
- package/schematics/ng-update/v5/index.js +14 -4
- package/schematics/ng-update/v5/index.js.map +1 -1
- package/schematics/ng-update/v5/steps/constants/attr-with-values-to-replace.js +29 -0
- package/schematics/ng-update/v5/steps/constants/attr-with-values-to-replace.js.map +1 -1
- package/schematics/ng-update/v5/steps/constants/attrs-in-host-to-replace.d.ts +2 -2
- package/schematics/ng-update/v5/steps/constants/attrs-in-host-to-replace.js.map +1 -1
- package/schematics/ng-update/v5/steps/constants/attrs-to-replace.js +4 -0
- package/schematics/ng-update/v5/steps/constants/attrs-to-replace.js.map +1 -1
- package/schematics/ng-update/v5/steps/constants/identifiers-to-replace.js +145 -1
- package/schematics/ng-update/v5/steps/constants/identifiers-to-replace.js.map +1 -1
- package/schematics/ng-update/v5/steps/constants/inputs-to-remove.js +6 -0
- package/schematics/ng-update/v5/steps/constants/inputs-to-remove.js.map +1 -1
- package/schematics/ng-update/v5/steps/constants/migration-warnings.js +70 -3
- package/schematics/ng-update/v5/steps/constants/migration-warnings.js.map +1 -1
- package/schematics/ng-update/v5/steps/constants/modules-to-remove.js +4 -8
- package/schematics/ng-update/v5/steps/constants/modules-to-remove.js.map +1 -1
- package/schematics/ng-update/v5/steps/migrate-doc-i18n-tokens.js +2 -21
- package/schematics/ng-update/v5/steps/migrate-doc-i18n-tokens.js.map +1 -1
- package/schematics/ng-update/v5/steps/migrate-i18n-language-signal.d.ts +18 -0
- package/schematics/ng-update/v5/steps/migrate-i18n-language-signal.js +70 -0
- package/schematics/ng-update/v5/steps/migrate-i18n-language-signal.js.map +1 -0
- package/schematics/ng-update/v5/steps/migrate-portals.d.ts +3 -0
- package/schematics/ng-update/v5/steps/migrate-portals.js +78 -0
- package/schematics/ng-update/v5/steps/migrate-portals.js.map +1 -0
- package/schematics/ng-update/v5/steps/migrate-templates.js +2 -0
- package/schematics/ng-update/v5/steps/migrate-templates.js.map +1 -1
- package/schematics/ng-update/v5/steps/templates/migrate-async-pipes.js +6 -1
- package/schematics/ng-update/v5/steps/templates/migrate-async-pipes.js.map +1 -1
- package/schematics/ng-update/v5/steps/templates/migrate-hint-on-legacy-controls.d.ts +12 -0
- package/schematics/ng-update/v5/steps/templates/migrate-hint-on-legacy-controls.js +172 -0
- package/schematics/ng-update/v5/steps/templates/migrate-hint-on-legacy-controls.js.map +1 -0
- package/schematics/ng-update/v5/steps/templates/migrate-input.d.ts +8 -0
- package/schematics/ng-update/v5/steps/templates/migrate-input.js +42 -13
- package/schematics/ng-update/v5/steps/templates/migrate-input.js.map +1 -1
- package/schematics/ng-update/v5/steps/templates/migrate-textarea.d.ts +8 -0
- package/schematics/ng-update/v5/steps/templates/migrate-textarea.js +45 -13
- package/schematics/ng-update/v5/steps/templates/migrate-textarea.js.map +1 -1
- package/schematics/utils/add-import-to-closest-module.js +1 -0
- package/schematics/utils/add-import-to-closest-module.js.map +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type Tree } from '@angular-devkit/schematics';
|
|
2
|
+
import { type TuiSchema } from '../../../ng-add/schema';
|
|
3
|
+
/**
|
|
4
|
+
* Migrates i18n language providers from of(TUI_*_LANGUAGE) to signal(TUI_*_LANGUAGE).
|
|
5
|
+
*
|
|
6
|
+
* Before:
|
|
7
|
+
* {
|
|
8
|
+
* provide: TUI_LANGUAGE,
|
|
9
|
+
* useValue: of(TUI_ENGLISH_LANGUAGE),
|
|
10
|
+
* }
|
|
11
|
+
*
|
|
12
|
+
* After:
|
|
13
|
+
* {
|
|
14
|
+
* provide: TUI_LANGUAGE,
|
|
15
|
+
* useValue: signal(TUI_ENGLISH_LANGUAGE),
|
|
16
|
+
* }
|
|
17
|
+
*/
|
|
18
|
+
export declare function migrateI18nLanguageSignal(tree: Tree, options: TuiSchema): void;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrateI18nLanguageSignal = migrateI18nLanguageSignal;
|
|
4
|
+
const ng_morph_1 = require("ng-morph");
|
|
5
|
+
const add_unique_import_1 = require("../../../utils/add-unique-import");
|
|
6
|
+
const get_named_import_references_1 = require("../../../utils/get-named-import-references");
|
|
7
|
+
const ANGULAR_CORE = '@angular/core';
|
|
8
|
+
const SIGNAL = 'signal';
|
|
9
|
+
/**
|
|
10
|
+
* Migrates i18n language providers from of(TUI_*_LANGUAGE) to signal(TUI_*_LANGUAGE).
|
|
11
|
+
*
|
|
12
|
+
* Before:
|
|
13
|
+
* {
|
|
14
|
+
* provide: TUI_LANGUAGE,
|
|
15
|
+
* useValue: of(TUI_ENGLISH_LANGUAGE),
|
|
16
|
+
* }
|
|
17
|
+
*
|
|
18
|
+
* After:
|
|
19
|
+
* {
|
|
20
|
+
* provide: TUI_LANGUAGE,
|
|
21
|
+
* useValue: signal(TUI_ENGLISH_LANGUAGE),
|
|
22
|
+
* }
|
|
23
|
+
*/
|
|
24
|
+
function migrateI18nLanguageSignal(tree, options) {
|
|
25
|
+
var _a;
|
|
26
|
+
if (!options['skip-logs']) {
|
|
27
|
+
(0, ng_morph_1.infoLog)('Migrating i18n language providers to signal-based values...');
|
|
28
|
+
}
|
|
29
|
+
const refs = (0, get_named_import_references_1.getNamedImportReferences)('TUI_LANGUAGE', '@taiga-ui/i18n');
|
|
30
|
+
for (const ref of refs) {
|
|
31
|
+
if (ref.wasForgotten()) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const parent = ref.getParent();
|
|
35
|
+
if (!parent || ng_morph_1.Node.isImportSpecifier(parent)) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
// We are looking for { provide: TUI_LANGUAGE, useValue: of(...) }
|
|
39
|
+
if (!ng_morph_1.Node.isPropertyAssignment(parent) || parent.getName() !== 'provide') {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const objectLiteral = parent.getParent();
|
|
43
|
+
if (!objectLiteral || !ng_morph_1.Node.isObjectLiteralExpression(objectLiteral)) {
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const useValueProp = objectLiteral.getProperty('useValue');
|
|
47
|
+
if (!useValueProp || !ng_morph_1.Node.isPropertyAssignment(useValueProp)) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
const initializer = useValueProp.getInitializer();
|
|
51
|
+
if (!initializer || !ng_morph_1.Node.isCallExpression(initializer)) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
const expression = initializer.getExpression();
|
|
55
|
+
if (expression.getText() !== 'of') {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const args = initializer.getArguments();
|
|
59
|
+
if (args.length !== 1) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const argText = (_a = args[0]) === null || _a === void 0 ? void 0 : _a.getText();
|
|
63
|
+
if ((argText === null || argText === void 0 ? void 0 : argText.startsWith('TUI_')) && argText.endsWith('_LANGUAGE')) {
|
|
64
|
+
useValueProp.setInitializer(`${SIGNAL}(${argText})`);
|
|
65
|
+
(0, add_unique_import_1.addUniqueImport)(ref.getSourceFile().getFilePath(), SIGNAL, ANGULAR_CORE);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
(0, ng_morph_1.saveActiveProject)();
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=migrate-i18n-language-signal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-i18n-language-signal.js","sourceRoot":"","sources":["../../../../../../projects/cdk/schematics/ng-update/v5/steps/migrate-i18n-language-signal.ts"],"names":[],"mappings":";;AAyBA,8DA8DC;AAtFD,uCAA0D;AAG1D,wEAAiE;AACjE,4FAAoF;AAEpF,MAAM,YAAY,GAAG,eAAe,CAAC;AACrC,MAAM,MAAM,GAAG,QAAQ,CAAC;AAExB;;;;;;;;;;;;;;GAcG;AACH,SAAgB,yBAAyB,CAAC,IAAU,EAAE,OAAkB;;IACpE,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC;QACxB,IAAA,kBAAO,EAAC,6DAA6D,CAAC,CAAC;IAC3E,CAAC;IAED,MAAM,IAAI,GAAG,IAAA,sDAAwB,EAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;IAExE,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACrB,IAAI,GAAG,CAAC,YAAY,EAAE,EAAE,CAAC;YACrB,SAAS;QACb,CAAC;QAED,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC;QAE/B,IAAI,CAAC,MAAM,IAAI,eAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5C,SAAS;QACb,CAAC;QAED,kEAAkE;QAClE,IAAI,CAAC,eAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,KAAK,SAAS,EAAE,CAAC;YACvE,SAAS;QACb,CAAC;QAED,MAAM,aAAa,GAAG,MAAM,CAAC,SAA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use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migratePortals = migratePortals;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const path = tslib_1.__importStar(require("node:path"));
|
|
6
|
+
const ng_morph_1 = require("ng-morph");
|
|
7
|
+
const constants_1 = require("../../../constants");
|
|
8
|
+
const add_unique_import_1 = require("../../../utils/add-unique-import");
|
|
9
|
+
const push_to_array_property_1 = require("../../../utils/push-to-array-property");
|
|
10
|
+
const TUI_PORTALS = 'TuiPortals';
|
|
11
|
+
const TUI_VCR_CLASS = 'TuiVCR';
|
|
12
|
+
const TUI_VCR_DIRECTIVE = 'tuiVCR';
|
|
13
|
+
const TAIGA_CDK = '@taiga-ui/cdk';
|
|
14
|
+
const VIEW_CONTAINER_REF = '#viewContainer';
|
|
15
|
+
function migratePortals(tree, _options) {
|
|
16
|
+
(0, ng_morph_1.getSourceFiles)(constants_1.ALL_TS_FILES).forEach((sourceFile) => {
|
|
17
|
+
migrateSourceFile(sourceFile, tree);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function migrateSourceFile(sourceFile, tree) {
|
|
21
|
+
var _a;
|
|
22
|
+
const hasTuiPortalsImport = sourceFile
|
|
23
|
+
.getImportDeclarations()
|
|
24
|
+
.some((imp) => imp.getModuleSpecifierValue() === TAIGA_CDK &&
|
|
25
|
+
imp.getNamedImports().some((ni) => ni.getName() === TUI_PORTALS));
|
|
26
|
+
if (!hasTuiPortalsImport) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
for (const classDecl of sourceFile.getClasses()) {
|
|
30
|
+
const extendsClause = classDecl.getExtends();
|
|
31
|
+
if ((extendsClause === null || extendsClause === void 0 ? void 0 : extendsClause.getExpression().getText()) !== TUI_PORTALS) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
const decorator = classDecl.getDecorator('Component');
|
|
35
|
+
if (!decorator) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const [metadata] = decorator.getArguments();
|
|
39
|
+
if (!ng_morph_1.Node.isObjectLiteralExpression(metadata)) {
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
const templateProp = metadata.getProperty('template');
|
|
43
|
+
const templateUrlProp = metadata.getProperty('templateUrl');
|
|
44
|
+
if (ng_morph_1.Node.isPropertyAssignment(templateProp)) {
|
|
45
|
+
const initializer = templateProp.getInitializer();
|
|
46
|
+
if (!initializer) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
const text = initializer.getText();
|
|
50
|
+
if (!text.includes(VIEW_CONTAINER_REF)) {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const hasExistingImports = !!metadata.getProperty('imports');
|
|
54
|
+
initializer.replaceWithText(text.replaceAll(VIEW_CONTAINER_REF, TUI_VCR_DIRECTIVE));
|
|
55
|
+
(0, push_to_array_property_1.pushToObjectArrayProperty)(metadata, 'imports', TUI_VCR_CLASS, { unique: true });
|
|
56
|
+
if (hasExistingImports) {
|
|
57
|
+
(0, add_unique_import_1.addUniqueImport)(sourceFile.getFilePath(), TUI_VCR_CLASS, TAIGA_CDK);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else if (ng_morph_1.Node.isPropertyAssignment(templateUrlProp)) {
|
|
61
|
+
const templateUrlInit = templateUrlProp.getInitializer();
|
|
62
|
+
if (!templateUrlInit) {
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
const templateUrl = templateUrlInit.getText().replaceAll(/['"`]/g, '');
|
|
66
|
+
const componentDir = path.dirname(sourceFile.getFilePath());
|
|
67
|
+
const templatePath = path.join(componentDir, templateUrl);
|
|
68
|
+
const content = (_a = tree.read(templatePath)) === null || _a === void 0 ? void 0 : _a.toString();
|
|
69
|
+
if (!(content === null || content === void 0 ? void 0 : content.includes(VIEW_CONTAINER_REF))) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
tree.overwrite(templatePath, content.replaceAll(VIEW_CONTAINER_REF, TUI_VCR_DIRECTIVE));
|
|
73
|
+
(0, push_to_array_property_1.pushToObjectArrayProperty)(metadata, 'imports', TUI_VCR_CLASS, { unique: true });
|
|
74
|
+
(0, add_unique_import_1.addUniqueImport)(sourceFile.getFilePath(), TUI_VCR_CLASS, TAIGA_CDK);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=migrate-portals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-portals.js","sourceRoot":"","sources":["../../../../../../projects/cdk/schematics/ng-update/v5/steps/migrate-portals.ts"],"names":[],"mappings":";;AAiBA,wCAIC;;AArBD,wDAAkC;AAGlC,uCAA8C;AAG9C,kDAAgD;AAEhD,wEAAiE;AACjE,kFAAgF;AAEhF,MAAM,WAAW,GAAG,YAAY,CAAC;AACjC,MAAM,aAAa,GAAG,QAAQ,CAAC;AAC/B,MAAM,iBAAiB,GAAG,QAAQ,CAAC;AACnC,MAAM,SAAS,GAAG,eAAe,CAAC;AAClC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AAE5C,SAAgB,cAAc,CAAC,IAAU,EAAE,QAAmB;IAC1D,IAAA,yBAAc,EAAC,wBAAY,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QAChD,iBAAiB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;AACP,CAAC;AAED,SAAS,iBAAiB,CAAC,UAAsB,EAAE,IAAU;;IACzD,MAAM,mBAAmB,GAAG,UAAU;SACjC,qBAAqB,EAAE;SACvB,IAAI,CACD,CAAC,GAAG,EAAE,EAAE,CACJ,GAAG,CAAC,uBAAuB,EAAE,KAAK,SAAS;QAC3C,GAAG,CAAC,eAAe,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,WAAW,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,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -25,6 +25,7 @@ const migrate_closeable_1 = require("./templates/migrate-closeable");
|
|
|
25
25
|
const migrate_combo_box_1 = require("./templates/migrate-combo-box");
|
|
26
26
|
const migrate_field_error_1 = require("./templates/migrate-field-error");
|
|
27
27
|
const migrate_format_phone_pipe_1 = require("./templates/migrate-format-phone-pipe");
|
|
28
|
+
const migrate_hint_on_legacy_controls_1 = require("./templates/migrate-hint-on-legacy-controls");
|
|
28
29
|
const migrate_input_1 = require("./templates/migrate-input");
|
|
29
30
|
const migrate_input_date_1 = require("./templates/migrate-input-date");
|
|
30
31
|
const migrate_input_date_multi_1 = require("./templates/migrate-input-date-multi");
|
|
@@ -86,6 +87,7 @@ function migrateTemplates(fileSystem, options) {
|
|
|
86
87
|
migrate_sidebar_1.migrateSidebar,
|
|
87
88
|
migrate_format_phone_pipe_1.migrateFormatPhonePipe,
|
|
88
89
|
...(hasProprietaryPackage ? [migrate_proprietary_textfield_icons_1.migrateProprietaryTextfieldIcons] : []),
|
|
90
|
+
migrate_hint_on_legacy_controls_1.migrateHintOnLegacyControls,
|
|
89
91
|
migrate_input_1.migrateInput,
|
|
90
92
|
migrate_textarea_1.migrateTextarea,
|
|
91
93
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-templates.js","sourceRoot":"","sources":["../../../../../../projects/cdk/schematics/ng-update/v5/steps/migrate-templates.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"migrate-templates.js","sourceRoot":"","sources":["../../../../../../projects/cdk/schematics/ng-update/v5/steps/migrate-templates.ts"],"names":[],"mappings":";;AA8DA,8BA0BC;AAED,4CAqEC;AA/JD,uCASkB;AAElB,kDAAgD;AAEhD,8FAA6E;AAC7E,sDAA4D;AAC5D,8FAAuF;AACvF,kFAAuF;AAEvF,qDAM+B;AAC/B,yFAAoF;AACpF,mEAA8D;AAC9D,6DAAwD;AACxD,mEAA8D;AAC9D,iEAA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OAAO,CAAC,WAAW,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;YAChE,MAAM,CAAC,EAAC,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAC,CAAC,CAAC;QAC7C,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAEH,UAAU,CAAC,WAAW,EAAE,CAAC;IAEzB,IAAA,+CAAgB,EAAC,OAAO,CAAC,CAAC;IAE1B,CAAC,OAAO,CAAC,WAAW,CAAC;QACjB,IAAA,qBAAU,EAAC,GAAG,2BAAgB,GAAG,yBAAc,wBAAwB,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.migrateAsyncPipes = migrateAsyncPipes;
|
|
4
4
|
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
|
5
|
-
const SIGNAL_BASED_PIPES = [
|
|
5
|
+
const SIGNAL_BASED_PIPES = [
|
|
6
|
+
'tuiAmount',
|
|
7
|
+
'tuiDecimal',
|
|
8
|
+
'tuiFormatNumber',
|
|
9
|
+
'tuiSortCountries',
|
|
10
|
+
];
|
|
6
11
|
/**
|
|
7
12
|
* Matches `| tuiPipeName` (with optional args) followed by `| async`.
|
|
8
13
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-async-pipes.js","sourceRoot":"","sources":["../../../../../../../projects/cdk/schematics/ng-update/v5/steps/templates/migrate-async-pipes.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"migrate-async-pipes.js","sourceRoot":"","sources":["../../../../../../../projects/cdk/schematics/ng-update/v5/steps/templates/migrate-async-pipes.ts"],"names":[],"mappings":";;AAgCA,8CAsBC;AAnDD,qFAGuD;AAGvD,MAAM,kBAAkB,GAAG;IACvB,WAAW;IACX,YAAY;IACZ,iBAAiB;IACjB,kBAAkB;CACrB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,gBAAgB,GAAG,IAAI,MAAM,CAC/B,MAAM,CAAC,GAAG,CAAA,YAAY,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,iCAAiC,EACnF,IAAI,CACP,CAAC;AAEF,SAAgB,iBAAiB,CAAC,EAC9B,QAAQ,EACR,QAAQ,EACR,UAAU,GAKb;IACG,MAAM,QAAQ,GAAG,IAAA,mDAA+B,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACvE,MAAM,cAAc,GAAG,IAAA,qCAAiB,EAAC,QAAQ,CAAC,CAAC;IAEnD,IAAI,KAAK,CAAC;IAEV,OAAO,CAAC,KAAK,GAAG,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACxD,MAAM,cAAc,GAAG,KAAK,CAAC,KAAK,CAAC;QACnC,MAAM,eAAe,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QACxC,MAAM,gBAAgB,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QAElC,QAAQ,CAAC,MAAM,CAAC,cAAc,GAAG,cAAc,EAAE,eAAe,CAAC,CAAC;QAClE,QAAQ,CAAC,WAAW,CAAC,cAAc,GAAG,cAAc,EAAE,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,EAAE,CAAC,CAAC;IAClF,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type UpdateRecorder } from '@angular-devkit/schematics';
|
|
2
|
+
import { type DevkitFileSystem } from 'ng-morph';
|
|
3
|
+
import { type DefaultTreeAdapterTypes } from 'parse5';
|
|
4
|
+
import { type TemplateResource } from '../../../interfaces/template-resource';
|
|
5
|
+
type Element = DefaultTreeAdapterTypes.Element;
|
|
6
|
+
export declare function buildTuiIconStr(element: Element, template: string): string;
|
|
7
|
+
export declare function migrateHintOnLegacyControls({ resource, recorder, fileSystem, }: {
|
|
8
|
+
fileSystem: DevkitFileSystem;
|
|
9
|
+
recorder: UpdateRecorder;
|
|
10
|
+
resource: TemplateResource;
|
|
11
|
+
}): void;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildTuiIconStr = buildTuiIconStr;
|
|
4
|
+
exports.migrateHintOnLegacyControls = migrateHintOnLegacyControls;
|
|
5
|
+
const add_import_to_closest_module_1 = require("../../../../utils/add-import-to-closest-module");
|
|
6
|
+
const elements_1 = require("../../../../utils/templates/elements");
|
|
7
|
+
const migrate_attr_value_1 = require("../../../../utils/templates/migrate-attr-value");
|
|
8
|
+
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
|
9
|
+
const migrate_input_1 = require("./migrate-input");
|
|
10
|
+
const migrate_textarea_1 = require("./migrate-textarea");
|
|
11
|
+
/** Legacy controls that contain tuiHintContent and need migration. */
|
|
12
|
+
const LEGACY_CONTROLS = new Set([
|
|
13
|
+
'tui-combo-box',
|
|
14
|
+
'tui-input',
|
|
15
|
+
'tui-input-date',
|
|
16
|
+
'tui-input-date-range',
|
|
17
|
+
'tui-input-number',
|
|
18
|
+
'tui-input-phone',
|
|
19
|
+
'tui-input-tag',
|
|
20
|
+
'tui-input-time',
|
|
21
|
+
'tui-multi-select',
|
|
22
|
+
'tui-select',
|
|
23
|
+
'tui-textarea',
|
|
24
|
+
]);
|
|
25
|
+
const HINT_ATTR_NAMES = [
|
|
26
|
+
'[tuiHintAppearance]',
|
|
27
|
+
'[tuiHintContent]',
|
|
28
|
+
'[tuiHintDirection]',
|
|
29
|
+
'tuiHintAppearance',
|
|
30
|
+
'tuiHintContent',
|
|
31
|
+
'tuiHintDirection',
|
|
32
|
+
];
|
|
33
|
+
function hasHintContent(element) {
|
|
34
|
+
return element.attrs.some((attr) => {
|
|
35
|
+
const lower = attr.name.toLowerCase();
|
|
36
|
+
return (lower === 'tuiHintContent'.toLowerCase() ||
|
|
37
|
+
lower === '[tuiHintContent]'.toLowerCase());
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function getOriginalAttrText(template, element, attrNameLower) {
|
|
41
|
+
var _a, _b;
|
|
42
|
+
const attrLoc = (_b = (_a = element.sourceCodeLocation) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b[attrNameLower];
|
|
43
|
+
if (!attrLoc) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
return template.slice(attrLoc.startOffset, attrLoc.endOffset);
|
|
47
|
+
}
|
|
48
|
+
function buildTuiIconStr(element, template) {
|
|
49
|
+
const contentAttr = element.attrs.find((a) => {
|
|
50
|
+
const lower = a.name.toLowerCase();
|
|
51
|
+
return (lower === '[tuiHintContent]'.toLowerCase() ||
|
|
52
|
+
lower === 'tuiHintContent'.toLowerCase());
|
|
53
|
+
});
|
|
54
|
+
if (!contentAttr) {
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
const isBinding = contentAttr.name.toLowerCase() === '[tuiHintContent]'.toLowerCase();
|
|
58
|
+
const tooltipAttr = isBinding
|
|
59
|
+
? `[tuiTooltip]="${contentAttr.value}"`
|
|
60
|
+
: `tuiTooltip="${contentAttr.value}"`;
|
|
61
|
+
const appearanceAttr = element.attrs.find((a) => {
|
|
62
|
+
const lower = a.name.toLowerCase();
|
|
63
|
+
return (lower === '[tuiHintAppearance]'.toLowerCase() ||
|
|
64
|
+
lower === 'tuiHintAppearance'.toLowerCase());
|
|
65
|
+
});
|
|
66
|
+
const directionAttr = element.attrs.find((a) => {
|
|
67
|
+
const lower = a.name.toLowerCase();
|
|
68
|
+
return (lower === '[tuiHintDirection]'.toLowerCase() ||
|
|
69
|
+
lower === 'tuiHintDirection'.toLowerCase());
|
|
70
|
+
});
|
|
71
|
+
const extraAttrs = [];
|
|
72
|
+
if (appearanceAttr) {
|
|
73
|
+
const original = getOriginalAttrText(template, element, appearanceAttr.name.toLowerCase());
|
|
74
|
+
extraAttrs.push(original !== null && original !== void 0 ? original : (appearanceAttr.value
|
|
75
|
+
? `${appearanceAttr.name}="${appearanceAttr.value}"`
|
|
76
|
+
: appearanceAttr.name));
|
|
77
|
+
}
|
|
78
|
+
if (directionAttr) {
|
|
79
|
+
const nameLower = directionAttr.name.toLowerCase();
|
|
80
|
+
const migratedValue = (0, migrate_attr_value_1.migrateAttrValue)(nameLower, directionAttr.value);
|
|
81
|
+
const original = getOriginalAttrText(template, element, nameLower);
|
|
82
|
+
let attrText;
|
|
83
|
+
if (original && directionAttr.value !== migratedValue) {
|
|
84
|
+
attrText = original.replace(`="${directionAttr.value}"`, `="${migratedValue}"`);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
attrText =
|
|
88
|
+
original !== null && original !== void 0 ? original : (directionAttr.value
|
|
89
|
+
? `${directionAttr.name}="${migratedValue}"`
|
|
90
|
+
: directionAttr.name);
|
|
91
|
+
}
|
|
92
|
+
extraAttrs.push(attrText);
|
|
93
|
+
}
|
|
94
|
+
const allAttrs = [tooltipAttr, ...extraAttrs];
|
|
95
|
+
return `<tui-icon ${allAttrs.join(' ')} />`;
|
|
96
|
+
}
|
|
97
|
+
function removeAttr(recorder, templateOffset, element, name, template) {
|
|
98
|
+
var _a, _b;
|
|
99
|
+
const attrLocation = (_b = (_a = element.sourceCodeLocation) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b[name.toLowerCase()];
|
|
100
|
+
if (!attrLocation) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const lineStart = template.lastIndexOf('\n', attrLocation.startOffset) + 1;
|
|
104
|
+
const lineEnd = template.indexOf('\n', attrLocation.endOffset);
|
|
105
|
+
const attrText = template.slice(attrLocation.startOffset, attrLocation.endOffset);
|
|
106
|
+
const lineText = lineEnd === -1 ? '' : template.slice(lineStart, lineEnd);
|
|
107
|
+
if (lineText.trim() === attrText.trim() && lineEnd !== -1) {
|
|
108
|
+
recorder.remove(templateOffset + lineStart, lineEnd - lineStart + 1);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
recorder.remove(templateOffset + attrLocation.startOffset - 1, attrLocation.endOffset - attrLocation.startOffset + 1);
|
|
112
|
+
}
|
|
113
|
+
function migrateHintOnLegacyControls({ resource, recorder, fileSystem, }) {
|
|
114
|
+
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
|
115
|
+
const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
|
|
116
|
+
const elements = (0, elements_1.findElementsInTemplateByFn)(template, (el) => LEGACY_CONTROLS.has(el.tagName) && hasHintContent(el));
|
|
117
|
+
if (elements.length === 0) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
(0, add_import_to_closest_module_1.addImportToClosestModule)(resource.componentPath, 'TuiIcon', '@taiga-ui/core');
|
|
121
|
+
(0, add_import_to_closest_module_1.addImportToClosestModule)(resource.componentPath, 'TuiTooltip', '@taiga-ui/kit');
|
|
122
|
+
elements.forEach((element) => {
|
|
123
|
+
var _a;
|
|
124
|
+
const loc = element.sourceCodeLocation;
|
|
125
|
+
if (!loc) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
const isSelfClosing = !loc.endTag;
|
|
129
|
+
const tagName = element.tagName;
|
|
130
|
+
const tuiIconStr = buildTuiIconStr(element, template);
|
|
131
|
+
if (!tuiIconStr) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
if (!isSelfClosing && tagName === 'tui-input') {
|
|
135
|
+
const result = (0, migrate_input_1.buildTuiInputReplacement)(template, element, tuiIconStr);
|
|
136
|
+
if (result) {
|
|
137
|
+
recorder.remove(templateOffset + result.startOffset, result.endOffset - result.startOffset);
|
|
138
|
+
recorder.insertRight(templateOffset + result.startOffset, result.replacement);
|
|
139
|
+
}
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (!isSelfClosing && tagName === 'tui-textarea') {
|
|
143
|
+
const result = (0, migrate_textarea_1.buildTuiTextareaReplacement)(template, element, tuiIconStr);
|
|
144
|
+
if (result) {
|
|
145
|
+
recorder.remove(templateOffset + result.startOffset, result.endOffset - result.startOffset);
|
|
146
|
+
recorder.insertRight(templateOffset + result.startOffset, result.replacement);
|
|
147
|
+
}
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (isSelfClosing) {
|
|
151
|
+
const nonHintAttrs = element.attrs
|
|
152
|
+
.filter((attr) => !HINT_ATTR_NAMES.some((n) => n.toLowerCase() === attr.name.toLowerCase()))
|
|
153
|
+
.map((attr) => {
|
|
154
|
+
const original = getOriginalAttrText(template, element, attr.name.toLowerCase());
|
|
155
|
+
return (original !== null && original !== void 0 ? original : (attr.value ? `${attr.name}="${attr.value}"` : attr.name));
|
|
156
|
+
});
|
|
157
|
+
const attrsStr = nonHintAttrs.length > 0 ? ` ${nonHintAttrs.join(' ')}` : '';
|
|
158
|
+
const replacement = `<${tagName}${attrsStr}>${tuiIconStr}</${tagName}>`;
|
|
159
|
+
recorder.remove(templateOffset + loc.startOffset, loc.endOffset - loc.startOffset);
|
|
160
|
+
recorder.insertRight(templateOffset + loc.startOffset, replacement);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
for (const attrName of HINT_ATTR_NAMES) {
|
|
164
|
+
removeAttr(recorder, templateOffset, element, attrName, template);
|
|
165
|
+
}
|
|
166
|
+
const insertOffset = (_a = loc.endTag) === null || _a === void 0 ? void 0 : _a.startOffset;
|
|
167
|
+
insertOffset &&
|
|
168
|
+
recorder.insertRight(templateOffset + insertOffset, `${tuiIconStr}\n`);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=migrate-hint-on-legacy-controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-hint-on-legacy-controls.js","sourceRoot":"","sources":["../../../../../../../projects/cdk/schematics/ng-update/v5/steps/templates/migrate-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,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7E,MAAM,WAAW,GAAG,IAAI,OAAO,GAAG,QAAQ,IAAI,UAAU,KAAK,OAAO,GAAG,CAAC;YAExE,QAAQ,CAAC,MAAM,CACX,cAAc,GAAG,GAAG,CAAC,WAAW,EAChC,GAAG,CAAC,SAAS,GAAG,GAAG,CAAC,WAAW,CAClC,CAAC;YACF,QAAQ,CAAC,WAAW,CAAC,cAAc,GAAG,GAAG,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;QACxE,CAAC;aAAM,CAAC;YACJ,KAAK,MAAM,QAAQ,IAAI,eAAe,EAAE,CAAC;gBACrC,UAAU,CAAC,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACtE,CAAC;YAED,MAAM,YAAY,GAAG,MAAA,GAAG,CAAC,MAAM,0CAAE,WAAW,CAAC;YAE7C,YAAY;gBACR,QAAQ,CAAC,WAAW,CAAC,cAAc,GAAG,YAAY,EAAE,GAAG,UAAU,IAAI,CAAC,CAAC;QAC/E,CAAC;IACL,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { type UpdateRecorder } from '@angular-devkit/schematics';
|
|
2
2
|
import { type DevkitFileSystem } from 'ng-morph';
|
|
3
|
+
import { type DefaultTreeAdapterTypes } from 'parse5';
|
|
3
4
|
import { type TemplateResource } from '../../../interfaces/template-resource';
|
|
5
|
+
type Element = DefaultTreeAdapterTypes.Element;
|
|
4
6
|
export declare function migrateInput({ resource, recorder, fileSystem, }: {
|
|
5
7
|
fileSystem: DevkitFileSystem;
|
|
6
8
|
recorder: UpdateRecorder;
|
|
7
9
|
resource: TemplateResource;
|
|
8
10
|
}): void;
|
|
11
|
+
export declare function buildTuiInputReplacement(template: string, element: Element, hintIconStr?: string): {
|
|
12
|
+
startOffset: number;
|
|
13
|
+
endOffset: number;
|
|
14
|
+
replacement: string;
|
|
15
|
+
} | null;
|
|
16
|
+
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.migrateInput = migrateInput;
|
|
4
|
+
exports.buildTuiInputReplacement = buildTuiInputReplacement;
|
|
4
5
|
const insert_todo_1 = require("../../../../utils/insert-todo");
|
|
5
6
|
const elements_1 = require("../../../../utils/templates/elements");
|
|
6
7
|
const migrate_attr_value_1 = require("../../../../utils/templates/migrate-attr-value");
|
|
@@ -15,16 +16,18 @@ const CONTROL_ATTR_NAMES = [
|
|
|
15
16
|
'ngModel',
|
|
16
17
|
];
|
|
17
18
|
const CONTROL_ATTRS = new Set(CONTROL_ATTR_NAMES.map((name) => name.toLowerCase()));
|
|
18
|
-
const
|
|
19
|
+
const HINT_ATTRS = new Set([
|
|
19
20
|
'[tuiHintAppearance]'.toLowerCase(),
|
|
20
21
|
'[tuiHintContent]'.toLowerCase(),
|
|
21
22
|
'[tuiHintDirection]'.toLowerCase(),
|
|
22
|
-
'[tuiTextfieldAppearance]'.toLowerCase(),
|
|
23
|
-
'[tuiTextfieldCleaner]'.toLowerCase(),
|
|
24
|
-
'[tuiTextfieldSize]'.toLowerCase(),
|
|
25
23
|
'tuiHintAppearance'.toLowerCase(),
|
|
26
24
|
'tuiHintContent'.toLowerCase(),
|
|
27
25
|
'tuiHintDirection'.toLowerCase(),
|
|
26
|
+
]);
|
|
27
|
+
const TEXTFIELD_WRAPPER_ATTRS = new Set([
|
|
28
|
+
'[tuiTextfieldAppearance]'.toLowerCase(),
|
|
29
|
+
'[tuiTextfieldCleaner]'.toLowerCase(),
|
|
30
|
+
'[tuiTextfieldSize]'.toLowerCase(),
|
|
28
31
|
'tuiTextfieldAppearance'.toLowerCase(),
|
|
29
32
|
'tuiTextfieldCleaner'.toLowerCase(),
|
|
30
33
|
'tuiTextfieldSize'.toLowerCase(),
|
|
@@ -58,12 +61,20 @@ function isDropdownAttr(nameLower) {
|
|
|
58
61
|
const stripped = nameLower.replaceAll(/^\[|\]$|\(|\)/g, '');
|
|
59
62
|
return stripped.startsWith(prefix);
|
|
60
63
|
}
|
|
64
|
+
function hasHintContent(element) {
|
|
65
|
+
return element.attrs.some((attr) => {
|
|
66
|
+
const lower = attr.name.toLowerCase();
|
|
67
|
+
return (lower === 'tuiHintContent'.toLowerCase() ||
|
|
68
|
+
lower === '[tuiHintContent]'.toLowerCase());
|
|
69
|
+
});
|
|
70
|
+
}
|
|
61
71
|
function migrateInput({ resource, recorder, fileSystem, }) {
|
|
62
72
|
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
|
63
73
|
const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
|
|
64
74
|
const elements = (0, elements_1.findElementsByTagName)(template, 'tui-input');
|
|
65
75
|
const replacements = elements
|
|
66
|
-
.
|
|
76
|
+
.filter((element) => !hasHintContent(element))
|
|
77
|
+
.map((element) => buildTuiInputReplacement(template, element))
|
|
67
78
|
.filter((x) => Boolean(x))
|
|
68
79
|
.sort((a, b) => b.startOffset - a.startOffset);
|
|
69
80
|
replacements.forEach(({ startOffset, endOffset, replacement }) => {
|
|
@@ -71,6 +82,9 @@ function migrateInput({ resource, recorder, fileSystem, }) {
|
|
|
71
82
|
recorder.insertRight(templateOffset + startOffset, replacement);
|
|
72
83
|
});
|
|
73
84
|
}
|
|
85
|
+
function buildTuiInputReplacement(template, element, hintIconStr = '') {
|
|
86
|
+
return buildReplacement(template, element, hintIconStr);
|
|
87
|
+
}
|
|
74
88
|
function getOriginalAttrText(template, element, attrNameLower) {
|
|
75
89
|
var _a, _b;
|
|
76
90
|
const attrLoc = (_b = (_a = element.sourceCodeLocation) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b[attrNameLower];
|
|
@@ -79,7 +93,7 @@ function getOriginalAttrText(template, element, attrNameLower) {
|
|
|
79
93
|
}
|
|
80
94
|
return template.slice(attrLoc.startOffset, attrLoc.endOffset);
|
|
81
95
|
}
|
|
82
|
-
function buildReplacement(template, element) {
|
|
96
|
+
function buildReplacement(template, element, hintIconStr = '') {
|
|
83
97
|
var _a, _b, _c, _d, _e, _f;
|
|
84
98
|
const loc = element.sourceCodeLocation;
|
|
85
99
|
if (!(loc === null || loc === void 0 ? void 0 : loc.startTag) || !loc.endTag) {
|
|
@@ -130,6 +144,9 @@ function buildReplacement(template, element) {
|
|
|
130
144
|
textfieldAttrs.push(attrText);
|
|
131
145
|
continue;
|
|
132
146
|
}
|
|
147
|
+
if (HINT_ATTRS.has(nameLower)) {
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
133
150
|
if (CONTROL_ATTRS.has(nameLower)) {
|
|
134
151
|
const original = getOriginalAttrText(template, element, nameLower);
|
|
135
152
|
inputAttrs.push(original !== null && original !== void 0 ? original : (attr.value
|
|
@@ -150,10 +167,14 @@ function buildReplacement(template, element) {
|
|
|
150
167
|
const isLabelOutsideTrue = ctx.labelOutsideValue === 'true' ||
|
|
151
168
|
(!ctx.labelOutsideIsBinding && ctx.labelOutsideValue === '');
|
|
152
169
|
const wrapperAttrsStr = textfieldAttrs.length > 0 ? ` ${textfieldAttrs.join(' ')}` : '';
|
|
153
|
-
const innerContent = buildInnerContent(
|
|
170
|
+
const innerContent = buildInnerContent({
|
|
171
|
+
element,
|
|
172
|
+
template,
|
|
173
|
+
inputAttrs,
|
|
154
174
|
placeholder: ctx.placeholder,
|
|
155
175
|
indent,
|
|
156
176
|
labelOutsideIsTrue: isLabelOutsideTrue,
|
|
177
|
+
hintIconStr,
|
|
157
178
|
});
|
|
158
179
|
const todoComment = buildTodoComment(ctx);
|
|
159
180
|
// `indent` is added before <tui-textfield> only when there is a TODO — in that case
|
|
@@ -199,12 +220,20 @@ function buildTodoComment(ctx) {
|
|
|
199
220
|
];
|
|
200
221
|
return `${lines.join('\n')}\n`;
|
|
201
222
|
}
|
|
202
|
-
function buildInnerContent(element, template, inputAttrs,
|
|
223
|
+
function buildInnerContent({ element, template, inputAttrs, placeholder, indent, labelOutsideIsTrue, hintIconStr, }) {
|
|
203
224
|
const childElements = element.childNodes.filter((node) => node.nodeName !== '#text' && node.nodeName !== '#comment');
|
|
204
225
|
const legacyInnerInput = childElements.find((node) => node.nodeName === 'input' &&
|
|
205
226
|
node.attrs.some((a) => LEGACY_INPUT_ATTRS.has(a.name.toLowerCase())));
|
|
227
|
+
const hintIconLine = hintIconStr ? `${hintIconStr}\n` : '';
|
|
206
228
|
if (legacyInnerInput) {
|
|
207
|
-
return migrateInnerInput(
|
|
229
|
+
return migrateInnerInput({
|
|
230
|
+
inner: legacyInnerInput,
|
|
231
|
+
template,
|
|
232
|
+
attrsToAdd: inputAttrs,
|
|
233
|
+
allChildren: childElements,
|
|
234
|
+
indent,
|
|
235
|
+
hintIconLine,
|
|
236
|
+
});
|
|
208
237
|
}
|
|
209
238
|
const attrsStr = inputAttrs.length > 0 ? ` ${inputAttrs.join(' ')}` : '';
|
|
210
239
|
const otherChildren = childElements
|
|
@@ -218,19 +247,19 @@ function buildInnerContent(element, template, inputAttrs, { placeholder, indent,
|
|
|
218
247
|
if (labelOutsideIsTrue) {
|
|
219
248
|
// labelOutside=true: text → placeholder on <input>, no label inside
|
|
220
249
|
const placeholderAttr = placeholder ? ` placeholder="${placeholder}"` : '';
|
|
221
|
-
return `${indent}<input${placeholderAttr}${attrsStr} />\n${otherChildren}`;
|
|
250
|
+
return `${indent}<input${placeholderAttr}${attrsStr} />\n${otherChildren}${hintIconLine}`;
|
|
222
251
|
}
|
|
223
252
|
// labelOutside=false/absent: text → <label tuiLabel> inside (floating label)
|
|
224
253
|
const labelEl = placeholder
|
|
225
254
|
? `${indent}<label tuiLabel>${placeholder}</label>\n`
|
|
226
255
|
: '';
|
|
227
|
-
return `${labelEl}${indent}<input${attrsStr} />\n${otherChildren}`;
|
|
256
|
+
return `${labelEl}${indent}<input${attrsStr} />\n${otherChildren}${hintIconLine}`;
|
|
228
257
|
}
|
|
229
258
|
/**
|
|
230
259
|
* Rewrites an existing <input tuiTextfieldLegacy> to <input tuiInput ...>
|
|
231
260
|
* by replacing the legacy directive attr and appending form control attrs.
|
|
232
261
|
*/
|
|
233
|
-
function migrateInnerInput(inner, template, attrsToAdd, allChildren, indent) {
|
|
262
|
+
function migrateInnerInput({ inner, template, attrsToAdd, allChildren, indent, hintIconLine = '', }) {
|
|
234
263
|
var _a;
|
|
235
264
|
const innerLoc = inner.sourceCodeLocation;
|
|
236
265
|
if (!(innerLoc === null || innerLoc === void 0 ? void 0 : innerLoc.startTag)) {
|
|
@@ -259,7 +288,7 @@ function migrateInnerInput(inner, template, attrsToAdd, allChildren, indent) {
|
|
|
259
288
|
return loc ? template.slice(loc.startOffset, loc.endOffset) : '';
|
|
260
289
|
})
|
|
261
290
|
.join('');
|
|
262
|
-
return `${indent}${startTag}\n${siblings}`;
|
|
291
|
+
return `${indent}${startTag}\n${siblings}${hintIconLine}`;
|
|
263
292
|
}
|
|
264
293
|
/**
|
|
265
294
|
* Returns the position just before the closing `>` or `/>` in a void element tag string.
|