@taiga-ui/cdk 5.13.0 → 5.14.0-canary.41d4be7
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/version.d.ts +1 -1
- package/constants/version.js +1 -1
- package/constants/version.js.map +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-truncate.mjs +3 -3
- package/fesm2022/taiga-ui-cdk-directives-truncate.mjs.map +1 -1
- package/fesm2022/taiga-ui-cdk-portals.mjs.map +1 -1
- package/package.json +2 -3
- package/portals/portals.d.ts +3 -2
- package/schematics/ng-add/constants/versions.d.ts +1 -1
- package/schematics/ng-update/utils/replace-function-parameters.js +20 -8
- package/schematics/ng-update/utils/replace-function-parameters.js.map +1 -1
- package/schematics/ng-update/v5/index.js +15 -0
- package/schematics/ng-update/v5/index.js.map +1 -1
- package/schematics/ng-update/v5/steps/constants/attrs-to-replace.js +8 -0
- package/schematics/ng-update/v5/steps/constants/attrs-to-replace.js.map +1 -1
- package/schematics/ng-update/v5/steps/constants/html-comments.js +28 -0
- package/schematics/ng-update/v5/steps/constants/html-comments.js.map +1 -1
- package/schematics/ng-update/v5/steps/constants/identifiers-to-replace.js +122 -12
- 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 +4 -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 +82 -0
- package/schematics/ng-update/v5/steps/constants/migration-warnings.js.map +1 -1
- package/schematics/ng-update/v5/steps/constants/tags-to-replace.js +4 -0
- package/schematics/ng-update/v5/steps/constants/tags-to-replace.js.map +1 -1
- package/schematics/ng-update/v5/steps/migrate-css-variables.js +2 -2
- package/schematics/ng-update/v5/steps/migrate-css-variables.js.map +1 -1
- package/schematics/ng-update/v5/steps/migrate-dialog-header.d.ts +3 -0
- package/schematics/ng-update/v5/steps/migrate-dialog-header.js +30 -0
- package/schematics/ng-update/v5/steps/migrate-dialog-header.js.map +1 -0
- package/schematics/ng-update/v5/steps/migrate-dialog-legacy-sizes.js +8 -14
- package/schematics/ng-update/v5/steps/migrate-dialog-legacy-sizes.js.map +1 -1
- package/schematics/ng-update/v5/steps/migrate-hint-directive-binding.d.ts +3 -0
- package/schematics/ng-update/v5/steps/migrate-hint-directive-binding.js +38 -0
- package/schematics/ng-update/v5/steps/migrate-hint-directive-binding.js.map +1 -0
- package/schematics/ng-update/v5/steps/migrate-range-token.d.ts +3 -0
- package/schematics/ng-update/v5/steps/migrate-range-token.js +38 -0
- package/schematics/ng-update/v5/steps/migrate-range-token.js.map +1 -0
- package/schematics/ng-update/v5/steps/migrate-templates.js +10 -0
- package/schematics/ng-update/v5/steps/migrate-templates.js.map +1 -1
- package/schematics/ng-update/v5/steps/templates/migrate-avatar.js +37 -0
- package/schematics/ng-update/v5/steps/templates/migrate-avatar.js.map +1 -1
- package/schematics/ng-update/v5/steps/templates/migrate-format-phone-pipe.js +2 -2
- package/schematics/ng-update/v5/steps/templates/migrate-format-phone-pipe.js.map +1 -1
- package/schematics/ng-update/v5/steps/templates/migrate-input-date-time.d.ts +8 -0
- package/schematics/ng-update/v5/steps/templates/migrate-input-date-time.js +132 -0
- package/schematics/ng-update/v5/steps/templates/migrate-input-date-time.js.map +1 -0
- package/schematics/ng-update/v5/steps/templates/migrate-input-month-range.d.ts +8 -0
- package/schematics/ng-update/v5/steps/templates/migrate-input-month-range.js +127 -0
- package/schematics/ng-update/v5/steps/templates/migrate-input-month-range.js.map +1 -0
- package/schematics/ng-update/v5/steps/templates/migrate-input-number.d.ts +8 -0
- package/schematics/ng-update/v5/steps/templates/migrate-input-number.js +111 -0
- package/schematics/ng-update/v5/steps/templates/migrate-input-number.js.map +1 -0
- package/schematics/ng-update/v5/steps/templates/migrate-input-phone.js +1 -1
- package/schematics/ng-update/v5/steps/templates/migrate-input-phone.js.map +1 -1
- package/schematics/ng-update/v5/steps/templates/migrate-input-slider.d.ts +8 -0
- package/schematics/ng-update/v5/steps/templates/migrate-input-slider.js +178 -0
- package/schematics/ng-update/v5/steps/templates/migrate-input-slider.js.map +1 -0
- package/schematics/ng-update/v5/steps/templates/migrate-input-tag.js +8 -2
- package/schematics/ng-update/v5/steps/templates/migrate-input-tag.js.map +1 -1
- package/schematics/ng-update/v5/steps/templates/migrate-repeat-times.js +31 -9
- package/schematics/ng-update/v5/steps/templates/migrate-repeat-times.js.map +1 -1
- package/schematics/ng-update/v5/steps/templates/migrate-tooltip.d.ts +8 -0
- package/schematics/ng-update/v5/steps/templates/migrate-tooltip.js +49 -0
- package/schematics/ng-update/v5/steps/templates/migrate-tooltip.js.map +1 -0
- package/schematics/ng-update/v5/steps/utils/get-dialog-options.d.ts +10 -0
- package/schematics/ng-update/v5/steps/utils/get-dialog-options.js +28 -0
- package/schematics/ng-update/v5/steps/utils/get-dialog-options.js.map +1 -0
- package/schematics/utils/insert-todo.d.ts +1 -0
- package/schematics/utils/insert-todo.js +2 -1
- package/schematics/utils/insert-todo.js.map +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-range-token.js","sourceRoot":"","sources":["../../../../../../projects/cdk/schematics/ng-update/v5/steps/migrate-range-token.ts"],"names":[],"mappings":";;AAmBA,8CA4BC;AA9CD,uCAA8B;AAG9B,wEAAiE;AACjE,4FAAoF;AACpF,8EAAiE;AAEjE,MAAM,SAAS,GAAG,eAAe,CAAC;AAClC,MAAM,WAAW,GAAG,WAAW,CAAC;AAChC,MAAM,YAAY,GAAG,eAAe,CAAC;AACrC,MAAM,cAAc,GAAG,iBAAiB,CAAC;AACzC,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAChD,MAAM,WAAW,GAAG,aAAa,CAAC;AAElC,MAAM,iBAAiB,GAAG,GAAG,mBAAmB,WAAW,WAAW;;+BAEvC,CAAC;AAEhC,SAAgB,iBAAiB,CAAC,KAAW,EAAE,QAAmB;IAC9D,IAAA,sDAAwB,EAAC,WAAW,EAAE,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QAC7D,IAAI,GAAG,CAAC,YAAY,EAAE,EAAE,CAAC;YACrB,OAAO;QACX,CAAC;QAED,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC;QAE/B,IAAI,eAAI,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC;YACjC,IAAA,mCAAY,EAAC,MAAM,CAAC,CAAC;YAErB,OAAO;QACX,CAAC;QAED,MAAM,gBAAgB,GAClB,eAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC;YAC7B,MAAM,CAAC,aAAa,EAAE,CAAC,OAAO,EAAE,KAAK,QAAQ,CAAC;QAElD,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACpB,OAAO;QACX,CAAC;QAED,MAAM,QAAQ,GAAG,GAAG,CAAC,aAAa,EAAE,CAAC,WAAW,EAAE,CAAC;QAEnD,MAAM,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;QAC1C,IAAA,mCAAe,EAAC,QAAQ,EAAE,mBAAmB,EAAE,cAAc,CAAC,CAAC;QAC/D,IAAA,mCAAe,EAAC,QAAQ,EAAE,WAAW,EAAE,YAAY,CAAC,CAAC;IACzD,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -30,10 +30,14 @@ const migrate_input_1 = require("./templates/migrate-input");
|
|
|
30
30
|
const migrate_input_date_1 = require("./templates/migrate-input-date");
|
|
31
31
|
const migrate_input_date_multi_1 = require("./templates/migrate-input-date-multi");
|
|
32
32
|
const migrate_input_date_range_1 = require("./templates/migrate-input-date-range");
|
|
33
|
+
const migrate_input_date_time_1 = require("./templates/migrate-input-date-time");
|
|
33
34
|
const migrate_input_month_1 = require("./templates/migrate-input-month");
|
|
35
|
+
const migrate_input_month_range_1 = require("./templates/migrate-input-month-range");
|
|
36
|
+
const migrate_input_number_1 = require("./templates/migrate-input-number");
|
|
34
37
|
const migrate_input_password_1 = require("./templates/migrate-input-password");
|
|
35
38
|
const migrate_input_phone_1 = require("./templates/migrate-input-phone");
|
|
36
39
|
const migrate_input_phone_international_1 = require("./templates/migrate-input-phone-international");
|
|
40
|
+
const migrate_input_slider_1 = require("./templates/migrate-input-slider");
|
|
37
41
|
const migrate_input_tag_1 = require("./templates/migrate-input-tag");
|
|
38
42
|
const migrate_input_time_1 = require("./templates/migrate-input-time");
|
|
39
43
|
const migrate_input_year_1 = require("./templates/migrate-input-year");
|
|
@@ -45,6 +49,7 @@ const migrate_select_1 = require("./templates/migrate-select");
|
|
|
45
49
|
const migrate_sidebar_1 = require("./templates/migrate-sidebar");
|
|
46
50
|
const migrate_tag_1 = require("./templates/migrate-tag");
|
|
47
51
|
const migrate_textarea_1 = require("./templates/migrate-textarea");
|
|
52
|
+
const migrate_tooltip_1 = require("./templates/migrate-tooltip");
|
|
48
53
|
function getAction({ action, requiredData, }) {
|
|
49
54
|
return ({ resource, fileSystem, recorder, }) => action({ resource, fileSystem, recorder, data: requiredData });
|
|
50
55
|
}
|
|
@@ -60,19 +65,24 @@ function migrateTemplates(fileSystem, options) {
|
|
|
60
65
|
getAction({ action: templates_1.removeInputs, requiredData: inputs_to_remove_1.INPUTS_TO_REMOVE }),
|
|
61
66
|
migrate_input_password_1.migrateInputPassword,
|
|
62
67
|
migrate_input_month_1.migrateInputMonth,
|
|
68
|
+
migrate_input_month_range_1.migrateInputMonthRange,
|
|
69
|
+
migrate_input_date_time_1.migrateInputDateTime,
|
|
63
70
|
migrate_input_date_1.migrateInputDate,
|
|
71
|
+
migrate_input_slider_1.migrateInputSlider,
|
|
64
72
|
migrate_input_time_1.migrateInputTime,
|
|
65
73
|
migrate_input_phone_international_1.migrateInputPhoneInternational,
|
|
66
74
|
migrate_input_date_multi_1.migrateInputDateMulti,
|
|
67
75
|
migrate_input_tag_1.migrateInputTag,
|
|
68
76
|
migrate_input_year_1.migrateInputYear,
|
|
69
77
|
migrate_input_phone_1.migrateInputPhone,
|
|
78
|
+
migrate_input_number_1.migrateInputNumber,
|
|
70
79
|
migrate_input_date_range_1.migrateInputDateRange,
|
|
71
80
|
migrate_multi_select_1.migrateMultiSelect,
|
|
72
81
|
migrate_select_1.migrateSelect,
|
|
73
82
|
migrate_combo_box_1.migrateComboBox,
|
|
74
83
|
migrate_accordion_1.migrateAccordionItem,
|
|
75
84
|
migrate_avatar_1.migrateAvatarToDirective,
|
|
85
|
+
migrate_tooltip_1.migrateTooltip,
|
|
76
86
|
migrate_notification_1.migrateTuiNotification,
|
|
77
87
|
migrate_repeat_times_1.migrateRepeatTimes,
|
|
78
88
|
migrate_field_error_1.migrateFieldError,
|
|
@@ -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":";;AAiEA,8BA0BC;AAED,4CAqEC;AAhKD,kDAAgD;AAEhD,4DAMoC;AACpC,sDAA4D;AAC5D,8FAAuF;AACvF,kFAAuF;AAEvF,qDAM+B;AAC/B,yFAAoF;AACpF,mEAA8D;AAC9D,6DAAwD;AACxD,mEAA8D;AAC9D,iEAA4D;AAC5D,qEAAmE;AACnE,6FAAqF;AACrF,yEAAkE;AAClE,+DAAoE;AACpE,2DAAqD;AACrD,6FAAqF;AACrF,uEAAgE;AAChE,qEAA+D;AAC/D,qEAA8D;AAC9D,qFAA8E;AAC9E,yEAAkE;AAClE,qFAA6E;AAC7E,iGAAwF;AACxF,6DAAuD;AACvD,uEAAgE;AAChE,mFAA2E;AAC3E,mFAA2E;AAC3E,iFAAyE;AACzE,yEAAkE;AAClE,qFAA6E;AAC7E,2EAAo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AG,4BAAc,wBAAwB,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.migrateAvatarToDirective = migrateAvatarToDirective;
|
|
4
|
+
const insert_todo_1 = require("../../../../utils/insert-todo");
|
|
4
5
|
const elements_1 = require("../../../../utils/templates/elements");
|
|
5
6
|
const inputs_1 = require("../../../../utils/templates/inputs");
|
|
6
7
|
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
|
7
8
|
const remove_attrs_1 = require("../../../utils/remove-attrs");
|
|
8
9
|
const replace_tag_1 = require("../../../utils/templates/replace-tag");
|
|
10
|
+
const SAFE_RESOURCE_URL_TODO = 'tuiAvatar accepts only a string (icon name or URL). If this value is a SafeResourceUrl or another non-string image source, render it via an inner <img> instead: <span tuiAvatar><img [src]="..." alt="" /></span>.';
|
|
9
11
|
function migrateAvatarToDirective({ resource, recorder, fileSystem, }) {
|
|
10
12
|
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
|
11
13
|
const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
|
|
@@ -36,6 +38,7 @@ function migrateAvatarToDirective({ resource, recorder, fileSystem, }) {
|
|
|
36
38
|
if (!srcAttr || (tuiAvatarAttr === null || tuiAvatarAttr === void 0 ? void 0 : tuiAvatarAttr.value)) {
|
|
37
39
|
return;
|
|
38
40
|
}
|
|
41
|
+
maybeInsertSafeResourceUrlTodo(recorder, loc, templateOffset, srcAttr);
|
|
39
42
|
replaceAttribute(recorder, (_a = tuiAvatarAttr === null || tuiAvatarAttr === void 0 ? void 0 : tuiAvatarAttr.name) !== null && _a !== void 0 ? _a : 'tuiAvatar', getAvatarAttr(srcAttr), loc, templateOffset);
|
|
40
43
|
(0, remove_attrs_1.removeAttrs)([srcAttr], loc, recorder, templateOffset);
|
|
41
44
|
});
|
|
@@ -47,6 +50,9 @@ function migrateAvatarToDirective({ resource, recorder, fileSystem, }) {
|
|
|
47
50
|
const srcAttr = getSrcAttr(element.attrs);
|
|
48
51
|
const hasAvatarAttr = hasTuiAvatarAttr(element.attrs);
|
|
49
52
|
const attrToAdd = hasAvatarAttr ? null : getAvatarAttr(srcAttr);
|
|
53
|
+
if (!hasAvatarAttr) {
|
|
54
|
+
maybeInsertSafeResourceUrlTodo(recorder, loc, templateOffset, srcAttr);
|
|
55
|
+
}
|
|
50
56
|
(0, replace_tag_1.replaceTag)(recorder, loc, 'tui-avatar', 'span', template, templateOffset, attrToAdd ? [attrToAdd] : []);
|
|
51
57
|
if (srcAttr) {
|
|
52
58
|
(0, remove_attrs_1.removeAttrs)([srcAttr], loc, recorder, templateOffset);
|
|
@@ -68,6 +74,37 @@ function hasTuiAvatarAttr(attrs) {
|
|
|
68
74
|
.map((attr) => attr.toLowerCase())
|
|
69
75
|
.includes(name));
|
|
70
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* A raw dynamic `[src]`/`[(src)]` becomes `[tuiAvatar]="..."`, which only accepts a
|
|
79
|
+
* string. A `SafeResourceUrl` (or any non-string image) would break at build time, and
|
|
80
|
+
* the bound type cannot be inferred from the template — so flag it with a TODO. Provably
|
|
81
|
+
* string values are skipped: quoted/backtick literals (`[src]="'a.png'"`) and known
|
|
82
|
+
* string flows (`| tuiIcon`, `| tuiFallbackSrc`).
|
|
83
|
+
*/
|
|
84
|
+
function maybeInsertSafeResourceUrlTodo(recorder, loc, templateOffset, srcAttr) {
|
|
85
|
+
if (!srcAttr || !isRawDynamicSrc(srcAttr)) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
recorder.insertLeft(templateOffset + loc.startOffset, `<!-- ${insert_todo_1.TODO_MARK} ${SAFE_RESOURCE_URL_TODO} -->\n`);
|
|
89
|
+
}
|
|
90
|
+
function isRawDynamicSrc(attr) {
|
|
91
|
+
const isBinding = attr.name === '[src]' || attr.name === '[(src)]';
|
|
92
|
+
if (!isBinding) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
const value = attr.value.trim();
|
|
96
|
+
return !isStringLiteral(value) && !/\|\s*(?:tuiIcon|tuiFallbackSrc)\b/.test(value);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* A quoted or backtick-delimited value is provably a `string`, so it can never be a
|
|
100
|
+
* `SafeResourceUrl` and does not need a TODO.
|
|
101
|
+
*/
|
|
102
|
+
function isStringLiteral(value) {
|
|
103
|
+
return (value.length >= 2 &&
|
|
104
|
+
((value.startsWith("'") && value.endsWith("'")) ||
|
|
105
|
+
(value.startsWith('"') && value.endsWith('"')) ||
|
|
106
|
+
(value.startsWith('`') && value.endsWith('`'))));
|
|
107
|
+
}
|
|
71
108
|
function getSrcAttr(attrs) {
|
|
72
109
|
var _a, _b;
|
|
73
110
|
return ((_b = (_a = (0, inputs_1.findAttr)(attrs, 'src')) !== null && _a !== void 0 ? _a : attrs.find((a) => a.name === '[(src)]')) !== null && _b !== void 0 ? _b : attrs.find((a) => a.name === '[src]'));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-avatar.js","sourceRoot":"","sources":["../../../../../../../projects/cdk/schematics/ng-update/v5/steps/templates/migrate-avatar.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"migrate-avatar.js","sourceRoot":"","sources":["../../../../../../../projects/cdk/schematics/ng-update/v5/steps/templates/migrate-avatar.ts"],"names":[],"mappings":";;AA2BA,4DA0GC;AAjID,+DAAwD;AACxD,mEAG8C;AAC9C,+DAA4D;AAC5D,qFAGuD;AAEvD,8DAAwD;AACxD,sEAAgE;AAQhE,MAAM,sBAAsB,GACxB,qNAAqN,CAAC;AAE1N,SAAgB,wBAAwB,CAAC,EACrC,QAAQ,EACR,QAAQ,EACR,UAAU,GAKb;IACG,MAAM,QAAQ,GAAG,IAAA,mDAA+B,EAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;IACvE,MAAM,cAAc,GAAG,IAAA,q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AM,uBAAN,MAAM,CAAE,IAAI,EAAE,mCAAI,EAAE;QAC5B,QAAQ,EAAE,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE;KAC3B,CAAC;AACN,CAAC"}
|
|
@@ -4,8 +4,8 @@ exports.migrateFormatPhonePipe = migrateFormatPhonePipe;
|
|
|
4
4
|
const insert_todo_1 = require("../../../../utils/insert-todo");
|
|
5
5
|
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
|
6
6
|
const PIPE_RENAME_REGEX = /(\|\s*)tuiFormatPhone\b/g;
|
|
7
|
-
const TODO_COMMENT_WITH_ARGS = `<!-- ${insert_todo_1.TODO_MARK} \`tuiFormatPhone\` pipe was replaced by \`maskito\` pipe. Replace its arguments with \`
|
|
8
|
-
const TODO_COMMENT_NO_ARGS = `<!-- ${insert_todo_1.TODO_MARK} \`tuiFormatPhone\` pipe was replaced by \`maskito\` pipe. Add \`
|
|
7
|
+
const TODO_COMMENT_WITH_ARGS = `<!-- ${insert_todo_1.TODO_MARK} \`tuiFormatPhone\` pipe was replaced by \`maskito\` pipe. Replace its arguments with \`maskitoPhone({countryIsoCode, metadata})\` from '@maskito/phone' (note: countryIsoCode is ISO format e.g. 'US', not '+1'). See: https://taiga-ui.dev/components/input-phone-international#phone-format-helpers -->`;
|
|
8
|
+
const TODO_COMMENT_NO_ARGS = `<!-- ${insert_todo_1.TODO_MARK} \`tuiFormatPhone\` pipe was replaced by \`maskito\` pipe. Add \`maskitoPhone({countryIsoCode, metadata})\` from '@maskito/phone' as argument. See: https://taiga-ui.dev/components/input-phone-international#phone-format-helpers -->`;
|
|
9
9
|
function migrateFormatPhonePipe({ resource, recorder, fileSystem, }) {
|
|
10
10
|
var _a, _b;
|
|
11
11
|
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-format-phone-pipe.js","sourceRoot":"","sources":["../../../../../../../projects/cdk/schematics/ng-update/v5/steps/templates/migrate-format-phone-pipe.ts"],"names":[],"mappings":";;AAcA,wDA4CC;AAvDD,+DAAwD;AACxD,qFAGuD;AAGvD,MAAM,iBAAiB,GAAG,0BAA0B,CAAC;AACrD,MAAM,sBAAsB,GAAG,QAAQ,uBAAS,
|
|
1
|
+
{"version":3,"file":"migrate-format-phone-pipe.js","sourceRoot":"","sources":["../../../../../../../projects/cdk/schematics/ng-update/v5/steps/templates/migrate-format-phone-pipe.ts"],"names":[],"mappings":";;AAcA,wDA4CC;AAvDD,+DAAwD;AACxD,qFAGuD;AAGvD,MAAM,iBAAiB,GAAG,0BAA0B,CAAC;AACrD,MAAM,sBAAsB,GAAG,QAAQ,uBAAS,4SAA4S,CAAC;AAC7V,MAAM,oBAAoB,GAAG,QAAQ,uBAAS,wOAAwO,CAAC;AAEvR,SAAgB,sBAAsB,CAAC,EACnC,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,wEAAwE;IACxE,4DAA4D;IAC5D,sDAAsD;IACtD,MAAM,gBAAgB,GAAG,UAAU,IAAI,QAAQ,CAAC;IAChD,MAAM,mBAAmB,GAAG,IAAI,GAAG,EAAU,CAAC;IAC9C,IAAI,KAAK,CAAC;IAEV,OAAO,CAAC,KAAK,GAAG,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QACzD,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,MAAA,MAAA,KAAK,CAAC,CAAC,CAAC,0CAAE,MAAM,mCAAI,CAAC,CAAC,CAAC;QAC5D,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,aAAa,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;QAC9E,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAE5C,QAAQ,CAAC,MAAM,CAAC,cAAc,GAAG,aAAa,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;QACzE,QAAQ,CAAC,WAAW,CAAC,cAAc,GAAG,aAAa,EAAE,SAAS,CAAC,CAAC;QAEhE,MAAM,SAAS,GAAG,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAE9D,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC;YACtC,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAEnC,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,oBAAoB,CAAC;YAE5E,IAAI,gBAAgB,IAAI,SAAS,KAAK,CAAC,EAAE,CAAC;gBACtC,0EAA0E;gBAC1E,oEAAoE;gBACpE,mEAAmE;gBACnE,QAAQ,CAAC,UAAU,CAAC,cAAc,GAAG,CAAC,EAAE,GAAG,WAAW,GAAG,CAAC,CAAC;YAC/D,CAAC;iBAAM,CAAC;gBACJ,QAAQ,CAAC,UAAU,CAAC,cAAc,GAAG,SAAS,EAAE,GAAG,WAAW,IAAI,CAAC,CAAC;YACxE,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type UpdateRecorder } from '@angular-devkit/schematics';
|
|
2
|
+
import { type DevkitFileSystem } from 'ng-morph';
|
|
3
|
+
import { type TemplateResource } from '../../../interfaces/template-resource';
|
|
4
|
+
export declare function migrateInputDateTime({ resource, recorder, fileSystem, }: {
|
|
5
|
+
fileSystem: DevkitFileSystem;
|
|
6
|
+
recorder: UpdateRecorder;
|
|
7
|
+
resource: TemplateResource;
|
|
8
|
+
}): void;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrateInputDateTime = migrateInputDateTime;
|
|
4
|
+
const insert_todo_1 = require("../../../../utils/insert-todo");
|
|
5
|
+
const elements_1 = require("../../../../utils/templates/elements");
|
|
6
|
+
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
|
7
|
+
const control_state_attrs_1 = require("../../../utils/templates/control-state-attrs");
|
|
8
|
+
const remove_attr_1 = require("../../../utils/templates/remove-attr");
|
|
9
|
+
const replace_tag_1 = require("../../../utils/templates/replace-tag");
|
|
10
|
+
/** Attributes that map 1:1 onto the v5 `<input tuiInputDateTime>` directive. */
|
|
11
|
+
const INPUT_ATTRS = new Set(['min', 'max', 'timeMode'].flatMap((name) => [
|
|
12
|
+
name.toLowerCase(),
|
|
13
|
+
`[${name.toLowerCase()}]`,
|
|
14
|
+
]));
|
|
15
|
+
/**
|
|
16
|
+
* Attributes that move onto the `<tui-calendar>` dropdown in v5.
|
|
17
|
+
*
|
|
18
|
+
* `disabledItemHandler` is intentionally NOT here: in v5 it stays on `<tui-textfield>`
|
|
19
|
+
* (the `tuiInputDateTime` directive forwards it to the calendar internally), matching
|
|
20
|
+
* the official demo: https://taiga-ui.dev/components/input-date-time
|
|
21
|
+
*/
|
|
22
|
+
const CALENDAR_ATTR_RENAMES = new Map([
|
|
23
|
+
['[defaultActiveYearMonth]'.toLowerCase(), '[month]'],
|
|
24
|
+
['defaultActiveYearMonth'.toLowerCase(), 'month'],
|
|
25
|
+
]);
|
|
26
|
+
function migrateInputDateTime({ resource, recorder, fileSystem, }) {
|
|
27
|
+
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
|
28
|
+
const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
|
|
29
|
+
const elements = (0, elements_1.findElementsByTagName)(template, 'tui-input-date-time');
|
|
30
|
+
elements.forEach((element) => {
|
|
31
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
32
|
+
const sourceCodeLocation = element.sourceCodeLocation;
|
|
33
|
+
// Self-closing/unclosed elements have no end tag, so there is no inside to place
|
|
34
|
+
// the migrated `<input>`/`<tui-calendar>` — skip to avoid inserting at offset 0.
|
|
35
|
+
if (!(sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.endTag)) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
(0, replace_tag_1.replaceTag)(recorder, sourceCodeLocation, 'tui-input-date-time', 'tui-textfield', template, templateOffset);
|
|
39
|
+
const { value: labelOutside, isBinding: labelOutsideIsBinding } = (0, remove_attr_1.removeAttr)(element, 'tuiTextfieldLabelOutside', recorder, templateOffset);
|
|
40
|
+
const isLabelOutsideTrue = labelOutside === 'true' || (!labelOutsideIsBinding && labelOutside === '');
|
|
41
|
+
const isDynamic = labelOutside !== null && !isLabelOutsideTrue && labelOutside !== 'false';
|
|
42
|
+
const controlAttrs = [...element.attrs].filter((attr) => /formcontrol|ngmodel/.exec(attr.name.toLowerCase()));
|
|
43
|
+
const inputAttrs = [...element.attrs].filter((attr) => INPUT_ATTRS.has(attr.name.toLowerCase()));
|
|
44
|
+
const calendarAttrs = [...element.attrs].filter((attr) => CALENDAR_ATTR_RENAMES.has(attr.name.toLowerCase()));
|
|
45
|
+
const controlStateAttrs = (0, control_state_attrs_1.getControlStateAttrs)(element);
|
|
46
|
+
(0, control_state_attrs_1.removeControlStateAttrs)(recorder, templateOffset, element, template, [
|
|
47
|
+
...controlAttrs,
|
|
48
|
+
...inputAttrs,
|
|
49
|
+
...calendarAttrs,
|
|
50
|
+
...controlStateAttrs,
|
|
51
|
+
]);
|
|
52
|
+
const labelIndex = element.childNodes.findIndex((node) => node.nodeName === '#text' && (node === null || node === void 0 ? void 0 : node.value.trim()));
|
|
53
|
+
let placeholderAttr = '';
|
|
54
|
+
if (labelIndex !== -1) {
|
|
55
|
+
const labelNode = element.childNodes[labelIndex];
|
|
56
|
+
const labelText = labelNode.value.trim();
|
|
57
|
+
const labelTextStart = ((_b = (_a = labelNode === null || labelNode === void 0 ? void 0 : labelNode.sourceCodeLocation) === null || _a === void 0 ? void 0 : _a.startOffset) !== null && _b !== void 0 ? _b : 0) + templateOffset;
|
|
58
|
+
const labelTextEnd = ((_d = (_c = labelNode === null || labelNode === void 0 ? void 0 : labelNode.sourceCodeLocation) === null || _c === void 0 ? void 0 : _c.endOffset) !== null && _d !== void 0 ? _d : 0) + templateOffset;
|
|
59
|
+
if (isLabelOutsideTrue) {
|
|
60
|
+
recorder.remove(labelTextStart, labelTextEnd - labelTextStart);
|
|
61
|
+
placeholderAttr = ` placeholder="${labelText.replaceAll('"', '"')}"`;
|
|
62
|
+
}
|
|
63
|
+
else if (!isDynamic) {
|
|
64
|
+
recorder.insertRight(labelTextStart, '\n<label tuiLabel>');
|
|
65
|
+
recorder.insertRight(labelTextEnd, '</label>\n');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (isDynamic) {
|
|
69
|
+
const insertAt = ((_e = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.startOffset) !== null && _e !== void 0 ? _e : 0) + templateOffset;
|
|
70
|
+
recorder.insertLeft(insertAt, `<!-- ${insert_todo_1.TODO_MARK} ${insert_todo_1.LABEL_OUTSIDE_TODO_MESSAGE}\n-->\n`);
|
|
71
|
+
}
|
|
72
|
+
const insertOffset = ((_g = (_f = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.endTag) === null || _f === void 0 ? void 0 : _f.startOffset) !== null && _g !== void 0 ? _g : 0) + templateOffset;
|
|
73
|
+
const inputs = element.childNodes.filter((node) => node.nodeName === 'input');
|
|
74
|
+
const baseAttrs = [...controlAttrs, ...inputAttrs].reduce((result, attr) => {
|
|
75
|
+
const name = normalizeAttrName(attr.name);
|
|
76
|
+
return attr.value ? `${result} ${name}="${attr.value}"` : `${result} ${name}`;
|
|
77
|
+
}, '');
|
|
78
|
+
const migrationAttrs = `${baseAttrs}${(0, control_state_attrs_1.stringifyControlStateAttrs)(controlStateAttrs)}`;
|
|
79
|
+
const calendarAttrStr = calendarAttrs.reduce((result, attr) => {
|
|
80
|
+
var _a;
|
|
81
|
+
const name = (_a = CALENDAR_ATTR_RENAMES.get(attr.name.toLowerCase())) !== null && _a !== void 0 ? _a : attr.name;
|
|
82
|
+
return attr.value ? `${result} ${name}="${attr.value}"` : `${result} ${name}`;
|
|
83
|
+
}, '');
|
|
84
|
+
if (inputs.length) {
|
|
85
|
+
recorder.insertRight(insertOffset, `\n<tui-calendar *tuiDropdown${calendarAttrStr} />\n`);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
recorder.insertRight(insertOffset, `\n<input tuiInputDateTime${migrationAttrs}${placeholderAttr} />\n<tui-calendar *tuiDropdown${calendarAttrStr} />\n`);
|
|
89
|
+
}
|
|
90
|
+
for (const input of inputs) {
|
|
91
|
+
input.attrs.forEach((attr) => {
|
|
92
|
+
var _a, _b, _c;
|
|
93
|
+
if (/^tuiTextfield$|^tuiTextfieldLegacy$/i.exec(attr.name)) {
|
|
94
|
+
const { startOffset = 0, endOffset = 0 } = (_c = (_b = (_a = input.sourceCodeLocation) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b[attr.name]) !== null && _c !== void 0 ? _c : {};
|
|
95
|
+
recorder.remove(templateOffset + startOffset, endOffset - startOffset);
|
|
96
|
+
recorder.insertRight(templateOffset + startOffset, `tuiInputDateTime${migrationAttrs}${placeholderAttr}`);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function normalizeAttrName(name) {
|
|
103
|
+
switch (name.toLowerCase()) {
|
|
104
|
+
case '(ngModelChange)'.toLowerCase():
|
|
105
|
+
return '(ngModelChange)';
|
|
106
|
+
case '[(ngModel)]'.toLowerCase():
|
|
107
|
+
return '[(ngModel)]';
|
|
108
|
+
case '[formControl]'.toLowerCase():
|
|
109
|
+
return '[formControl]';
|
|
110
|
+
case '[formControlName]'.toLowerCase():
|
|
111
|
+
return '[formControlName]';
|
|
112
|
+
case '[max]'.toLowerCase():
|
|
113
|
+
return '[max]';
|
|
114
|
+
case '[min]'.toLowerCase():
|
|
115
|
+
return '[min]';
|
|
116
|
+
case '[ngModel]'.toLowerCase():
|
|
117
|
+
return '[ngModel]';
|
|
118
|
+
case '[timeMode]'.toLowerCase():
|
|
119
|
+
return '[timeMode]';
|
|
120
|
+
case 'formControl'.toLowerCase():
|
|
121
|
+
return 'formControl';
|
|
122
|
+
case 'formControlName'.toLowerCase():
|
|
123
|
+
return 'formControlName';
|
|
124
|
+
case 'ngModel'.toLowerCase():
|
|
125
|
+
return 'ngModel';
|
|
126
|
+
case 'timeMode'.toLowerCase():
|
|
127
|
+
return 'timeMode';
|
|
128
|
+
default:
|
|
129
|
+
return name;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=migrate-input-date-time.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-input-date-time.js","sourceRoot":"","sources":["../../../../../../../projects/cdk/schematics/ng-update/v5/steps/templates/migrate-input-date-time.ts"],"names":[],"mappings":";;AA6CA,oDAwJC;AAjMD,+DAAoF;AACpF,mEAA2E;AAC3E,qFAGuD;AAEvD,sFAIsD;AACtD,sEAAgE;AAChE,sEAAgE;AAQhE,gFAAgF;AAChF,MAAM,WAAW,GAAG,IAAI,GAAG,CACvB,CAAC,KAAK,EAAE,KAAK,EAAE,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;IACzC,IAAI,CAAC,WAAW,EAAE;IAClB,IAAI,IAAI,CAAC,WAAW,EAAE,GAAG;CAC5B,CAAC,CACL,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IAClC,CAAC,0BAA0B,CAAC,WAAW,EAAE,EAAE,SAAS,CAA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,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type UpdateRecorder } from '@angular-devkit/schematics';
|
|
2
|
+
import { type DevkitFileSystem } from 'ng-morph';
|
|
3
|
+
import { type TemplateResource } from '../../../interfaces/template-resource';
|
|
4
|
+
export declare function migrateInputMonthRange({ resource, recorder, fileSystem, }: {
|
|
5
|
+
fileSystem: DevkitFileSystem;
|
|
6
|
+
recorder: UpdateRecorder;
|
|
7
|
+
resource: TemplateResource;
|
|
8
|
+
}): void;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrateInputMonthRange = migrateInputMonthRange;
|
|
4
|
+
const insert_todo_1 = require("../../../../utils/insert-todo");
|
|
5
|
+
const elements_1 = require("../../../../utils/templates/elements");
|
|
6
|
+
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
|
7
|
+
const control_state_attrs_1 = require("../../../utils/templates/control-state-attrs");
|
|
8
|
+
const remove_attr_1 = require("../../../utils/templates/remove-attr");
|
|
9
|
+
const replace_tag_1 = require("../../../utils/templates/replace-tag");
|
|
10
|
+
// All domain attrs go directly to <tui-calendar-month> — the directive has no own inputs for them.
|
|
11
|
+
const CALENDAR_ATTR_RENAMES = new Map([
|
|
12
|
+
['[defaultActiveYear]'.toLowerCase(), '[year]'],
|
|
13
|
+
['[disabledItemHandler]'.toLowerCase(), '[disabledItemHandler]'],
|
|
14
|
+
['[max]', '[max]'],
|
|
15
|
+
['[maxLength]'.toLowerCase(), '[maxLength]'],
|
|
16
|
+
['[min]', '[min]'],
|
|
17
|
+
['[minLength]'.toLowerCase(), '[minLength]'],
|
|
18
|
+
['defaultActiveYear'.toLowerCase(), 'year'],
|
|
19
|
+
['disabledItemHandler'.toLowerCase(), 'disabledItemHandler'],
|
|
20
|
+
['max', 'max'],
|
|
21
|
+
['maxLength'.toLowerCase(), 'maxLength'],
|
|
22
|
+
['min', 'min'],
|
|
23
|
+
['minLength'.toLowerCase(), 'minLength'],
|
|
24
|
+
]);
|
|
25
|
+
function migrateInputMonthRange({ resource, recorder, fileSystem, }) {
|
|
26
|
+
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
|
27
|
+
const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
|
|
28
|
+
const elements = (0, elements_1.findElementsByTagName)(template, 'tui-input-month-range');
|
|
29
|
+
elements.forEach((element) => {
|
|
30
|
+
var _a, _b, _c, _d;
|
|
31
|
+
const sourceCodeLocation = element.sourceCodeLocation;
|
|
32
|
+
(0, replace_tag_1.replaceTag)(recorder, sourceCodeLocation, 'tui-input-month-range', 'tui-textfield', template, templateOffset);
|
|
33
|
+
const { value: labelOutside, isBinding: labelOutsideIsBinding } = (0, remove_attr_1.removeAttr)(element, 'tuiTextfieldLabelOutside', recorder, templateOffset);
|
|
34
|
+
const isLabelOutsideTrue = labelOutside === 'true' || (!labelOutsideIsBinding && labelOutside === '');
|
|
35
|
+
const isDynamic = labelOutside !== null && !isLabelOutsideTrue && labelOutside !== 'false';
|
|
36
|
+
const controlAttrs = [...element.attrs].filter((attr) => /formcontrol|ngmodel/.exec(attr.name.toLocaleLowerCase()));
|
|
37
|
+
const calendarAttrs = [...element.attrs].filter((attr) => CALENDAR_ATTR_RENAMES.has(attr.name.toLowerCase()));
|
|
38
|
+
const controlStateAttrs = (0, control_state_attrs_1.getControlStateAttrs)(element);
|
|
39
|
+
for (const attr of [...controlAttrs, ...calendarAttrs]) {
|
|
40
|
+
const attributeLocation = (_b = (_a = element.sourceCodeLocation) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b[attr.name];
|
|
41
|
+
if (attributeLocation) {
|
|
42
|
+
recorder.remove(templateOffset + attributeLocation.startOffset, attributeLocation.endOffset - attributeLocation.startOffset);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
(0, control_state_attrs_1.removeControlStateAttrs)(recorder, templateOffset, element, template, controlStateAttrs);
|
|
46
|
+
const labelIndex = element.childNodes.findIndex((node) => node.nodeName === '#text' && (node === null || node === void 0 ? void 0 : node.value.trim()));
|
|
47
|
+
let placeholderAttr = '';
|
|
48
|
+
if (labelIndex !== -1) {
|
|
49
|
+
const labelNode = element.childNodes[labelIndex];
|
|
50
|
+
if (labelNode === null || labelNode === void 0 ? void 0 : labelNode.sourceCodeLocation) {
|
|
51
|
+
const labelText = labelNode.value.trim();
|
|
52
|
+
const labelTextStart = labelNode.sourceCodeLocation.startOffset + templateOffset;
|
|
53
|
+
const labelTextEnd = labelNode.sourceCodeLocation.endOffset + templateOffset;
|
|
54
|
+
if (isLabelOutsideTrue) {
|
|
55
|
+
recorder.remove(labelTextStart, labelTextEnd - labelTextStart);
|
|
56
|
+
placeholderAttr = ` placeholder="${labelText}"`;
|
|
57
|
+
}
|
|
58
|
+
else if (!isDynamic) {
|
|
59
|
+
recorder.insertRight(labelTextStart, '\n<label tuiLabel>');
|
|
60
|
+
recorder.insertRight(labelTextEnd, '</label>\n');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (isDynamic) {
|
|
65
|
+
const insertAt = ((_c = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.startOffset) !== null && _c !== void 0 ? _c : 0) + templateOffset;
|
|
66
|
+
recorder.insertLeft(insertAt, `<!-- ${insert_todo_1.TODO_MARK} [tuiTextfieldLabelOutside] is dynamic — cannot be migrated automatically. Use <label tuiLabel> inside <tui-textfield> for label-outside pattern.\n-->\n`);
|
|
67
|
+
}
|
|
68
|
+
const endTagStartOffset = (_d = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.endTag) === null || _d === void 0 ? void 0 : _d.startOffset;
|
|
69
|
+
if (endTagStartOffset === undefined) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const insertOffset = endTagStartOffset + templateOffset;
|
|
73
|
+
const inputs = element.childNodes.filter((node) => node.nodeName === 'input');
|
|
74
|
+
const controlAttrStr = [...controlAttrs].reduce((result, attr) => {
|
|
75
|
+
const name = normalizeAttrName(attr.name);
|
|
76
|
+
return attr.value ? `${result} ${name}="${attr.value}"` : `${result} ${name}`;
|
|
77
|
+
}, '');
|
|
78
|
+
const migrationAttrs = `${controlAttrStr}${(0, control_state_attrs_1.stringifyControlStateAttrs)(controlStateAttrs)}`;
|
|
79
|
+
const calendarAttrStr = calendarAttrs.reduce((result, attr) => {
|
|
80
|
+
var _a;
|
|
81
|
+
const name = (_a = CALENDAR_ATTR_RENAMES.get(attr.name.toLowerCase())) !== null && _a !== void 0 ? _a : attr.name;
|
|
82
|
+
return attr.value ? `${result} ${name}="${attr.value}"` : `${result} ${name}`;
|
|
83
|
+
}, '');
|
|
84
|
+
if (inputs.length) {
|
|
85
|
+
recorder.insertRight(insertOffset, `\n<tui-calendar-month *tuiDropdown${calendarAttrStr} />\n`);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
recorder.insertRight(insertOffset, `\n<input tuiInputMonthRange${migrationAttrs}${placeholderAttr} />\n<tui-calendar-month *tuiDropdown${calendarAttrStr} />\n`);
|
|
89
|
+
}
|
|
90
|
+
for (const input of inputs) {
|
|
91
|
+
input.attrs.forEach((attr) => {
|
|
92
|
+
var _a, _b;
|
|
93
|
+
if (/^tuiTextfield$|^tuiTextfieldLegacy$/i.exec(attr.name)) {
|
|
94
|
+
const attributeLocation = (_b = (_a = input.sourceCodeLocation) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b[attr.name];
|
|
95
|
+
if (attributeLocation) {
|
|
96
|
+
const { startOffset, endOffset } = attributeLocation;
|
|
97
|
+
recorder.remove(templateOffset + startOffset, endOffset - startOffset);
|
|
98
|
+
recorder.insertRight(templateOffset + startOffset, `tuiInputMonthRange${migrationAttrs}${placeholderAttr}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function normalizeAttrName(name) {
|
|
106
|
+
switch (name.toLowerCase()) {
|
|
107
|
+
case '(ngModelChange)'.toLowerCase():
|
|
108
|
+
return '(ngModelChange)';
|
|
109
|
+
case '[(ngModel)]'.toLowerCase():
|
|
110
|
+
return '[(ngModel)]';
|
|
111
|
+
case '[formControl]'.toLowerCase():
|
|
112
|
+
return '[formControl]';
|
|
113
|
+
case '[formControlName]'.toLowerCase():
|
|
114
|
+
return '[formControlName]';
|
|
115
|
+
case '[ngModel]'.toLowerCase():
|
|
116
|
+
return '[ngModel]';
|
|
117
|
+
case 'formControl'.toLowerCase():
|
|
118
|
+
return 'formControl';
|
|
119
|
+
case 'formControlName'.toLowerCase():
|
|
120
|
+
return 'formControlName';
|
|
121
|
+
case 'ngModel'.toLowerCase():
|
|
122
|
+
return 'ngModel';
|
|
123
|
+
default:
|
|
124
|
+
return name;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
//# sourceMappingURL=migrate-input-month-range.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-input-month-range.js","sourceRoot":"","sources":["../../../../../../../projects/cdk/schematics/ng-update/v5/steps/templates/migrate-input-month-range.ts"],"names":[],"mappings":";;AAyCA,wDAsKC;AA3MD,+DAAwD;AACxD,mEAA2E;AAC3E,qFAGuD;AAEvD,sFAIsD;AACtD,sEAAgE;AAChE,sEAAgE;AAQhE,mGAAmG;AACnG,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IAClC,CAAC,qBAAqB,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC;IAC/C,CAAC,uBAAuB,CAAC,WAAW,EAAE,EAAE,uBAAuB,CAAC;IAChE,CAAC,OAAO,EAAE,OAAO,CAAC;IAClB,CAAC,aAAa,CAAC,WAAW,EAAE,EAAE,aAAa,CAAC;IAC5C,CAAC,OAAO,EAAE,OAAO,CAAC;IAClB,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;QACrB;YACI,OAAO,IAAI,CAAC;IACpB,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type UpdateRecorder } from '@angular-devkit/schematics';
|
|
2
|
+
import { type DevkitFileSystem } from 'ng-morph';
|
|
3
|
+
import { type TemplateResource } from '../../../interfaces/template-resource';
|
|
4
|
+
export declare function migrateInputNumber({ resource, recorder, fileSystem, }: {
|
|
5
|
+
fileSystem: DevkitFileSystem;
|
|
6
|
+
recorder: UpdateRecorder;
|
|
7
|
+
resource: TemplateResource;
|
|
8
|
+
}): void;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrateInputNumber = migrateInputNumber;
|
|
4
|
+
const insert_todo_1 = require("../../../../utils/insert-todo");
|
|
5
|
+
const elements_1 = require("../../../../utils/templates/elements");
|
|
6
|
+
const template_resource_1 = require("../../../../utils/templates/template-resource");
|
|
7
|
+
const control_state_attrs_1 = require("../../../utils/templates/control-state-attrs");
|
|
8
|
+
const remove_attr_1 = require("../../../utils/templates/remove-attr");
|
|
9
|
+
const replace_tag_1 = require("../../../utils/templates/replace-tag");
|
|
10
|
+
/** Numeric inputs that map 1:1 onto the v5 `<input tuiInputNumber>` directive. */
|
|
11
|
+
const INPUT_ATTRS = new Set(['min', 'max', 'step'].flatMap((name) => [name, `[${name}]`]));
|
|
12
|
+
/**
|
|
13
|
+
* v4 affix attributes lived on the legacy `<tui-input-number>` textfield; in v5 the
|
|
14
|
+
* equivalents are `prefix`/`postfix` inputs on `<input tuiInputNumber>`.
|
|
15
|
+
*/
|
|
16
|
+
const AFFIX_RENAMES = new Map([
|
|
17
|
+
['[tuiTextfieldPostfix]'.toLowerCase(), '[postfix]'],
|
|
18
|
+
['[tuiTextfieldPrefix]'.toLowerCase(), '[prefix]'],
|
|
19
|
+
['tuiTextfieldPostfix'.toLowerCase(), 'postfix'],
|
|
20
|
+
['tuiTextfieldPrefix'.toLowerCase(), 'prefix'],
|
|
21
|
+
]);
|
|
22
|
+
function migrateInputNumber({ resource, recorder, fileSystem, }) {
|
|
23
|
+
const template = (0, template_resource_1.getTemplateFromTemplateResource)(resource, fileSystem);
|
|
24
|
+
const templateOffset = (0, template_resource_1.getTemplateOffset)(resource);
|
|
25
|
+
const elements = (0, elements_1.findElementsByTagName)(template, 'tui-input-number');
|
|
26
|
+
elements.forEach((element) => {
|
|
27
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
28
|
+
const sourceCodeLocation = element.sourceCodeLocation;
|
|
29
|
+
// Self-closing/unclosed elements have no end tag, so there is no inside to place
|
|
30
|
+
// the migrated `<input>` — skip to avoid inserting at offset 0.
|
|
31
|
+
if (!(sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.endTag)) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
(0, replace_tag_1.replaceTag)(recorder, sourceCodeLocation, 'tui-input-number', 'tui-textfield', template, templateOffset);
|
|
35
|
+
const { value: labelOutside, isBinding: labelOutsideIsBinding } = (0, remove_attr_1.removeAttr)(element, 'tuiTextfieldLabelOutside', recorder, templateOffset);
|
|
36
|
+
const isLabelOutsideTrue = labelOutside === 'true' || (!labelOutsideIsBinding && labelOutside === '');
|
|
37
|
+
const isDynamic = labelOutside !== null && !isLabelOutsideTrue && labelOutside !== 'false';
|
|
38
|
+
const controlAttrs = [...element.attrs].filter((attr) => /formcontrol|ngmodel/.exec(attr.name.toLocaleLowerCase()));
|
|
39
|
+
const inputAttrs = [...element.attrs].filter((attr) => INPUT_ATTRS.has(attr.name.toLowerCase()));
|
|
40
|
+
const affixAttrs = [...element.attrs].filter((attr) => AFFIX_RENAMES.has(attr.name.toLowerCase()));
|
|
41
|
+
const controlStateAttrs = (0, control_state_attrs_1.getControlStateAttrs)(element);
|
|
42
|
+
for (const attr of [...controlAttrs, ...inputAttrs, ...affixAttrs]) {
|
|
43
|
+
const { startOffset = 0, endOffset = 0 } = (_c = (_b = (_a = element.sourceCodeLocation) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b[attr.name]) !== null && _c !== void 0 ? _c : {};
|
|
44
|
+
recorder.remove(templateOffset + startOffset, endOffset - startOffset);
|
|
45
|
+
}
|
|
46
|
+
(0, control_state_attrs_1.removeControlStateAttrs)(recorder, templateOffset, element, template, controlStateAttrs);
|
|
47
|
+
const labelIndex = element.childNodes.findIndex((node) => node.nodeName === '#text' && (node === null || node === void 0 ? void 0 : node.value.trim()));
|
|
48
|
+
let placeholderAttr = '';
|
|
49
|
+
if (labelIndex !== -1) {
|
|
50
|
+
const labelNode = element.childNodes[labelIndex];
|
|
51
|
+
const labelText = labelNode.value.trim();
|
|
52
|
+
const labelTextStart = ((_e = (_d = labelNode === null || labelNode === void 0 ? void 0 : labelNode.sourceCodeLocation) === null || _d === void 0 ? void 0 : _d.startOffset) !== null && _e !== void 0 ? _e : 0) + templateOffset;
|
|
53
|
+
const labelTextEnd = ((_g = (_f = labelNode === null || labelNode === void 0 ? void 0 : labelNode.sourceCodeLocation) === null || _f === void 0 ? void 0 : _f.endOffset) !== null && _g !== void 0 ? _g : 0) + templateOffset;
|
|
54
|
+
if (isLabelOutsideTrue) {
|
|
55
|
+
recorder.remove(labelTextStart, labelTextEnd - labelTextStart);
|
|
56
|
+
placeholderAttr = ` placeholder="${labelText}"`;
|
|
57
|
+
}
|
|
58
|
+
else if (!isDynamic) {
|
|
59
|
+
recorder.insertRight(labelTextStart, '\n<label tuiLabel>');
|
|
60
|
+
recorder.insertRight(labelTextEnd, '</label>\n');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (isDynamic) {
|
|
64
|
+
const insertAt = ((_h = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.startOffset) !== null && _h !== void 0 ? _h : 0) + templateOffset;
|
|
65
|
+
recorder.insertLeft(insertAt, `<!-- ${insert_todo_1.TODO_MARK} ${insert_todo_1.LABEL_OUTSIDE_TODO_MESSAGE}\n-->\n`);
|
|
66
|
+
}
|
|
67
|
+
const inputInsertOffset = ((_k = (_j = sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.endTag) === null || _j === void 0 ? void 0 : _j.startOffset) !== null && _k !== void 0 ? _k : 0) + templateOffset;
|
|
68
|
+
const inputs = element.childNodes.filter((node) => node.nodeName === 'input');
|
|
69
|
+
const migrationAttrs = [...controlAttrs, ...inputAttrs, ...affixAttrs].reduce((result, attr) => {
|
|
70
|
+
const name = normalizeAttrName(attr.name);
|
|
71
|
+
return attr.value
|
|
72
|
+
? `${result} ${name}="${attr.value}"`
|
|
73
|
+
: `${result} ${name}`;
|
|
74
|
+
}, '');
|
|
75
|
+
const stateAttrs = (0, control_state_attrs_1.stringifyControlStateAttrs)(controlStateAttrs);
|
|
76
|
+
recorder.insertRight(inputInsertOffset, inputs.length
|
|
77
|
+
? ''
|
|
78
|
+
: `\n<input tuiInputNumber${migrationAttrs}${stateAttrs}${placeholderAttr} />\n`);
|
|
79
|
+
for (const input of inputs) {
|
|
80
|
+
input.attrs.forEach((attr) => {
|
|
81
|
+
var _a, _b, _c;
|
|
82
|
+
if (/^tuiTextfield$|^tuiTextfieldLegacy$/i.exec(attr.name)) {
|
|
83
|
+
const { startOffset = 0, endOffset = 0 } = (_c = (_b = (_a = input.sourceCodeLocation) === null || _a === void 0 ? void 0 : _a.attrs) === null || _b === void 0 ? void 0 : _b[attr.name]) !== null && _c !== void 0 ? _c : {};
|
|
84
|
+
recorder.remove(templateOffset + startOffset, endOffset - startOffset);
|
|
85
|
+
recorder.insertRight(templateOffset + startOffset, `tuiInputNumber${migrationAttrs}${stateAttrs}${placeholderAttr}`);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
function normalizeAttrName(name) {
|
|
92
|
+
var _a;
|
|
93
|
+
const lower = name.toLowerCase();
|
|
94
|
+
switch (lower) {
|
|
95
|
+
case '[formControl]'.toLowerCase():
|
|
96
|
+
return '[formControl]';
|
|
97
|
+
case '[ngModel]'.toLowerCase():
|
|
98
|
+
return '[ngModel]';
|
|
99
|
+
case 'formControl'.toLowerCase():
|
|
100
|
+
return 'formControl';
|
|
101
|
+
case 'formControlName'.toLowerCase():
|
|
102
|
+
return 'formControlName';
|
|
103
|
+
case 'ngModel'.toLowerCase():
|
|
104
|
+
return 'ngModel';
|
|
105
|
+
case '[(ngmodel)]':
|
|
106
|
+
return '[(ngModel)]';
|
|
107
|
+
default:
|
|
108
|
+
return (_a = AFFIX_RENAMES.get(lower)) !== null && _a !== void 0 ? _a : name;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=migrate-input-number.js.map
|