@eui/core 23.0.0-alpha.1 → 23.0.0-alpha.2
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/CHANGELOG.md +424 -0
- package/assets/i18n-eui/bg.json +7 -0
- package/assets/i18n-eui/cs.json +7 -0
- package/assets/i18n-eui/da.json +7 -0
- package/assets/i18n-eui/de.json +7 -0
- package/assets/i18n-eui/el.json +7 -0
- package/assets/i18n-eui/en.json +8 -1
- package/assets/i18n-eui/es.json +7 -0
- package/assets/i18n-eui/et.json +7 -0
- package/assets/i18n-eui/fi.json +7 -0
- package/assets/i18n-eui/fr.json +8 -1
- package/assets/i18n-eui/ga.json +7 -0
- package/assets/i18n-eui/hr.json +7 -0
- package/assets/i18n-eui/hu.json +7 -0
- package/assets/i18n-eui/it.json +7 -0
- package/assets/i18n-eui/lt.json +7 -0
- package/assets/i18n-eui/lv.json +7 -0
- package/assets/i18n-eui/mt.json +7 -0
- package/assets/i18n-eui/nl.json +7 -0
- package/assets/i18n-eui/pl.json +7 -0
- package/assets/i18n-eui/pt.json +7 -0
- package/assets/i18n-eui/ro.json +7 -0
- package/assets/i18n-eui/sk.json +7 -0
- package/assets/i18n-eui/sl.json +7 -0
- package/assets/i18n-eui/sv.json +7 -0
- package/docs/changelog.html +686 -0
- package/docs/classes/EuiAppShellServiceMock.html +467 -0
- package/docs/injectables/EuiThemeService.html +5 -73
- package/docs/interfaces/ActionReducer.html +2 -2
- package/docs/interfaces/ComponentInfo.html +367 -0
- package/docs/interfaces/Edit-1.html +367 -0
- package/docs/interfaces/Edit-2.html +367 -0
- package/docs/interfaces/Edit.html +367 -0
- package/docs/interfaces/EuiComponentEntry.html +457 -0
- package/docs/interfaces/ImportToAdd.html +385 -0
- package/docs/interfaces/ImportsArrayInfo.html +328 -0
- package/docs/interfaces/MigrateAllSchema.html +430 -0
- package/docs/interfaces/MigrationResult.html +367 -0
- package/docs/interfaces/ModuleMapping.html +328 -0
- package/docs/interfaces/NgModuleInfo.html +367 -0
- package/docs/interfaces/Schema-1.html +340 -0
- package/docs/interfaces/Schema-10.html +340 -0
- package/docs/interfaces/Schema-11.html +340 -0
- package/docs/interfaces/Schema-12.html +340 -0
- package/docs/interfaces/Schema-13.html +340 -0
- package/docs/interfaces/Schema-14.html +340 -0
- package/docs/interfaces/Schema-15.html +340 -0
- package/docs/interfaces/Schema-16.html +340 -0
- package/docs/interfaces/Schema-17.html +340 -0
- package/docs/interfaces/Schema-18.html +340 -0
- package/docs/interfaces/Schema-19.html +340 -0
- package/docs/interfaces/Schema-2.html +352 -0
- package/docs/interfaces/Schema-20.html +340 -0
- package/docs/interfaces/Schema-3.html +403 -0
- package/docs/interfaces/Schema-4.html +340 -0
- package/docs/interfaces/Schema-5.html +340 -0
- package/docs/interfaces/Schema-6.html +340 -0
- package/docs/interfaces/Schema-7.html +340 -0
- package/docs/interfaces/Schema-8.html +340 -0
- package/docs/interfaces/Schema-9.html +340 -0
- package/docs/interfaces/Schema.html +385 -0
- package/docs/interfaces/SelectorEntry.html +483 -0
- package/docs/interfaces/TextChange.html +367 -0
- package/docs/js/menu-wc.js +105 -0
- package/docs/js/menu-wc_es5.js +1 -1
- package/docs/js/search/search_index.js +2 -2
- package/docs/json/documentation.json +37733 -14671
- package/docs/miscellaneous/enumerations.html +4 -24
- package/docs/miscellaneous/functions.html +19091 -722
- package/docs/miscellaneous/variables.html +4097 -1176
- package/docs/overview.html +2 -2
- package/docs/properties.html +1 -1
- package/fesm2022/eui-core.mjs +305 -130
- package/fesm2022/eui-core.mjs.map +1 -1
- package/package.json +16 -11
- package/schematics/add-eui-imports/index.d.ts +8 -0
- package/schematics/add-eui-imports/index.js +525 -0
- package/schematics/add-eui-imports/index.js.map +1 -0
- package/schematics/add-eui-imports/schema.json +24 -0
- package/schematics/add-eui-imports/selector-map.d.ts +35 -0
- package/schematics/add-eui-imports/selector-map.js +246 -0
- package/schematics/add-eui-imports/selector-map.js.map +1 -0
- package/schematics/collection.json +118 -0
- package/schematics/fix-no-multiple-empty-lines/index.d.ts +7 -0
- package/schematics/fix-no-multiple-empty-lines/index.js +90 -0
- package/schematics/fix-no-multiple-empty-lines/index.js.map +1 -0
- package/schematics/fix-no-multiple-empty-lines/schema.json +19 -0
- package/schematics/icon-migrate/index.d.ts +3 -0
- package/schematics/icon-migrate/index.js +228 -0
- package/schematics/icon-migrate/index.js.map +1 -0
- package/schematics/icon-migrate/schema.d.ts +6 -0
- package/schematics/icon-migrate/schema.js +3 -0
- package/schematics/icon-migrate/schema.js.map +1 -0
- package/schematics/icon-migrate/schema.json +20 -0
- package/schematics/migrate/index.d.ts +3 -0
- package/schematics/migrate/index.js +98 -0
- package/schematics/migrate/index.js.map +1 -0
- package/schematics/migrate/replacements/breaking-changes.d.ts +6 -0
- package/schematics/migrate/replacements/breaking-changes.js +173 -0
- package/schematics/migrate/replacements/breaking-changes.js.map +1 -0
- package/schematics/migrate/replacements/eui-modules.d.ts +29 -0
- package/schematics/migrate/replacements/eui-modules.js +231 -0
- package/schematics/migrate/replacements/eui-modules.js.map +1 -0
- package/schematics/migrate/replacements/icons.d.ts +14 -0
- package/schematics/migrate/replacements/icons.js +235 -0
- package/schematics/migrate/replacements/icons.js.map +1 -0
- package/schematics/migrate/replacements/mwp.d.ts +6 -0
- package/schematics/migrate/replacements/mwp.js +148 -0
- package/schematics/migrate/replacements/mwp.js.map +1 -0
- package/schematics/migrate/schema.d.ts +8 -0
- package/schematics/migrate/schema.js +3 -0
- package/schematics/migrate/schema.js.map +1 -0
- package/schematics/migrate/schema.json +25 -0
- package/schematics/migrate/utils.d.ts +21 -0
- package/schematics/migrate/utils.js +106 -0
- package/schematics/migrate/utils.js.map +1 -0
- package/schematics/migrate-all/index.d.ts +8 -0
- package/schematics/migrate-all/index.js +30 -0
- package/schematics/migrate-all/index.js.map +1 -0
- package/schematics/migrate-all/schema.json +30 -0
- package/schematics/migrate-eui-accent/index.d.ts +7 -0
- package/schematics/migrate-eui-accent/index.js +193 -0
- package/schematics/migrate-eui-accent/index.js.map +1 -0
- package/schematics/migrate-eui-accent/schema.json +19 -0
- package/schematics/migrate-eui-alert/index.d.ts +7 -0
- package/schematics/migrate-eui-alert/index.js +152 -0
- package/schematics/migrate-eui-alert/index.js.map +1 -0
- package/schematics/migrate-eui-alert/schema.json +19 -0
- package/schematics/migrate-eui-avatar/index.d.ts +7 -0
- package/schematics/migrate-eui-avatar/index.js +155 -0
- package/schematics/migrate-eui-avatar/index.js.map +1 -0
- package/schematics/migrate-eui-avatar/schema.json +19 -0
- package/schematics/migrate-eui-button/index.d.ts +7 -0
- package/schematics/migrate-eui-button/index.js +191 -0
- package/schematics/migrate-eui-button/index.js.map +1 -0
- package/schematics/migrate-eui-button/schema.json +19 -0
- package/schematics/migrate-eui-chip/index.d.ts +7 -0
- package/schematics/migrate-eui-chip/index.js +153 -0
- package/schematics/migrate-eui-chip/index.js.map +1 -0
- package/schematics/migrate-eui-chip/schema.json +19 -0
- package/schematics/migrate-eui-chip-list/index.d.ts +7 -0
- package/schematics/migrate-eui-chip-list/index.js +472 -0
- package/schematics/migrate-eui-chip-list/index.js.map +1 -0
- package/schematics/migrate-eui-chip-list/schema.json +19 -0
- package/schematics/migrate-eui-discussion-thread/index.d.ts +7 -0
- package/schematics/migrate-eui-discussion-thread/index.js +143 -0
- package/schematics/migrate-eui-discussion-thread/index.js.map +1 -0
- package/schematics/migrate-eui-discussion-thread/schema.json +19 -0
- package/schematics/migrate-eui-editor/index.d.ts +7 -0
- package/schematics/migrate-eui-editor/index.js +198 -0
- package/schematics/migrate-eui-editor/index.js.map +1 -0
- package/schematics/migrate-eui-editor/schema.json +19 -0
- package/schematics/migrate-eui-fieldset/index.d.ts +7 -0
- package/schematics/migrate-eui-fieldset/index.js +186 -0
- package/schematics/migrate-eui-fieldset/index.js.map +1 -0
- package/schematics/migrate-eui-fieldset/schema.json +19 -0
- package/schematics/migrate-eui-icon-svg/index.d.ts +7 -0
- package/schematics/migrate-eui-icon-svg/index.js +197 -0
- package/schematics/migrate-eui-icon-svg/index.js.map +1 -0
- package/schematics/migrate-eui-icon-svg/schema.json +19 -0
- package/schematics/migrate-eui-icon-toggle/index.d.ts +7 -0
- package/schematics/migrate-eui-icon-toggle/index.js +194 -0
- package/schematics/migrate-eui-icon-toggle/index.js.map +1 -0
- package/schematics/migrate-eui-icon-toggle/schema.json +19 -0
- package/schematics/migrate-eui-popover/index.d.ts +7 -0
- package/schematics/migrate-eui-popover/index.js +152 -0
- package/schematics/migrate-eui-popover/index.js.map +1 -0
- package/schematics/migrate-eui-popover/schema.json +19 -0
- package/schematics/migrate-eui-progress-circle/index.d.ts +7 -0
- package/schematics/migrate-eui-progress-circle/index.js +192 -0
- package/schematics/migrate-eui-progress-circle/index.js.map +1 -0
- package/schematics/migrate-eui-progress-circle/schema.json +19 -0
- package/schematics/migrate-eui-table/index.d.ts +7 -0
- package/schematics/migrate-eui-table/index.js +544 -0
- package/schematics/migrate-eui-table/index.js.map +1 -0
- package/schematics/migrate-eui-table/schema.json +19 -0
- package/schematics/migrate-eui-tabs/index.d.ts +7 -0
- package/schematics/migrate-eui-tabs/index.js +296 -0
- package/schematics/migrate-eui-tabs/index.js.map +1 -0
- package/schematics/migrate-eui-tabs/schema.json +19 -0
- package/schematics/migrate-eui-toolbar-menu/index.d.ts +7 -0
- package/schematics/migrate-eui-toolbar-menu/index.js +358 -0
- package/schematics/migrate-eui-toolbar-menu/index.js.map +1 -0
- package/schematics/migrate-eui-toolbar-menu/schema.json +19 -0
- package/schematics/migrate-to-standalone/index.d.ts +7 -0
- package/schematics/migrate-to-standalone/index.js +723 -0
- package/schematics/migrate-to-standalone/index.js.map +1 -0
- package/schematics/migrate-to-standalone/schema.json +19 -0
- package/schematics/package.json +1 -0
- package/schematics/utils/dry-run.d.ts +3 -0
- package/schematics/utils/dry-run.js +14 -0
- package/schematics/utils/dry-run.js.map +1 -0
- package/types/eui-core.d.ts +72 -13
- package/types/eui-core.d.ts.map +1 -1
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.migrateEuiChip = migrateEuiChip;
|
|
37
|
+
const compiler_1 = require("@angular/compiler");
|
|
38
|
+
const ts = __importStar(require("typescript"));
|
|
39
|
+
const dry_run_1 = require("../utils/dry-run");
|
|
40
|
+
const REMOVED_INPUTS = new Set(['isSquared']);
|
|
41
|
+
function migrateEuiChip(options = {}) {
|
|
42
|
+
return (tree, context) => {
|
|
43
|
+
const scanPath = options.path ? '/' + options.path.replace(/^\.?\//, '').replace(/\/$/, '') : '';
|
|
44
|
+
let count = 0;
|
|
45
|
+
const dir = tree.getDir(scanPath || '/');
|
|
46
|
+
visitDir(dir, (path) => {
|
|
47
|
+
const buffer = tree.read(path);
|
|
48
|
+
if (!buffer)
|
|
49
|
+
return;
|
|
50
|
+
const original = buffer.toString('utf-8');
|
|
51
|
+
if (!original.includes('eui-chip') && !original.includes('euiChip'))
|
|
52
|
+
return;
|
|
53
|
+
const result = path.endsWith('.html')
|
|
54
|
+
? migrateTemplate(original)
|
|
55
|
+
: migrateInlineTemplates(original);
|
|
56
|
+
if (result !== original) {
|
|
57
|
+
if (options.dryRun) {
|
|
58
|
+
(0, dry_run_1.logDryRun)(context, `Would remove 'isSquared' input in ${path}`);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
tree.overwrite(path, result);
|
|
62
|
+
}
|
|
63
|
+
count++;
|
|
64
|
+
}
|
|
65
|
+
// Warn about TS usages inline
|
|
66
|
+
if (path.endsWith('.ts') && !path.endsWith('.spec.ts') && original.includes('isSquared')) {
|
|
67
|
+
const sourceFile = ts.createSourceFile(path, original, ts.ScriptTarget.Latest, true);
|
|
68
|
+
const visit = (node) => {
|
|
69
|
+
if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name) && node.name.text === 'isSquared') {
|
|
70
|
+
const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
71
|
+
context.logger.warn(`${path}:${line + 1} - "isSquared" is no longer a valid input on eui-chip. Remove this assignment.`);
|
|
72
|
+
}
|
|
73
|
+
ts.forEachChild(node, visit);
|
|
74
|
+
};
|
|
75
|
+
visit(sourceFile);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
context.logger.info(`Removed deprecated eui-chip 'isSquared' input from ${count} file(s).`);
|
|
79
|
+
if (options.dryRun) {
|
|
80
|
+
(0, dry_run_1.logDryRunNote)(context);
|
|
81
|
+
}
|
|
82
|
+
return tree;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function visitDir(dir, callback) {
|
|
86
|
+
for (const file of dir.subfiles) {
|
|
87
|
+
if (file.endsWith('.d.ts'))
|
|
88
|
+
continue;
|
|
89
|
+
if (!file.endsWith('.html') && !file.endsWith('.ts'))
|
|
90
|
+
continue;
|
|
91
|
+
callback(`${dir.path}/${file}`);
|
|
92
|
+
}
|
|
93
|
+
for (const sub of dir.subdirs) {
|
|
94
|
+
if (sub === 'node_modules' || sub === 'dist')
|
|
95
|
+
continue;
|
|
96
|
+
visitDir(dir.dir(sub), callback);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function migrateTemplate(source) {
|
|
100
|
+
const parsed = (0, compiler_1.parseTemplate)(source, '', { preserveWhitespaces: true });
|
|
101
|
+
const removals = [];
|
|
102
|
+
visitNodes(parsed.nodes, removals);
|
|
103
|
+
let result = source;
|
|
104
|
+
for (const { start, end } of removals.sort((a, b) => b.start - a.start)) {
|
|
105
|
+
let adjustedStart = start;
|
|
106
|
+
while (adjustedStart > 0 && (result[adjustedStart - 1] === ' ' || result[adjustedStart - 1] === '\t')) {
|
|
107
|
+
adjustedStart--;
|
|
108
|
+
}
|
|
109
|
+
result = result.slice(0, adjustedStart) + result.slice(end);
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
}
|
|
113
|
+
function migrateInlineTemplates(source) {
|
|
114
|
+
const templateRegex = /template\s*:\s*`([^`]*)`/gs;
|
|
115
|
+
return source.replace(templateRegex, (match, templateContent) => {
|
|
116
|
+
if (!templateContent.includes('eui-chip') && !templateContent.includes('euiChip'))
|
|
117
|
+
return match;
|
|
118
|
+
const migrated = migrateTemplate(templateContent);
|
|
119
|
+
if (migrated === templateContent)
|
|
120
|
+
return match;
|
|
121
|
+
return match.replace(templateContent, migrated);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function isChipElement(element) {
|
|
125
|
+
if (element.name === 'eui-chip')
|
|
126
|
+
return true;
|
|
127
|
+
return element.attributes.some((a) => a.name === 'euiChip');
|
|
128
|
+
}
|
|
129
|
+
function visitNodes(nodes, removals) {
|
|
130
|
+
for (const node of nodes) {
|
|
131
|
+
if (node instanceof compiler_1.TmplAstElement) {
|
|
132
|
+
if (isChipElement(node))
|
|
133
|
+
collectRemovals(node, removals);
|
|
134
|
+
visitNodes(node.children, removals);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function collectRemovals(element, removals) {
|
|
139
|
+
for (const attr of element.attributes) {
|
|
140
|
+
if (REMOVED_INPUTS.has(attr.name)) {
|
|
141
|
+
removals.push(getAttributeSpan(attr));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
for (const input of element.inputs) {
|
|
145
|
+
if (REMOVED_INPUTS.has(input.name)) {
|
|
146
|
+
removals.push(getAttributeSpan(input));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
function getAttributeSpan(attr) {
|
|
151
|
+
return { start: attr.sourceSpan.start.offset, end: attr.sourceSpan.end.offset };
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../schematics/migrate-eui-chip/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,wCAgDC;AA5DD,gDAA4H;AAE5H,+CAAiC;AACjC,8CAA4D;AAO5D,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC;AAE9C,SAAgB,cAAc,CAAC,UAAkB,EAAE;IACjD,OAAO,CAAC,IAAU,EAAE,O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AC,EAAE,CAAC;YAClC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IACD,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnC,IAAI,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YACnC,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAkD;IAC1E,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"$id": "MigrateEuiChipSchema",
|
|
4
|
+
"title": "Removes the deprecated isSquared input from eui-chip",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"path": {
|
|
8
|
+
"type": "string",
|
|
9
|
+
"description": "The path to scan for files.",
|
|
10
|
+
"default": "./",
|
|
11
|
+
"visible": true
|
|
12
|
+
},
|
|
13
|
+
"dryRun": {
|
|
14
|
+
"type": "boolean",
|
|
15
|
+
"default": false,
|
|
16
|
+
"description": "Whether to run in dry-run mode without making actual changes."
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.migrateEuiChipList = migrateEuiChipList;
|
|
37
|
+
const compiler_1 = require("@angular/compiler");
|
|
38
|
+
const ts = __importStar(require("typescript"));
|
|
39
|
+
const dry_run_1 = require("../utils/dry-run");
|
|
40
|
+
const CHIP_LIST_TAG = 'eui-chip-list';
|
|
41
|
+
const CHIP_LIST_ATTR = 'euiChipList';
|
|
42
|
+
const CHIP_TAG = 'eui-chip';
|
|
43
|
+
const CHIP_ATTR = 'euiChip';
|
|
44
|
+
const PROPAGATED_INPUTS = new Set([
|
|
45
|
+
'euiPrimary', 'euiSecondary', 'euiSuccess', 'euiInfo', 'euiWarning',
|
|
46
|
+
'euiDanger', 'euiAccent', 'euiVariant', 'euiSizeS', 'euiSizeVariant',
|
|
47
|
+
'euiOutline', 'euiDisabled',
|
|
48
|
+
]);
|
|
49
|
+
const WARN_PROPERTIES = new Set([...PROPAGATED_INPUTS, 'chipRemove', 'isChipsRemovable', 'chipsLabelTruncateCount',
|
|
50
|
+
'maxVisibleChipsCount', 'isMaxVisibleChipsOpened', 'toggleLinkMoreLabel', 'toggleLinkLessLabel',
|
|
51
|
+
'isChipsSorted', 'chipsSortOrder']);
|
|
52
|
+
const REMOVED_INPUTS = new Set(['maxVisibleChipsCount', 'isMaxVisibleChipsOpened', 'toggleLinkMoreLabel', 'toggleLinkLessLabel', 'isChipsSorted', 'chipsSortOrder']);
|
|
53
|
+
const TRUNCATE_PIPE_IMPORT = 'EuiTruncatePipe';
|
|
54
|
+
const TRUNCATE_PIPE_PATH = '@eui/components/pipes';
|
|
55
|
+
function migrateEuiChipList(options = {}) {
|
|
56
|
+
return (tree, context) => {
|
|
57
|
+
const scanPath = options.path ? '/' + options.path.replace(/^\.?\//, '').replace(/\/$/, '') : '';
|
|
58
|
+
let count = 0;
|
|
59
|
+
const filesNeedingTruncateImport = new Set();
|
|
60
|
+
visitDir(tree.getDir(scanPath || '/'), (path) => {
|
|
61
|
+
const buffer = tree.read(path);
|
|
62
|
+
if (!buffer)
|
|
63
|
+
return;
|
|
64
|
+
const original = buffer.toString('utf-8');
|
|
65
|
+
if (!original.includes(CHIP_LIST_TAG) && !original.includes(CHIP_LIST_ATTR))
|
|
66
|
+
return;
|
|
67
|
+
let result;
|
|
68
|
+
let addedTruncate = false;
|
|
69
|
+
if (path.endsWith('.html')) {
|
|
70
|
+
result = migrateTemplate(original);
|
|
71
|
+
if (result !== original && result.includes('euiTruncate') && !original.includes('euiTruncate')) {
|
|
72
|
+
// Find the associated .ts file
|
|
73
|
+
const tsPath = path.replace(/\.html$/, '.ts');
|
|
74
|
+
if (tree.exists(tsPath)) {
|
|
75
|
+
filesNeedingTruncateImport.add(tsPath);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
// Try component naming convention
|
|
79
|
+
const componentTsPath = path.replace(/\.html$/, '.component.ts');
|
|
80
|
+
if (tree.exists(componentTsPath)) {
|
|
81
|
+
filesNeedingTruncateImport.add(componentTsPath);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
result = migrateInlineTemplates(original);
|
|
88
|
+
if (result !== original && result.includes('euiTruncate') && !original.includes('euiTruncate')) {
|
|
89
|
+
addedTruncate = true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (result !== original) {
|
|
93
|
+
if (options.dryRun) {
|
|
94
|
+
(0, dry_run_1.logDryRun)(context, `Would move variant/size/outline inputs to child eui-chip in ${path}`);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
tree.overwrite(path, result);
|
|
98
|
+
}
|
|
99
|
+
count++;
|
|
100
|
+
}
|
|
101
|
+
if (addedTruncate) {
|
|
102
|
+
filesNeedingTruncateImport.add(path);
|
|
103
|
+
}
|
|
104
|
+
// Warn about TS usages of removed properties
|
|
105
|
+
if (path.endsWith('.ts') && !path.endsWith('.spec.ts')) {
|
|
106
|
+
if ([...WARN_PROPERTIES].some((p) => original.includes(p))) {
|
|
107
|
+
const sourceFile = ts.createSourceFile(path, original, ts.ScriptTarget.Latest, true);
|
|
108
|
+
const visit = (node) => {
|
|
109
|
+
if (ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name) && WARN_PROPERTIES.has(node.name.text)) {
|
|
110
|
+
const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
|
111
|
+
context.logger.warn(`${path}:${line + 1} - "${node.name.text}" has been removed from eui-chip-list. Move it to individual eui-chip elements.`);
|
|
112
|
+
}
|
|
113
|
+
ts.forEachChild(node, visit);
|
|
114
|
+
};
|
|
115
|
+
visit(sourceFile);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
// Add EuiTruncatePipe import to component files that need it
|
|
120
|
+
for (const tsPath of filesNeedingTruncateImport) {
|
|
121
|
+
const buffer = tree.read(tsPath);
|
|
122
|
+
if (!buffer)
|
|
123
|
+
continue;
|
|
124
|
+
const source = buffer.toString('utf-8');
|
|
125
|
+
if (source.includes(TRUNCATE_PIPE_IMPORT))
|
|
126
|
+
continue;
|
|
127
|
+
const result = addTruncatePipeImport(source, tsPath);
|
|
128
|
+
if (result !== source) {
|
|
129
|
+
if (!options.dryRun) {
|
|
130
|
+
tree.overwrite(tsPath, result);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
context.logger.info(`Migrated eui-chip-list inputs/outputs to child eui-chip in ${count} file(s).`);
|
|
135
|
+
if (options.dryRun) {
|
|
136
|
+
(0, dry_run_1.logDryRunNote)(context);
|
|
137
|
+
}
|
|
138
|
+
return tree;
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function visitDir(dir, callback) {
|
|
142
|
+
for (const file of dir.subfiles) {
|
|
143
|
+
if (file.endsWith('.d.ts'))
|
|
144
|
+
continue;
|
|
145
|
+
if (!file.endsWith('.html') && !file.endsWith('.ts'))
|
|
146
|
+
continue;
|
|
147
|
+
callback(`${dir.path}/${file}`);
|
|
148
|
+
}
|
|
149
|
+
for (const sub of dir.subdirs) {
|
|
150
|
+
if (sub === 'node_modules' || sub === 'dist')
|
|
151
|
+
continue;
|
|
152
|
+
visitDir(dir.dir(sub), callback);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function addTruncatePipeImport(source, filePath) {
|
|
156
|
+
const sourceFile = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true);
|
|
157
|
+
const edits = [];
|
|
158
|
+
// 1. Add ES import statement for EuiTruncatePipe
|
|
159
|
+
let hasEsImport = false;
|
|
160
|
+
let lastImportEnd = 0;
|
|
161
|
+
for (const stmt of sourceFile.statements) {
|
|
162
|
+
if (ts.isImportDeclaration(stmt)) {
|
|
163
|
+
lastImportEnd = stmt.getEnd();
|
|
164
|
+
const moduleSpec = stmt.moduleSpecifier.text;
|
|
165
|
+
if (moduleSpec === TRUNCATE_PIPE_PATH) {
|
|
166
|
+
const namedBindings = stmt.importClause?.namedBindings;
|
|
167
|
+
if (namedBindings && ts.isNamedImports(namedBindings)) {
|
|
168
|
+
if (namedBindings.elements.some((el) => el.name.text === TRUNCATE_PIPE_IMPORT)) {
|
|
169
|
+
hasEsImport = true;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
// Add to existing import from same path
|
|
173
|
+
const lastEl = namedBindings.elements[namedBindings.elements.length - 1];
|
|
174
|
+
edits.push({ start: lastEl.getEnd(), end: lastEl.getEnd(), replacement: `, ${TRUNCATE_PIPE_IMPORT}` });
|
|
175
|
+
hasEsImport = true;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
if (!hasEsImport) {
|
|
182
|
+
const importStatement = `\nimport { ${TRUNCATE_PIPE_IMPORT} } from '${TRUNCATE_PIPE_PATH}';`;
|
|
183
|
+
edits.push({ start: lastImportEnd, end: lastImportEnd, replacement: importStatement });
|
|
184
|
+
}
|
|
185
|
+
// 2. Add EuiTruncatePipe to @Component imports array
|
|
186
|
+
const visit = (node) => {
|
|
187
|
+
if (ts.isClassDeclaration(node)) {
|
|
188
|
+
const decs = ts.getDecorators(node);
|
|
189
|
+
if (!decs)
|
|
190
|
+
return;
|
|
191
|
+
for (const dec of decs) {
|
|
192
|
+
if (!ts.isCallExpression(dec.expression) || !ts.isIdentifier(dec.expression.expression) || dec.expression.expression.text !== 'Component')
|
|
193
|
+
continue;
|
|
194
|
+
const metadata = dec.expression.arguments[0];
|
|
195
|
+
if (!ts.isObjectLiteralExpression(metadata))
|
|
196
|
+
continue;
|
|
197
|
+
for (const prop of metadata.properties) {
|
|
198
|
+
if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name) || prop.name.text !== 'imports')
|
|
199
|
+
continue;
|
|
200
|
+
if (!ts.isArrayLiteralExpression(prop.initializer))
|
|
201
|
+
continue;
|
|
202
|
+
const arr = prop.initializer;
|
|
203
|
+
const arrText = source.slice(arr.getStart(sourceFile), arr.getEnd());
|
|
204
|
+
if (arrText.includes(TRUNCATE_PIPE_IMPORT))
|
|
205
|
+
continue;
|
|
206
|
+
if (arr.elements.length > 0) {
|
|
207
|
+
const lastElement = arr.elements[arr.elements.length - 1];
|
|
208
|
+
edits.push({ start: lastElement.getEnd(), end: lastElement.getEnd(), replacement: `,\n ${TRUNCATE_PIPE_IMPORT}` });
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
edits.push({ start: arr.getStart(sourceFile) + 1, end: arr.getEnd() - 1, replacement: TRUNCATE_PIPE_IMPORT });
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
ts.forEachChild(node, visit);
|
|
217
|
+
};
|
|
218
|
+
visit(sourceFile);
|
|
219
|
+
return applyEdits(source, edits);
|
|
220
|
+
}
|
|
221
|
+
function migrateTemplate(source) {
|
|
222
|
+
const parsed = (0, compiler_1.parseTemplate)(source, '', { preserveWhitespaces: true });
|
|
223
|
+
const edits = [];
|
|
224
|
+
visitNodes(parsed.nodes, source, edits);
|
|
225
|
+
return applyEdits(source, edits);
|
|
226
|
+
}
|
|
227
|
+
function migrateInlineTemplates(source) {
|
|
228
|
+
const sourceFile = ts.createSourceFile('', source, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
229
|
+
const changes = [];
|
|
230
|
+
const visit = (node) => {
|
|
231
|
+
if (ts.isPropertyAssignment(node) && isTemplateProperty(node) && isComponentMetadataProperty(node)) {
|
|
232
|
+
const init = unwrapExpression(node.initializer);
|
|
233
|
+
if (ts.isStringLiteral(init) || ts.isNoSubstitutionTemplateLiteral(init)) {
|
|
234
|
+
const start = init.getStart(sourceFile) + 1;
|
|
235
|
+
const end = init.getEnd() - 1;
|
|
236
|
+
const rawTemplate = source.slice(start, end);
|
|
237
|
+
if (!rawTemplate.includes(CHIP_LIST_TAG) && !rawTemplate.includes(CHIP_LIST_ATTR)) {
|
|
238
|
+
ts.forEachChild(node, visit);
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
const migrated = migrateTemplate(rawTemplate);
|
|
242
|
+
if (migrated !== rawTemplate)
|
|
243
|
+
changes.push({ start, end, replacement: migrated });
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
ts.forEachChild(node, visit);
|
|
247
|
+
};
|
|
248
|
+
visit(sourceFile);
|
|
249
|
+
return applyEdits(source, changes);
|
|
250
|
+
}
|
|
251
|
+
function visitNodes(nodes, source, edits) {
|
|
252
|
+
for (const node of nodes) {
|
|
253
|
+
if (node instanceof compiler_1.TmplAstElement) {
|
|
254
|
+
if (isChipListElement(node)) {
|
|
255
|
+
migrateChipListElement(node, source, edits);
|
|
256
|
+
}
|
|
257
|
+
visitNodes(node.children, source, edits);
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function isChipListElement(element) {
|
|
262
|
+
if (element.name === CHIP_LIST_TAG)
|
|
263
|
+
return true;
|
|
264
|
+
return element.attributes.some((a) => a.name === CHIP_LIST_ATTR);
|
|
265
|
+
}
|
|
266
|
+
function isChipElement(element) {
|
|
267
|
+
if (element.name === CHIP_TAG)
|
|
268
|
+
return true;
|
|
269
|
+
return element.attributes.some((a) => a.name === CHIP_ATTR);
|
|
270
|
+
}
|
|
271
|
+
function findChildChips(nodes) {
|
|
272
|
+
const chips = [];
|
|
273
|
+
for (const node of nodes) {
|
|
274
|
+
if (node instanceof compiler_1.TmplAstElement) {
|
|
275
|
+
if (isChipElement(node)) {
|
|
276
|
+
chips.push(node);
|
|
277
|
+
}
|
|
278
|
+
else {
|
|
279
|
+
chips.push(...findChildChips(node.children));
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
return chips;
|
|
284
|
+
}
|
|
285
|
+
function migrateChipListElement(element, source, edits) {
|
|
286
|
+
const childChips = findChildChips(element.children);
|
|
287
|
+
const insertions = [];
|
|
288
|
+
let truncateValue = null;
|
|
289
|
+
// Collect and remove propagated static attributes
|
|
290
|
+
for (const attr of element.attributes) {
|
|
291
|
+
if (PROPAGATED_INPUTS.has(attr.name)) {
|
|
292
|
+
edits.push(removalEdit(attr, source));
|
|
293
|
+
insertions.push(attr.value ? `${attr.name}="${attr.value}"` : attr.name);
|
|
294
|
+
}
|
|
295
|
+
if (attr.name === 'isChipsRemovable') {
|
|
296
|
+
edits.push(removalEdit(attr, source));
|
|
297
|
+
insertions.push('isChipRemovable');
|
|
298
|
+
}
|
|
299
|
+
if (attr.name === 'chipsLabelTruncateCount') {
|
|
300
|
+
edits.push(removalEdit(attr, source));
|
|
301
|
+
truncateValue = attr.value || null;
|
|
302
|
+
}
|
|
303
|
+
if (REMOVED_INPUTS.has(attr.name)) {
|
|
304
|
+
edits.push(removalEdit(attr, source));
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
// Collect and remove propagated bound inputs
|
|
308
|
+
for (const input of element.inputs) {
|
|
309
|
+
if (PROPAGATED_INPUTS.has(input.name)) {
|
|
310
|
+
edits.push(removalEdit(input, source));
|
|
311
|
+
const raw = source.slice(input.sourceSpan.start.offset, input.sourceSpan.end.offset);
|
|
312
|
+
insertions.push(raw);
|
|
313
|
+
}
|
|
314
|
+
if (input.name === 'isChipsRemovable') {
|
|
315
|
+
edits.push(removalEdit(input, source));
|
|
316
|
+
const valueText = extractBindingValue(input, source);
|
|
317
|
+
insertions.push(`[isChipRemovable]="${valueText}"`);
|
|
318
|
+
}
|
|
319
|
+
if (input.name === 'chipsLabelTruncateCount') {
|
|
320
|
+
edits.push(removalEdit(input, source));
|
|
321
|
+
truncateValue = extractBindingValue(input, source);
|
|
322
|
+
}
|
|
323
|
+
if (REMOVED_INPUTS.has(input.name)) {
|
|
324
|
+
edits.push(removalEdit(input, source));
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
// Collect and remove (chipRemove) output
|
|
328
|
+
let chipRemoveHandler = null;
|
|
329
|
+
for (const output of element.outputs) {
|
|
330
|
+
if (output.name === 'chipRemove') {
|
|
331
|
+
edits.push(removalEdit(output, source));
|
|
332
|
+
chipRemoveHandler = extractHandlerExpression(output, source);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (chipRemoveHandler) {
|
|
336
|
+
insertions.push(`(remove)="${chipRemoveHandler}"`);
|
|
337
|
+
}
|
|
338
|
+
// Add collected attributes to each child eui-chip
|
|
339
|
+
if (insertions.length > 0) {
|
|
340
|
+
for (const chip of childChips) {
|
|
341
|
+
const existingNames = getExistingAttrNames(chip);
|
|
342
|
+
const toInsert = insertions.filter((ins) => {
|
|
343
|
+
const name = extractAttrName(ins);
|
|
344
|
+
return !existingNames.has(name);
|
|
345
|
+
});
|
|
346
|
+
if (toInsert.length > 0) {
|
|
347
|
+
const insertPos = chip.startSourceSpan.end.offset - 1;
|
|
348
|
+
edits.push({ start: insertPos, end: insertPos, replacement: ' ' + toInsert.join(' ') });
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
// Add euiTruncate pipe to chip label content
|
|
353
|
+
if (truncateValue) {
|
|
354
|
+
for (const chip of childChips) {
|
|
355
|
+
const labelEdit = buildTruncatePipeEdit(chip, source, truncateValue);
|
|
356
|
+
if (labelEdit)
|
|
357
|
+
edits.push(labelEdit);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
function buildTruncatePipeEdit(chip, source, truncateValue) {
|
|
362
|
+
// Find <span euiLabel>...</span> inside the chip
|
|
363
|
+
const labelEl = findLabelElement(chip.children);
|
|
364
|
+
if (labelEl && labelEl.endSourceSpan) {
|
|
365
|
+
const contentStart = labelEl.startSourceSpan.end.offset;
|
|
366
|
+
const contentEnd = labelEl.endSourceSpan.start.offset;
|
|
367
|
+
const content = source.slice(contentStart, contentEnd);
|
|
368
|
+
if (content && !content.includes('euiTruncate')) {
|
|
369
|
+
const trimmed = content.trim();
|
|
370
|
+
const interpMatch = trimmed.match(/^\{\{\s*(.+?)\s*\}\}$/);
|
|
371
|
+
if (interpMatch) {
|
|
372
|
+
return { start: contentStart, end: contentEnd, replacement: `{{ ${interpMatch[1]} | euiTruncate: ${truncateValue} }}` };
|
|
373
|
+
}
|
|
374
|
+
return { start: contentStart, end: contentEnd, replacement: `{{ '${trimmed}' | euiTruncate: ${truncateValue} }}` };
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
// Check direct text content inside chip (no label element)
|
|
378
|
+
if (chip.endSourceSpan) {
|
|
379
|
+
const chipContentStart = chip.startSourceSpan.end.offset;
|
|
380
|
+
const chipContentEnd = chip.endSourceSpan.start.offset;
|
|
381
|
+
const chipContent = source.slice(chipContentStart, chipContentEnd);
|
|
382
|
+
const trimmed = chipContent.trim();
|
|
383
|
+
const interpMatch = trimmed.match(/^\{\{\s*(.+?)\s*\}\}$/);
|
|
384
|
+
if (interpMatch && !chipContent.includes('euiTruncate')) {
|
|
385
|
+
return { start: chipContentStart, end: chipContentEnd, replacement: `{{ ${interpMatch[1]} | euiTruncate: ${truncateValue} }}` };
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return null;
|
|
389
|
+
}
|
|
390
|
+
function findLabelElement(nodes) {
|
|
391
|
+
for (const node of nodes) {
|
|
392
|
+
if (node instanceof compiler_1.TmplAstElement) {
|
|
393
|
+
if (node.attributes.some((a) => a.name === 'euiLabel'))
|
|
394
|
+
return node;
|
|
395
|
+
const nested = findLabelElement(node.children);
|
|
396
|
+
if (nested)
|
|
397
|
+
return nested;
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
function getExistingAttrNames(element) {
|
|
403
|
+
const names = new Set();
|
|
404
|
+
for (const attr of element.attributes)
|
|
405
|
+
names.add(attr.name);
|
|
406
|
+
for (const input of element.inputs)
|
|
407
|
+
names.add(input.name);
|
|
408
|
+
for (const output of element.outputs)
|
|
409
|
+
names.add(output.name);
|
|
410
|
+
return names;
|
|
411
|
+
}
|
|
412
|
+
function extractAttrName(insertion) {
|
|
413
|
+
const outputMatch = insertion.match(/^\(([^)]+)\)/);
|
|
414
|
+
if (outputMatch)
|
|
415
|
+
return outputMatch[1];
|
|
416
|
+
const inputMatch = insertion.match(/^\[([^\]]+)\]/);
|
|
417
|
+
if (inputMatch)
|
|
418
|
+
return inputMatch[1];
|
|
419
|
+
return insertion.split('=')[0];
|
|
420
|
+
}
|
|
421
|
+
function removalEdit(node, source) {
|
|
422
|
+
let start = node.sourceSpan.start.offset;
|
|
423
|
+
while (start > 0 && (source[start - 1] === ' ' || source[start - 1] === '\t')) {
|
|
424
|
+
start--;
|
|
425
|
+
}
|
|
426
|
+
return { start, end: node.sourceSpan.end.offset, replacement: '' };
|
|
427
|
+
}
|
|
428
|
+
function extractBindingValue(input, source) {
|
|
429
|
+
const raw = source.slice(input.sourceSpan.start.offset, input.sourceSpan.end.offset);
|
|
430
|
+
const match = raw.match(/=["']([^"']*)["']/);
|
|
431
|
+
return match ? match[1] : 'true';
|
|
432
|
+
}
|
|
433
|
+
function extractHandlerExpression(output, source) {
|
|
434
|
+
const raw = source.slice(output.sourceSpan.start.offset, output.sourceSpan.end.offset);
|
|
435
|
+
const match = raw.match(/=["']([^"']*)["']/);
|
|
436
|
+
return match ? match[1] : '';
|
|
437
|
+
}
|
|
438
|
+
function isTemplateProperty(node) {
|
|
439
|
+
const name = node.name;
|
|
440
|
+
return (ts.isIdentifier(name) && name.text === 'template') || (ts.isStringLiteral(name) && name.text === 'template');
|
|
441
|
+
}
|
|
442
|
+
function isComponentMetadataProperty(node) {
|
|
443
|
+
const objectLiteral = node.parent;
|
|
444
|
+
if (!ts.isObjectLiteralExpression(objectLiteral))
|
|
445
|
+
return false;
|
|
446
|
+
const callExpression = objectLiteral.parent;
|
|
447
|
+
if (!ts.isCallExpression(callExpression) || callExpression.arguments[0] !== objectLiteral)
|
|
448
|
+
return false;
|
|
449
|
+
return ts.isDecorator(callExpression.parent) && ts.isIdentifier(callExpression.expression) && callExpression.expression.text === 'Component';
|
|
450
|
+
}
|
|
451
|
+
function unwrapExpression(expression) {
|
|
452
|
+
let current = expression;
|
|
453
|
+
while (ts.isParenthesizedExpression(current))
|
|
454
|
+
current = current.expression;
|
|
455
|
+
return current;
|
|
456
|
+
}
|
|
457
|
+
function applyEdits(source, edits) {
|
|
458
|
+
const unique = deduplicateEdits(edits);
|
|
459
|
+
let result = source;
|
|
460
|
+
for (const edit of unique.sort((a, b) => b.start - a.start)) {
|
|
461
|
+
result = result.slice(0, edit.start) + edit.replacement + result.slice(edit.end);
|
|
462
|
+
}
|
|
463
|
+
return result;
|
|
464
|
+
}
|
|
465
|
+
function deduplicateEdits(edits) {
|
|
466
|
+
const seen = new Map();
|
|
467
|
+
for (const edit of edits) {
|
|
468
|
+
seen.set(`${edit.start}:${edit.end}`, edit);
|
|
469
|
+
}
|
|
470
|
+
return Array.from(seen.values());
|
|
471
|
+
}
|
|
472
|
+
//# sourceMappingURL=index.js.map
|