igniteui-angular 20.0.14 → 20.0.15
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.
|
@@ -16,16 +16,18 @@ const import_helper_js_1 = require("igniteui-angular/migrations/common/import-he
|
|
|
16
16
|
const version = '20.0.6';
|
|
17
17
|
exports.default = () => (host, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
18
|
context.logger.info(`Applying migration for Ignite UI for Angular to version ${version}`);
|
|
19
|
-
const { HtmlParser } = yield (0, import_helper_js_1.nativeImport)('@angular/compiler');
|
|
19
|
+
const { HtmlParser } = (yield (0, import_helper_js_1.nativeImport)('@angular/compiler'));
|
|
20
20
|
const update = new UpdateChanges_1.UpdateChanges(__dirname, host, context);
|
|
21
21
|
const changes = new Map();
|
|
22
22
|
const parser = new HtmlParser();
|
|
23
|
-
const warnMsg = "Manual migration needed: please use 'disableFiltering' instead of filteringOptions.filterable." +
|
|
24
|
-
"Since it has been deprecated.
|
|
23
|
+
const warnMsg = "Manual migration needed: please use 'disableFiltering' instead of filteringOptions.filterable. " +
|
|
24
|
+
"Since it has been deprecated.";
|
|
25
25
|
const applyChanges = () => {
|
|
26
26
|
for (const [path, fileChanges] of changes.entries()) {
|
|
27
27
|
let content = host.read(path).toString();
|
|
28
|
-
fileChanges
|
|
28
|
+
fileChanges
|
|
29
|
+
.sort((a, b) => b.position - a.position)
|
|
30
|
+
.forEach((c) => {
|
|
29
31
|
content = c.apply(content);
|
|
30
32
|
});
|
|
31
33
|
host.overwrite(path, content);
|
|
@@ -39,7 +41,8 @@ exports.default = () => (host, context) => __awaiter(void 0, void 0, void 0, fun
|
|
|
39
41
|
};
|
|
40
42
|
const COMBO_TAGS = ['igx-simple-combo', 'igx-combo'];
|
|
41
43
|
for (const path of update.templateFiles) {
|
|
42
|
-
const
|
|
44
|
+
const root = (0, util_1.parseFile)(parser, host, path);
|
|
45
|
+
const nodes = (0, util_1.findElementNodes)(root, COMBO_TAGS);
|
|
43
46
|
for (const node of nodes) {
|
|
44
47
|
if (!(node instanceof compiler_1.Element))
|
|
45
48
|
continue;
|
|
@@ -47,37 +50,37 @@ exports.default = () => (host, context) => __awaiter(void 0, void 0, void 0, fun
|
|
|
47
50
|
const attr = node.attrs.find(a => a.name === '[filteringOptions]');
|
|
48
51
|
if (!attr)
|
|
49
52
|
continue;
|
|
50
|
-
const attrVal = attr.value.trim();
|
|
51
53
|
const offset = (0, util_1.getSourceOffset)(node);
|
|
52
54
|
const file = offset.file;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
const attrVal = (attr.value || '').trim();
|
|
56
|
+
// Handle inline object literals like [filteringOptions]="{...}"
|
|
57
|
+
if (attrVal.startsWith('{') && attrVal.endsWith('}')) {
|
|
58
|
+
const inner = attrVal.slice(1, -1);
|
|
59
|
+
let willDisableFiltering = false;
|
|
60
|
+
let remainingInner = inner.replace(/(^|,)\s*filterable\s*:\s*(true|false)\s*(?=,|$)/i, (_m, leading, val) => {
|
|
61
|
+
if (/^false$/i.test(val) && !hasDisableFiltering) {
|
|
62
|
+
willDisableFiltering = true;
|
|
63
|
+
}
|
|
64
|
+
return leading ? leading : '';
|
|
65
|
+
});
|
|
66
|
+
remainingInner = remainingInner
|
|
67
|
+
.replace(/\s*,\s*,\s*/g, ',')
|
|
68
|
+
.replace(/^\s*,\s*|\s*,\s*$/g, '')
|
|
69
|
+
.trim();
|
|
70
|
+
let replacementText = '';
|
|
71
|
+
if (willDisableFiltering) {
|
|
62
72
|
replacementText += `[disableFiltering]="true"`;
|
|
63
73
|
}
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const remainingProps = Object.entries(remaining)
|
|
67
|
-
.map(([k, v]) => `${k}: ${JSON.stringify(v)}`)
|
|
68
|
-
.join(', ');
|
|
69
|
-
if (remainingProps.length > 0) {
|
|
70
|
-
replacementText += ` [filteringOptions]="{ ${remainingProps} }"`;
|
|
71
|
-
}
|
|
72
|
-
// Replace whole [filteringOptions] attribute
|
|
73
|
-
const match = node.sourceSpan.toString().match(/\[filteringOptions\]="([^"]+)"/);
|
|
74
|
-
if (match) {
|
|
75
|
-
const attrText = match[0];
|
|
76
|
-
const attrPos = file.content.indexOf(attrText, offset.startTag.start);
|
|
77
|
-
addChange(file.url, new util_1.FileChange(attrPos, replacementText, attrText, 'replace'));
|
|
74
|
+
if (remainingInner.length > 0) {
|
|
75
|
+
replacementText += ` [filteringOptions]="{ ${remainingInner} }"`;
|
|
78
76
|
}
|
|
77
|
+
replacementText = replacementText.trim();
|
|
78
|
+
const attrStart = attr.sourceSpan.start.offset;
|
|
79
|
+
const attrEnd = attr.sourceSpan.end.offset;
|
|
80
|
+
const original = file.content.slice(attrStart, attrEnd);
|
|
81
|
+
addChange(file.url, new util_1.FileChange(attrStart, replacementText, original, 'replace'));
|
|
79
82
|
}
|
|
80
|
-
else {
|
|
83
|
+
else if (attrVal.length > 0) {
|
|
81
84
|
// log for manual TS edit
|
|
82
85
|
const comment = `\n<!-- ${warnMsg} -->\n`;
|
|
83
86
|
addChange(file.url, new util_1.FileChange(offset.startTag.end, comment));
|
|
@@ -86,14 +89,17 @@ exports.default = () => (host, context) => __awaiter(void 0, void 0, void 0, fun
|
|
|
86
89
|
}
|
|
87
90
|
applyChanges();
|
|
88
91
|
for (const path of update.tsFiles) {
|
|
89
|
-
const
|
|
92
|
+
const buf = host.read(path);
|
|
93
|
+
if (!buf)
|
|
94
|
+
continue;
|
|
95
|
+
const content = buf.toString();
|
|
90
96
|
const lines = content.split('\n');
|
|
91
97
|
const newLines = [];
|
|
92
98
|
let modified = false;
|
|
93
99
|
for (const line of lines) {
|
|
94
|
-
if (
|
|
95
|
-
|
|
96
|
-
newLines.push(
|
|
100
|
+
if (/\.\s*filteringOptions\s*\.\s*filterable\s*=/.test(line) ||
|
|
101
|
+
/\.\s*filteringOptions\s*=\s*{/.test(line)) {
|
|
102
|
+
newLines.push(`// ${warnMsg}`);
|
|
97
103
|
modified = true;
|
|
98
104
|
}
|
|
99
105
|
newLines.push(line);
|
package/package.json
CHANGED