@progress/kendo-angular-toolbar 21.2.0-develop.1 → 21.2.0-develop.11
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/codemods/utils.js +805 -394
- package/codemods/v19/toolbar-button-showicon.js +15 -16
- package/codemods/v19/toolbar-button-showtext.js +15 -16
- package/esm2022/package-metadata.mjs +2 -2
- package/esm2022/toolbar.component.mjs +4 -4
- package/esm2022/tools/toolbar-dropdownbutton.component.mjs +2 -2
- package/esm2022/tools/toolbar-splitbutton.component.mjs +2 -2
- package/esm2022/util.mjs +3 -3
- package/fesm2022/progress-kendo-angular-toolbar.mjs +10 -10
- package/package.json +9 -10
- package/codemods/template-transformer/index.js +0 -93
|
@@ -28,28 +28,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
exports.default = default_1;
|
|
31
|
-
const index_1 = require("../template-transformer/index");
|
|
32
31
|
const utils_1 = require("../utils");
|
|
33
32
|
const fs = __importStar(require("fs"));
|
|
34
33
|
function default_1(fileInfo, api) {
|
|
35
34
|
const filePath = fileInfo.path;
|
|
35
|
+
// Handle HTML files and inline templates
|
|
36
|
+
const htmlResult = (0, utils_1.htmlTransformer)(fileInfo, api, (templateContent) => {
|
|
37
|
+
let result = (0, utils_1.attributeValueUpdate)(templateContent, 'kendo-toolbar-button', 'showIcon', 'overflow', 'menu');
|
|
38
|
+
result = (0, utils_1.attributeValueUpdate)(result, 'kendo-toolbar-button', 'showIcon', 'both', 'always');
|
|
39
|
+
return result;
|
|
40
|
+
});
|
|
36
41
|
if (filePath.endsWith('.html')) {
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
updatedContent = (0, utils_1.htmlAttributeValueTransformer)({ ...fileInfo, source: updatedContent }, 'kendo-toolbar-button', 'showIcon', 'both', 'always');
|
|
41
|
-
// Only write to file once after all transformations
|
|
42
|
-
fs.writeFileSync(filePath, updatedContent, 'utf-8');
|
|
42
|
+
if (htmlResult && htmlResult !== fileInfo.source) {
|
|
43
|
+
fs.writeFileSync(filePath, htmlResult, 'utf-8');
|
|
44
|
+
return htmlResult;
|
|
43
45
|
}
|
|
44
|
-
return;
|
|
46
|
+
return fileInfo.source; // Return original source if no changes
|
|
45
47
|
}
|
|
48
|
+
// Handle TypeScript property transformations
|
|
46
49
|
const j = api.jscodeshift;
|
|
47
|
-
const rootSource = j(fileInfo.source);
|
|
48
|
-
(0,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
(0, utils_1.tsPropertyValueTransformer)(fileInfo.source, rootSource, j, 'DisplayMode', 'overflow', 'menu');
|
|
53
|
-
(0, utils_1.tsPropertyValueTransformer)(fileInfo.source, rootSource, j, 'DisplayMode', 'both', 'always');
|
|
54
|
-
return rootSource.toSource();
|
|
50
|
+
const rootSource = j(htmlResult || fileInfo.source);
|
|
51
|
+
(0, utils_1.tsPropertyValueTransformer)(fileInfo.source, rootSource, j, '@progress/kendo-angular-toolbar', 'DisplayMode', 'overflow', 'menu');
|
|
52
|
+
(0, utils_1.tsPropertyValueTransformer)(fileInfo.source, rootSource, j, '@progress/kendo-angular-toolbar', 'DisplayMode', 'both', 'always');
|
|
53
|
+
return rootSource.toSource({ quote: 'single' });
|
|
55
54
|
}
|
|
@@ -28,28 +28,27 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
exports.default = default_1;
|
|
31
|
-
const index_1 = require("../template-transformer/index");
|
|
32
31
|
const utils_1 = require("../utils");
|
|
33
32
|
const fs = __importStar(require("fs"));
|
|
34
33
|
function default_1(fileInfo, api) {
|
|
35
34
|
const filePath = fileInfo.path;
|
|
35
|
+
// Handle HTML files and inline templates
|
|
36
|
+
const htmlResult = (0, utils_1.htmlTransformer)(fileInfo, api, (templateContent) => {
|
|
37
|
+
let result = (0, utils_1.attributeValueUpdate)(templateContent, 'kendo-toolbar-button', 'showText', 'overflow', 'menu');
|
|
38
|
+
result = (0, utils_1.attributeValueUpdate)(result, 'kendo-toolbar-button', 'showText', 'both', 'always');
|
|
39
|
+
return result;
|
|
40
|
+
});
|
|
36
41
|
if (filePath.endsWith('.html')) {
|
|
37
|
-
if (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
updatedContent = (0, utils_1.htmlAttributeValueTransformer)({ ...fileInfo, source: updatedContent }, 'kendo-toolbar-button', 'showText', 'both', 'always');
|
|
41
|
-
// Only write to file once after all transformations
|
|
42
|
-
fs.writeFileSync(filePath, updatedContent, 'utf-8');
|
|
42
|
+
if (htmlResult && htmlResult !== fileInfo.source) {
|
|
43
|
+
fs.writeFileSync(filePath, htmlResult, 'utf-8');
|
|
44
|
+
return htmlResult;
|
|
43
45
|
}
|
|
44
|
-
return;
|
|
46
|
+
return fileInfo.source; // Return original source if no changes
|
|
45
47
|
}
|
|
48
|
+
// Handle TypeScript property transformations
|
|
46
49
|
const j = api.jscodeshift;
|
|
47
|
-
const rootSource = j(fileInfo.source);
|
|
48
|
-
(0,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
});
|
|
52
|
-
(0, utils_1.tsPropertyValueTransformer)(fileInfo.source, rootSource, j, 'DisplayMode', 'overflow', 'menu');
|
|
53
|
-
(0, utils_1.tsPropertyValueTransformer)(fileInfo.source, rootSource, j, 'DisplayMode', 'both', 'always');
|
|
54
|
-
return rootSource.toSource();
|
|
50
|
+
const rootSource = j(htmlResult || fileInfo.source);
|
|
51
|
+
(0, utils_1.tsPropertyValueTransformer)(fileInfo.source, rootSource, j, '@progress/kendo-angular-toolbar', 'DisplayMode', 'overflow', 'menu');
|
|
52
|
+
(0, utils_1.tsPropertyValueTransformer)(fileInfo.source, rootSource, j, '@progress/kendo-angular-toolbar', 'DisplayMode', 'both', 'always');
|
|
53
|
+
return rootSource.toSource({ quote: 'single' });
|
|
55
54
|
}
|
|
@@ -10,7 +10,7 @@ export const packageMetadata = {
|
|
|
10
10
|
productName: 'Kendo UI for Angular',
|
|
11
11
|
productCode: 'KENDOUIANGULAR',
|
|
12
12
|
productCodes: ['KENDOUIANGULAR'],
|
|
13
|
-
publishDate:
|
|
14
|
-
version: '21.2.0-develop.
|
|
13
|
+
publishDate: 1764684950,
|
|
14
|
+
version: '21.2.0-develop.11',
|
|
15
15
|
licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/'
|
|
16
16
|
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/* eslint-disable no-case-declarations */
|
|
6
6
|
import { Component, HostBinding, ViewChild, TemplateRef, ElementRef, QueryList, ContentChildren, Input, HostListener, Output, EventEmitter, ViewContainerRef, NgZone, Renderer2, ChangeDetectorRef } from '@angular/core';
|
|
7
7
|
import { PopupService } from '@progress/kendo-angular-popup';
|
|
8
|
-
import { guid,
|
|
8
|
+
import { guid, normalizeKeys, ResizeSensorComponent } from '@progress/kendo-angular-common';
|
|
9
9
|
import { LocalizationService, L10N_PREFIX } from '@progress/kendo-angular-l10n';
|
|
10
10
|
import { validatePackage } from '@progress/kendo-licensing';
|
|
11
11
|
import { packageMetadata } from './package-metadata';
|
|
@@ -393,7 +393,7 @@ export class ToolBarComponent {
|
|
|
393
393
|
this.zone.runOutsideAngular(() => {
|
|
394
394
|
this.toolbarKeydownListener = this.renderer.listen(this.element.nativeElement, 'keydown', (ev) => {
|
|
395
395
|
// on some keyboards arrow keys, PageUp/Down, and Home/End are mapped to Numpad keys
|
|
396
|
-
const code =
|
|
396
|
+
const code = normalizeKeys(ev);
|
|
397
397
|
switch (code) {
|
|
398
398
|
case Keys.ArrowLeft:
|
|
399
399
|
this.zone.run(() => {
|
|
@@ -663,7 +663,7 @@ export class ToolBarComponent {
|
|
|
663
663
|
this.zone.runOutsideAngular(() => {
|
|
664
664
|
if (this.normalizedOverflow.mode === 'section') {
|
|
665
665
|
this.sectionKeydownListener = this.renderer.listen(this.popupRef.popupElement, 'keydown', (ev) => {
|
|
666
|
-
const code =
|
|
666
|
+
const code = normalizeKeys(ev);
|
|
667
667
|
switch (code) {
|
|
668
668
|
case Keys.ArrowLeft:
|
|
669
669
|
this.zone.run(() => {
|
|
@@ -710,7 +710,7 @@ export class ToolBarComponent {
|
|
|
710
710
|
}
|
|
711
711
|
else {
|
|
712
712
|
this.overflowKeydownListener = this.renderer.listen(this.popupRef.popupElement, 'keydown', (ev) => {
|
|
713
|
-
const code =
|
|
713
|
+
const code = normalizeKeys(ev);
|
|
714
714
|
switch (code) {
|
|
715
715
|
case Keys.ArrowUp:
|
|
716
716
|
this.zone.run(() => {
|
|
@@ -10,7 +10,7 @@ import { IconWrapperComponent } from '@progress/kendo-angular-icons';
|
|
|
10
10
|
import { NgClass } from '@angular/common';
|
|
11
11
|
import { take } from 'rxjs/operators';
|
|
12
12
|
import { ToolBarComponent } from '../toolbar.component';
|
|
13
|
-
import {
|
|
13
|
+
import { normalizeKeys } from '@progress/kendo-angular-common';
|
|
14
14
|
import * as i0 from "@angular/core";
|
|
15
15
|
import * as i1 from "../toolbar.component";
|
|
16
16
|
/**
|
|
@@ -291,7 +291,7 @@ export class ToolBarDropDownButtonComponent extends ToolBarToolComponent {
|
|
|
291
291
|
* @hidden
|
|
292
292
|
*/
|
|
293
293
|
handleKey(ev) {
|
|
294
|
-
const code =
|
|
294
|
+
const code = normalizeKeys(ev);
|
|
295
295
|
if (!this.overflows && (code === this.getPrevKey(this.overflows) || code === this.getNextKey(this.overflows))) {
|
|
296
296
|
return false;
|
|
297
297
|
}
|
|
@@ -10,7 +10,7 @@ import { caretAltDownIcon } from '@progress/kendo-svg-icons';
|
|
|
10
10
|
import { IconWrapperComponent } from '@progress/kendo-angular-icons';
|
|
11
11
|
import { NgClass } from '@angular/common';
|
|
12
12
|
import { ToolBarComponent } from '../toolbar.component';
|
|
13
|
-
import {
|
|
13
|
+
import { normalizeKeys } from '@progress/kendo-angular-common';
|
|
14
14
|
import * as i0 from "@angular/core";
|
|
15
15
|
import * as i1 from "../toolbar.component";
|
|
16
16
|
/**
|
|
@@ -287,7 +287,7 @@ export class ToolBarSplitButtonComponent extends ToolBarToolComponent {
|
|
|
287
287
|
* @hidden
|
|
288
288
|
*/
|
|
289
289
|
handleKey(ev) {
|
|
290
|
-
const code =
|
|
290
|
+
const code = normalizeKeys(ev);
|
|
291
291
|
if (!this.overflows && (code === this.getPrevKey(this.overflows) || code === this.getNextKey(this.overflows))) {
|
|
292
292
|
return false;
|
|
293
293
|
}
|
package/esm2022/util.mjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
3
3
|
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
4
|
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
import { Keys,
|
|
5
|
+
import { Keys, normalizeKeys } from '@progress/kendo-angular-common';
|
|
6
6
|
/**
|
|
7
7
|
* @hidden
|
|
8
8
|
*/
|
|
@@ -130,7 +130,7 @@ export const makePeeker = (collection) => (index) => isPresent(collection[index]
|
|
|
130
130
|
* @hidden
|
|
131
131
|
*/
|
|
132
132
|
export const getIndexOfFocused = (prevKeyCode, nextKeyCode, collection) => (ev) => {
|
|
133
|
-
const code =
|
|
133
|
+
const code = normalizeKeys(ev);
|
|
134
134
|
switch (ev.type) {
|
|
135
135
|
case 'keydown':
|
|
136
136
|
if (code === prevKeyCode) {
|
|
@@ -152,7 +152,7 @@ export const getIndexOfFocused = (prevKeyCode, nextKeyCode, collection) => (ev)
|
|
|
152
152
|
* @hidden
|
|
153
153
|
*/
|
|
154
154
|
export const seekFocusedIndex = (prevKeyCode, nextKeyCode, seeker) => (startIndex, ev) => {
|
|
155
|
-
const code =
|
|
155
|
+
const code = normalizeKeys(ev);
|
|
156
156
|
switch (code) {
|
|
157
157
|
case prevKeyCode:
|
|
158
158
|
return seeker(startIndex - 1) ? startIndex - 1 : startIndex;
|
|
@@ -6,7 +6,7 @@ import * as i0 from '@angular/core';
|
|
|
6
6
|
import { EventEmitter, Injectable, inject, ElementRef, Directive, ViewChild, Input, Output, forwardRef, Component, HostBinding, ViewContainerRef, ContentChildren, HostListener, isDevMode, ViewChildren, NgModule } from '@angular/core';
|
|
7
7
|
import * as i2 from '@progress/kendo-angular-popup';
|
|
8
8
|
import { PopupService } from '@progress/kendo-angular-popup';
|
|
9
|
-
import {
|
|
9
|
+
import { normalizeKeys, Keys, isPresent as isPresent$1, isDocumentAvailable, guid, ResizeSensorComponent, ResizeBatchService } from '@progress/kendo-angular-common';
|
|
10
10
|
import * as i1 from '@progress/kendo-angular-l10n';
|
|
11
11
|
import { ComponentMessages, LocalizationService, L10N_PREFIX } from '@progress/kendo-angular-l10n';
|
|
12
12
|
import { validatePackage } from '@progress/kendo-licensing';
|
|
@@ -26,8 +26,8 @@ const packageMetadata = {
|
|
|
26
26
|
productName: 'Kendo UI for Angular',
|
|
27
27
|
productCode: 'KENDOUIANGULAR',
|
|
28
28
|
productCodes: ['KENDOUIANGULAR'],
|
|
29
|
-
publishDate:
|
|
30
|
-
version: '21.2.0-develop.
|
|
29
|
+
publishDate: 1764684950,
|
|
30
|
+
version: '21.2.0-develop.11',
|
|
31
31
|
licensingDocsUrl: 'https://www.telerik.com/kendo-angular-ui/my-license/'
|
|
32
32
|
};
|
|
33
33
|
|
|
@@ -173,7 +173,7 @@ const makePeeker = (collection) => (index) => isPresent(collection[index]);
|
|
|
173
173
|
* @hidden
|
|
174
174
|
*/
|
|
175
175
|
const getIndexOfFocused = (prevKeyCode, nextKeyCode, collection) => (ev) => {
|
|
176
|
-
const code =
|
|
176
|
+
const code = normalizeKeys(ev);
|
|
177
177
|
switch (ev.type) {
|
|
178
178
|
case 'keydown':
|
|
179
179
|
if (code === prevKeyCode) {
|
|
@@ -195,7 +195,7 @@ const getIndexOfFocused = (prevKeyCode, nextKeyCode, collection) => (ev) => {
|
|
|
195
195
|
* @hidden
|
|
196
196
|
*/
|
|
197
197
|
const seekFocusedIndex = (prevKeyCode, nextKeyCode, seeker) => (startIndex, ev) => {
|
|
198
|
-
const code =
|
|
198
|
+
const code = normalizeKeys(ev);
|
|
199
199
|
switch (code) {
|
|
200
200
|
case prevKeyCode:
|
|
201
201
|
return seeker(startIndex - 1) ? startIndex - 1 : startIndex;
|
|
@@ -1470,7 +1470,7 @@ class ToolBarComponent {
|
|
|
1470
1470
|
this.zone.runOutsideAngular(() => {
|
|
1471
1471
|
this.toolbarKeydownListener = this.renderer.listen(this.element.nativeElement, 'keydown', (ev) => {
|
|
1472
1472
|
// on some keyboards arrow keys, PageUp/Down, and Home/End are mapped to Numpad keys
|
|
1473
|
-
const code =
|
|
1473
|
+
const code = normalizeKeys(ev);
|
|
1474
1474
|
switch (code) {
|
|
1475
1475
|
case Keys.ArrowLeft:
|
|
1476
1476
|
this.zone.run(() => {
|
|
@@ -1740,7 +1740,7 @@ class ToolBarComponent {
|
|
|
1740
1740
|
this.zone.runOutsideAngular(() => {
|
|
1741
1741
|
if (this.normalizedOverflow.mode === 'section') {
|
|
1742
1742
|
this.sectionKeydownListener = this.renderer.listen(this.popupRef.popupElement, 'keydown', (ev) => {
|
|
1743
|
-
const code =
|
|
1743
|
+
const code = normalizeKeys(ev);
|
|
1744
1744
|
switch (code) {
|
|
1745
1745
|
case Keys.ArrowLeft:
|
|
1746
1746
|
this.zone.run(() => {
|
|
@@ -1787,7 +1787,7 @@ class ToolBarComponent {
|
|
|
1787
1787
|
}
|
|
1788
1788
|
else {
|
|
1789
1789
|
this.overflowKeydownListener = this.renderer.listen(this.popupRef.popupElement, 'keydown', (ev) => {
|
|
1790
|
-
const code =
|
|
1790
|
+
const code = normalizeKeys(ev);
|
|
1791
1791
|
switch (code) {
|
|
1792
1792
|
case Keys.ArrowUp:
|
|
1793
1793
|
this.zone.run(() => {
|
|
@@ -4074,7 +4074,7 @@ class ToolBarDropDownButtonComponent extends ToolBarToolComponent {
|
|
|
4074
4074
|
* @hidden
|
|
4075
4075
|
*/
|
|
4076
4076
|
handleKey(ev) {
|
|
4077
|
-
const code =
|
|
4077
|
+
const code = normalizeKeys(ev);
|
|
4078
4078
|
if (!this.overflows && (code === this.getPrevKey(this.overflows) || code === this.getNextKey(this.overflows))) {
|
|
4079
4079
|
return false;
|
|
4080
4080
|
}
|
|
@@ -4651,7 +4651,7 @@ class ToolBarSplitButtonComponent extends ToolBarToolComponent {
|
|
|
4651
4651
|
* @hidden
|
|
4652
4652
|
*/
|
|
4653
4653
|
handleKey(ev) {
|
|
4654
|
-
const code =
|
|
4654
|
+
const code = normalizeKeys(ev);
|
|
4655
4655
|
if (!this.overflows && (code === this.getPrevKey(this.overflows) || code === this.getNextKey(this.overflows))) {
|
|
4656
4656
|
return false;
|
|
4657
4657
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-angular-toolbar",
|
|
3
|
-
"version": "21.2.0-develop.
|
|
3
|
+
"version": "21.2.0-develop.11",
|
|
4
4
|
"description": "Kendo UI Angular Toolbar component - a single UI element that organizes buttons and other navigation elements",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"author": "Progress",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"package": {
|
|
46
46
|
"productName": "Kendo UI for Angular",
|
|
47
47
|
"productCode": "KENDOUIANGULAR",
|
|
48
|
-
"publishDate":
|
|
48
|
+
"publishDate": 1764684950,
|
|
49
49
|
"licensingDocsUrl": "https://www.telerik.com/kendo-angular-ui/my-license/"
|
|
50
50
|
}
|
|
51
51
|
},
|
|
@@ -55,18 +55,17 @@
|
|
|
55
55
|
"@angular/core": "18 - 21",
|
|
56
56
|
"@angular/platform-browser": "18 - 21",
|
|
57
57
|
"@progress/kendo-licensing": "^1.7.0",
|
|
58
|
-
"@progress/kendo-angular-buttons": "21.2.0-develop.
|
|
59
|
-
"@progress/kendo-angular-common": "21.2.0-develop.
|
|
60
|
-
"@progress/kendo-angular-l10n": "21.2.0-develop.
|
|
61
|
-
"@progress/kendo-angular-icons": "21.2.0-develop.
|
|
62
|
-
"@progress/kendo-angular-indicators": "21.2.0-develop.
|
|
63
|
-
"@progress/kendo-angular-popup": "21.2.0-develop.
|
|
58
|
+
"@progress/kendo-angular-buttons": "21.2.0-develop.11",
|
|
59
|
+
"@progress/kendo-angular-common": "21.2.0-develop.11",
|
|
60
|
+
"@progress/kendo-angular-l10n": "21.2.0-develop.11",
|
|
61
|
+
"@progress/kendo-angular-icons": "21.2.0-develop.11",
|
|
62
|
+
"@progress/kendo-angular-indicators": "21.2.0-develop.11",
|
|
63
|
+
"@progress/kendo-angular-popup": "21.2.0-develop.11",
|
|
64
64
|
"rxjs": "^6.5.3 || ^7.0.0"
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
67
|
"tslib": "^2.3.1",
|
|
68
|
-
"@progress/kendo-angular-schematics": "21.2.0-develop.
|
|
69
|
-
"node-html-parser": "^7.0.1"
|
|
68
|
+
"@progress/kendo-angular-schematics": "21.2.0-develop.11"
|
|
70
69
|
},
|
|
71
70
|
"schematics": "./schematics/collection.json",
|
|
72
71
|
"module": "fesm2022/progress-kendo-angular-toolbar.mjs",
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**-----------------------------------------------------------------------------------------
|
|
2
|
-
* Copyright © 2025 Progress Software Corporation. All rights reserved.
|
|
3
|
-
* Licensed under commercial license. See LICENSE.md in the project root for more information
|
|
4
|
-
*-------------------------------------------------------------------------------------------*/
|
|
5
|
-
"use strict";
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.templateTransformer = templateTransformer;
|
|
8
|
-
const node_html_parser_1 = require("node-html-parser");
|
|
9
|
-
function templateTransformer(root, j, ...processFns) {
|
|
10
|
-
root
|
|
11
|
-
.find(j.ClassDeclaration)
|
|
12
|
-
.forEach(classPath => {
|
|
13
|
-
// Skip if no decorators
|
|
14
|
-
const classNode = classPath.node;
|
|
15
|
-
if (!classNode.decorators || !classNode.decorators.length)
|
|
16
|
-
return;
|
|
17
|
-
// Find Component decorator
|
|
18
|
-
const componentDecorator = classNode.decorators.find((decorator) => {
|
|
19
|
-
if (decorator.expression && decorator.expression.type === 'CallExpression') {
|
|
20
|
-
const callee = decorator.expression.callee;
|
|
21
|
-
// Handle direct Component identifier
|
|
22
|
-
if (callee.type === 'Identifier' && callee.name === 'Component') {
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
// Handle angular.core.Component or similar
|
|
26
|
-
if (callee.type === 'MemberExpression' &&
|
|
27
|
-
callee.property &&
|
|
28
|
-
callee.property.type === 'Identifier' &&
|
|
29
|
-
callee.property.name === 'Component') {
|
|
30
|
-
return true;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return false;
|
|
34
|
-
});
|
|
35
|
-
if (!componentDecorator || !componentDecorator.expression)
|
|
36
|
-
return;
|
|
37
|
-
const expression = componentDecorator.expression;
|
|
38
|
-
if (expression.type !== 'CallExpression' || !expression.arguments.length)
|
|
39
|
-
return;
|
|
40
|
-
const componentOptions = expression.arguments[0];
|
|
41
|
-
if (componentOptions.type !== 'ObjectExpression')
|
|
42
|
-
return;
|
|
43
|
-
// Find template and templateUrl properties
|
|
44
|
-
const props = componentOptions.properties || [];
|
|
45
|
-
const templateProp = props.find((prop) => (prop.key.type === 'Identifier' && prop.key.name === 'template') ||
|
|
46
|
-
(prop.key.type === 'StringLiteral' && prop.key.value === 'template'));
|
|
47
|
-
// const templateUrlProp = props.find((prop: any) =>
|
|
48
|
-
// (prop.key.type === 'Identifier' && prop.key.name === 'templateUrl') ||
|
|
49
|
-
// (prop.key.type === 'StringLiteral' && prop.key.value === 'templateUrl')
|
|
50
|
-
// );
|
|
51
|
-
// Process inline template
|
|
52
|
-
if (templateProp) {
|
|
53
|
-
// Extract template based on node type
|
|
54
|
-
let originalTemplate;
|
|
55
|
-
if (templateProp.value.type === 'StringLiteral' || templateProp.value.type === 'Literal') {
|
|
56
|
-
originalTemplate = templateProp.value.value;
|
|
57
|
-
}
|
|
58
|
-
else if (templateProp.value.type === 'TemplateLiteral') {
|
|
59
|
-
// For template literals, join quasis
|
|
60
|
-
if (templateProp.value.quasis && templateProp.value.quasis.length) {
|
|
61
|
-
originalTemplate = templateProp.value.quasis
|
|
62
|
-
.map((q) => q.value.cooked || q.value.raw)
|
|
63
|
-
.join('');
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
console.warn('Could not process TemplateLiteral properly');
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
else {
|
|
71
|
-
console.warn(`Unsupported template type: ${templateProp.value.type}`);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
const root = (0, node_html_parser_1.parse)(originalTemplate);
|
|
75
|
-
processFns.forEach(fn => {
|
|
76
|
-
fn(root);
|
|
77
|
-
});
|
|
78
|
-
// Transform template using Angular compiler
|
|
79
|
-
const transformedTemplate = root.toString();
|
|
80
|
-
if (transformedTemplate !== originalTemplate) {
|
|
81
|
-
// Update template property
|
|
82
|
-
if (templateProp.value.type === 'TemplateLiteral') {
|
|
83
|
-
// For template literals, create a new template literal
|
|
84
|
-
templateProp.value = j.templateLiteral([j.templateElement({ cooked: transformedTemplate, raw: transformedTemplate }, true)], []);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
// For string literals, update the value
|
|
88
|
-
templateProp.value.value = transformedTemplate;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|