@skyux/packages 12.30.0 → 12.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. package/collection.json +5 -0
  2. package/package.json +57 -57
  3. package/src/schematics/migrations/migration-collection.json +1 -1
  4. package/src/schematics/ng-generate/convert-page-summary-to-page-header/convert-page-summary-to-page-header.schematic.d.ts +6 -0
  5. package/src/schematics/ng-generate/convert-page-summary-to-page-header/convert-page-summary-to-page-header.schematic.js +15 -0
  6. package/src/schematics/ng-generate/convert-page-summary-to-page-header/convert-page-summary-to-page-header.schematic.js.map +1 -0
  7. package/src/schematics/ng-generate/convert-page-summary-to-page-header/schema.d.ts +9 -0
  8. package/src/schematics/ng-generate/convert-page-summary-to-page-header/schema.js +3 -0
  9. package/src/schematics/ng-generate/convert-page-summary-to-page-header/schema.js.map +1 -0
  10. package/src/schematics/ng-generate/convert-page-summary-to-page-header/schema.json +13 -0
  11. package/src/schematics/rules/convert-page-summary-to-page-header/convert-page-summary-to-page-header.d.ts +2 -0
  12. package/src/schematics/rules/convert-page-summary-to-page-header/convert-page-summary-to-page-header.js +177 -0
  13. package/src/schematics/rules/convert-page-summary-to-page-header/convert-page-summary-to-page-header.js.map +1 -0
  14. package/src/schematics/utility/typescript/swap-imported-class.d.ts +4 -1
  15. package/src/schematics/utility/typescript/swap-imported-class.js +35 -10
  16. package/src/schematics/utility/typescript/swap-imported-class.js.map +1 -1
  17. package/src/version.js +1 -1
  18. package/src/schematics/utility/typescript/imports.d.ts +0 -11
  19. package/src/schematics/utility/typescript/imports.js +0 -82
  20. package/src/schematics/utility/typescript/imports.js.map +0 -1
  21. package/src/schematics/utility/typescript/source-file.d.ts +0 -2
  22. package/src/schematics/utility/typescript/source-file.js +0 -9
  23. package/src/schematics/utility/typescript/source-file.js.map +0 -1
package/collection.json CHANGED
@@ -21,6 +21,11 @@
21
21
  "factory": "./src/schematics/ng-generate/convert-definition-list-to-description-list/convert-definition-list-to-description-list.schematic",
22
22
  "schema": "./src/schematics/ng-generate/convert-definition-list-to-description-list/schema.json"
23
23
  },
24
+ "convert-page-summary-to-page-header": {
25
+ "description": "Convert <sky-page-summary> components to <sky-page-header> components.",
26
+ "factory": "./src/schematics/ng-generate/convert-page-summary-to-page-header/convert-page-summary-to-page-header.schematic",
27
+ "schema": "./src/schematics/ng-generate/convert-page-summary-to-page-header/schema.json"
28
+ },
24
29
  "polyfills": {
25
30
  "description": "Add @skyux/packages/polyfills to project config.",
26
31
  "factory": "./src/schematics/ng-generate/polyfills/polyfills.schematic",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skyux/packages",
3
- "version": "12.30.0",
3
+ "version": "12.32.0",
4
4
  "author": "Blackbaud, Inc.",
5
5
  "description": "Handles the `ng update` command for SKY UX component libraries.",
6
6
  "keywords": [
@@ -35,68 +35,68 @@
35
35
  "ng-update": {
36
36
  "migrations": "./src/schematics/migrations/migration-collection.json",
37
37
  "packageGroup": {
38
- "@skyux/packages": "12.30.0",
38
+ "@skyux/packages": "12.32.0",
39
39
  "@blackbaud/angular-tree-component": "^1.0.0",
40
- "@skyux-sdk/eslint-config": "12.30.0",
41
- "@skyux-sdk/eslint-schematics": "12.30.0",
42
- "@skyux-sdk/prettier-schematics": "12.30.0",
43
- "@skyux-sdk/stylelint-schematics": "12.30.0",
44
- "@skyux-sdk/testing": "12.30.0",
45
- "@skyux/a11y": "12.30.0",
46
- "@skyux/action-bars": "12.30.0",
47
- "@skyux/ag-grid": "12.30.0",
48
- "@skyux/angular-tree-component": "12.30.0",
49
- "@skyux/animations": "12.30.0",
50
- "@skyux/assets": "12.30.0",
51
- "@skyux/autonumeric": "12.30.0",
52
- "@skyux/avatar": "12.30.0",
53
- "@skyux/code-examples": "12.30.0",
54
- "@skyux/colorpicker": "12.30.0",
55
- "@skyux/config": "12.30.0",
56
- "@skyux/core": "12.30.0",
57
- "@skyux/data-manager": "12.30.0",
58
- "@skyux/datetime": "12.30.0",
59
- "@skyux/docs-tools": "12.30.0",
60
- "@skyux/errors": "12.30.0",
61
- "@skyux/flyout": "12.30.0",
62
- "@skyux/forms": "12.30.0",
63
- "@skyux/grids": "12.30.0",
64
- "@skyux/help-inline": "12.30.0",
65
- "@skyux/i18n": "12.30.0",
66
- "@skyux/icon": "12.30.0",
40
+ "@skyux-sdk/eslint-config": "12.32.0",
41
+ "@skyux-sdk/eslint-schematics": "12.32.0",
42
+ "@skyux-sdk/prettier-schematics": "12.32.0",
43
+ "@skyux-sdk/stylelint-schematics": "12.32.0",
44
+ "@skyux-sdk/testing": "12.32.0",
45
+ "@skyux/a11y": "12.32.0",
46
+ "@skyux/action-bars": "12.32.0",
47
+ "@skyux/ag-grid": "12.32.0",
48
+ "@skyux/angular-tree-component": "12.32.0",
49
+ "@skyux/animations": "12.32.0",
50
+ "@skyux/assets": "12.32.0",
51
+ "@skyux/autonumeric": "12.32.0",
52
+ "@skyux/avatar": "12.32.0",
53
+ "@skyux/code-examples": "12.32.0",
54
+ "@skyux/colorpicker": "12.32.0",
55
+ "@skyux/config": "12.32.0",
56
+ "@skyux/core": "12.32.0",
57
+ "@skyux/data-manager": "12.32.0",
58
+ "@skyux/datetime": "12.32.0",
59
+ "@skyux/docs-tools": "12.32.0",
60
+ "@skyux/errors": "12.32.0",
61
+ "@skyux/flyout": "12.32.0",
62
+ "@skyux/forms": "12.32.0",
63
+ "@skyux/grids": "12.32.0",
64
+ "@skyux/help-inline": "12.32.0",
65
+ "@skyux/i18n": "12.32.0",
66
+ "@skyux/icon": "12.32.0",
67
67
  "@skyux/icons": "^9.0.0",
68
- "@skyux/indicators": "12.30.0",
69
- "@skyux/inline-form": "12.30.0",
70
- "@skyux/layout": "12.30.0",
71
- "@skyux/list-builder": "12.30.0",
72
- "@skyux/list-builder-common": "12.30.0",
73
- "@skyux/list-builder-view-checklist": "12.30.0",
74
- "@skyux/list-builder-view-grids": "12.30.0",
75
- "@skyux/lists": "12.30.0",
76
- "@skyux/lookup": "12.30.0",
77
- "@skyux/manifest": "12.30.0",
78
- "@skyux/modals": "12.30.0",
79
- "@skyux/navbar": "12.30.0",
80
- "@skyux/pages": "12.30.0",
81
- "@skyux/phone-field": "12.30.0",
82
- "@skyux/popovers": "12.30.0",
83
- "@skyux/progress-indicator": "12.30.0",
84
- "@skyux/router": "12.30.0",
85
- "@skyux/select-field": "12.30.0",
86
- "@skyux/split-view": "12.30.0",
87
- "@skyux/tabs": "12.30.0",
88
- "@skyux/text-editor": "12.30.0",
89
- "@skyux/theme": "12.30.0",
90
- "@skyux/tiles": "12.30.0",
91
- "@skyux/toast": "12.30.0",
92
- "@skyux/validation": "12.30.0",
68
+ "@skyux/indicators": "12.32.0",
69
+ "@skyux/inline-form": "12.32.0",
70
+ "@skyux/layout": "12.32.0",
71
+ "@skyux/list-builder": "12.32.0",
72
+ "@skyux/list-builder-common": "12.32.0",
73
+ "@skyux/list-builder-view-checklist": "12.32.0",
74
+ "@skyux/list-builder-view-grids": "12.32.0",
75
+ "@skyux/lists": "12.32.0",
76
+ "@skyux/lookup": "12.32.0",
77
+ "@skyux/manifest": "12.32.0",
78
+ "@skyux/modals": "12.32.0",
79
+ "@skyux/navbar": "12.32.0",
80
+ "@skyux/pages": "12.32.0",
81
+ "@skyux/phone-field": "12.32.0",
82
+ "@skyux/popovers": "12.32.0",
83
+ "@skyux/progress-indicator": "12.32.0",
84
+ "@skyux/router": "12.32.0",
85
+ "@skyux/select-field": "12.32.0",
86
+ "@skyux/split-view": "12.32.0",
87
+ "@skyux/tabs": "12.32.0",
88
+ "@skyux/text-editor": "12.32.0",
89
+ "@skyux/theme": "12.32.0",
90
+ "@skyux/tiles": "12.32.0",
91
+ "@skyux/toast": "12.32.0",
92
+ "@skyux/validation": "12.32.0",
93
93
  "ag-grid-angular": "^33.3.2",
94
94
  "ag-grid-community": "^33.3.2",
95
95
  "ag-grid-enterprise": "^32.1.0",
96
96
  "autonumeric": "^4.10.5",
97
- "eslint-config-skyux": "12.30.0",
98
- "skyux-stylelint": "12.30.0",
99
- "stylelint-config-skyux": "12.30.0"
97
+ "eslint-config-skyux": "12.32.0",
98
+ "skyux-stylelint": "12.32.0",
99
+ "stylelint-config-skyux": "12.32.0"
100
100
  }
101
101
  },
102
102
  "peerDependencies": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schematics": {
3
3
  "noop": {
4
- "version": "12.30.0",
4
+ "version": "12.32.0",
5
5
  "factory": "./noop/noop.schematic",
6
6
  "description": "Update all SKY UX component packages"
7
7
  },
@@ -0,0 +1,6 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ import { Schema } from './schema';
3
+ /**
4
+ * Converts `<sky-definition-list>` to `<sky-description-list>`.
5
+ */
6
+ export default function convertPageSummaryToPageHeaderSchematic(options: Schema): Rule;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = convertPageSummaryToPageHeaderSchematic;
4
+ const convert_page_summary_to_page_header_1 = require("../../rules/convert-page-summary-to-page-header/convert-page-summary-to-page-header");
5
+ const workspace_1 = require("../../utility/workspace");
6
+ /**
7
+ * Converts `<sky-definition-list>` to `<sky-description-list>`.
8
+ */
9
+ function convertPageSummaryToPageHeaderSchematic(options) {
10
+ return async (tree) => {
11
+ const { project } = await (0, workspace_1.getRequiredProject)(tree, options.project);
12
+ return (0, convert_page_summary_to_page_header_1.convertPageSummaryToPageHeader)(project.root);
13
+ };
14
+ }
15
+ //# sourceMappingURL=convert-page-summary-to-page-header.schematic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-page-summary-to-page-header.schematic.js","sourceRoot":"","sources":["../../../../../../../../libs/components/packages/src/schematics/ng-generate/convert-page-summary-to-page-header/convert-page-summary-to-page-header.schematic.ts"],"names":[],"mappings":";;AAUA,0DAQC;AAhBD,6IAAqI;AACrI,uDAA6D;AAI7D;;GAEG;AACH,SAAwB,uCAAuC,CAC7D,OAAe;IAEf,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAA,8BAAkB,EAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;QAEpE,OAAO,IAAA,oEAA8B,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Represents options passed via Angular CLI.
3
+ */
4
+ export interface Schema {
5
+ /**
6
+ * The name of the project to convert.
7
+ */
8
+ project?: string;
9
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../../../../libs/components/packages/src/schematics/ng-generate/convert-page-summary-to-page-header/schema.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "type": "object",
4
+ "properties": {
5
+ "project": {
6
+ "type": "string",
7
+ "description": "The name of the project.",
8
+ "$default": {
9
+ "$source": "projectName"
10
+ }
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,2 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ export declare function convertPageSummaryToPageHeader(projectPath: string): Rule;
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertPageSummaryToPageHeader = convertPageSummaryToPageHeader;
4
+ const schematics_1 = require("@angular/cdk/schematics");
5
+ const eol_1 = require("@schematics/angular/utility/eol");
6
+ const template_1 = require("../../utility/template");
7
+ const ng_ast_1 = require("../../utility/typescript/ng-ast");
8
+ const swap_imported_class_1 = require("../../utility/typescript/swap-imported-class");
9
+ const visit_project_files_1 = require("../../utility/visit-project-files");
10
+ /**
11
+ * The page header component uses a `pageTitle` attribute for its title.
12
+ * Extracts the title from the `<sky-page-summary-title>` element and returns it
13
+ * as a string.
14
+ * If the title is anything more than a simple text node, an error is thrown.
15
+ */
16
+ function getPageTitle(pageSummary) {
17
+ const heading = (0, template_1.getElementsByTagName)('sky-page-summary-title', pageSummary)[0];
18
+ if ((0, template_1.isParentNode)(heading) &&
19
+ heading.childNodes.length === 1 &&
20
+ heading.childNodes[0].nodeName === '#text') {
21
+ return heading.childNodes[0].value.trim();
22
+ }
23
+ else if (!heading) {
24
+ return '';
25
+ }
26
+ else {
27
+ // If the heading contains something other than a single text node,
28
+ // throw an error to indicate that the title cannot be converted.
29
+ throw new Error(`The '<sky-page-summary-title>' element contains additional markup that is not supported as a 'pageTitle' for the <sky-page-header> component.`);
30
+ }
31
+ }
32
+ /**
33
+ * Moves detail elements (subtitle, status, content, key info) from the
34
+ * <sky-page-summary> element to a <sky-page-header-details> element.
35
+ */
36
+ function moveDetails(pageSummary, recorder, content, offset) {
37
+ const detailsContents = [
38
+ 'sky-page-summary-subtitle',
39
+ 'sky-page-summary-status',
40
+ 'sky-page-summary-content',
41
+ 'sky-page-summary-key-info',
42
+ ]
43
+ .flatMap((tag) => {
44
+ const elements = (0, template_1.getElementsByTagName)(tag, pageSummary);
45
+ return elements.map((element) => content
46
+ .substring(element.sourceCodeLocation.startTag.endOffset, element.sourceCodeLocation.endTag.startOffset)
47
+ .trim());
48
+ })
49
+ .filter(Boolean);
50
+ const indent = ' '.repeat(pageSummary.sourceCodeLocation.endTag.startCol);
51
+ const eol = (0, eol_1.getEOL)(content);
52
+ if (detailsContents.length === 1) {
53
+ recorder.insertLeft(pageSummary.sourceCodeLocation.endTag.startOffset + offset, [
54
+ ` <sky-page-header-details>`,
55
+ `${indent} ${detailsContents[0].trim()}`,
56
+ `${indent} </sky-page-header-details>`,
57
+ `${indent}`,
58
+ ].join(eol));
59
+ }
60
+ else if (detailsContents.length > 1) {
61
+ recorder.insertLeft(pageSummary.sourceCodeLocation.endTag.startOffset + offset, [
62
+ ` <sky-page-header-details>`,
63
+ detailsContents
64
+ .map((detailsContent) => [
65
+ `${indent} <div class="sky-margin-stacked-md">`,
66
+ `${indent} ${detailsContent.trim()}`,
67
+ `${indent} </div>`,
68
+ ].join(eol))
69
+ .join(eol),
70
+ `${indent} </sky-page-header-details>`,
71
+ `${indent}`,
72
+ ].join(eol));
73
+ }
74
+ }
75
+ /**
76
+ * Removes title and detail elements from the page summary, including
77
+ * <sky-page-summary-title>, <sky-page-summary-subtitle>, <sky-page-summary-status>,
78
+ * <sky-page-summary-content>, and <sky-page-summary-key-info>.
79
+ */
80
+ function removeTitleAndDetailElements(pageSummary, recorder, content, offset) {
81
+ const tagsToRemove = [
82
+ 'sky-page-summary-title',
83
+ 'sky-page-summary-subtitle',
84
+ 'sky-page-summary-status',
85
+ 'sky-page-summary-content',
86
+ 'sky-page-summary-key-info',
87
+ ];
88
+ const eol = (0, eol_1.getEOL)(content);
89
+ for (const tag of tagsToRemove) {
90
+ const elements = (0, template_1.getElementsByTagName)(tag, pageSummary);
91
+ elements.forEach((element) => {
92
+ const trailingLineBreak = content.indexOf(eol, offset + element.sourceCodeLocation.endOffset) ===
93
+ offset + element.sourceCodeLocation.endOffset;
94
+ recorder.remove(offset + element.sourceCodeLocation.startOffset, element.sourceCodeLocation.endOffset -
95
+ element.sourceCodeLocation.startOffset +
96
+ (trailingLineBreak ? eol.length : 0));
97
+ });
98
+ }
99
+ }
100
+ const tags = {
101
+ 'sky-page-summary': 'sky-page-header',
102
+ 'sky-page-summary-alert': 'sky-page-header-alerts',
103
+ 'sky-page-summary-image': 'sky-page-header-avatar',
104
+ };
105
+ function pageSummaryTagSwap() {
106
+ return (position, oldTag, node, content) => {
107
+ if (position === 'open') {
108
+ if (oldTag === Object.keys(tags)[0]) {
109
+ return `<${tags[oldTag]} pageTitle="${getPageTitle(node)}">`;
110
+ }
111
+ return `<${tags[oldTag]}>`;
112
+ }
113
+ return `</${tags[oldTag]}>`;
114
+ };
115
+ }
116
+ function convertTemplate(recorder, content, offset = 0) {
117
+ const fragment = (0, template_1.parseTemplate)(content);
118
+ const pageSummaries = (0, template_1.getElementsByTagName)('sky-page-summary', fragment);
119
+ for (const pageSummary of pageSummaries) {
120
+ removeTitleAndDetailElements(pageSummary, recorder, content, offset);
121
+ moveDetails(pageSummary, recorder, content, offset);
122
+ (0, template_1.swapTags)(content, recorder, offset, Object.keys(tags), pageSummaryTagSwap(), pageSummary);
123
+ }
124
+ }
125
+ function convertHtmlFile(tree, filePath) {
126
+ const content = tree.readText(filePath);
127
+ if (content.includes('<sky-page-summary')) {
128
+ const recorder = tree.beginUpdate(filePath);
129
+ convertTemplate(recorder, content);
130
+ tree.commitUpdate(recorder);
131
+ }
132
+ }
133
+ function convertTypescriptFile(tree, filePath) {
134
+ const source = (0, schematics_1.parseSourceFile)(tree, filePath);
135
+ const templates = (0, ng_ast_1.getInlineTemplates)(source);
136
+ const recorder = tree.beginUpdate(filePath);
137
+ if (templates.length > 0) {
138
+ const content = tree.readText(filePath);
139
+ for (const template of templates) {
140
+ convertTemplate(recorder, content.slice(template.start, template.end), template.start);
141
+ }
142
+ }
143
+ if ((0, schematics_1.isImported)(source, 'SkyPageSummaryModule', '@skyux/layout')) {
144
+ (0, swap_imported_class_1.swapImportedClass)(recorder, filePath, source, [
145
+ {
146
+ classNames: {
147
+ SkyPageSummaryModule: 'SkyPageModule',
148
+ },
149
+ moduleName: {
150
+ old: '@skyux/layout',
151
+ new: '@skyux/pages',
152
+ },
153
+ },
154
+ ]);
155
+ }
156
+ tree.commitUpdate(recorder);
157
+ }
158
+ function convertPageSummaryToPageHeader(projectPath) {
159
+ return (tree) => {
160
+ (0, visit_project_files_1.visitProjectFiles)(tree, projectPath, (filePath) => {
161
+ try {
162
+ if (filePath.endsWith('.html')) {
163
+ convertHtmlFile(tree, filePath);
164
+ }
165
+ else if (filePath.endsWith('.ts')) {
166
+ convertTypescriptFile(tree, filePath);
167
+ }
168
+ }
169
+ catch (error) {
170
+ /* istanbul ignore next */
171
+ const msg = error instanceof Error ? error.message : String(error);
172
+ throw new Error(`Error converting '${filePath}': ${msg}`);
173
+ }
174
+ });
175
+ };
176
+ }
177
+ //# sourceMappingURL=convert-page-summary-to-page-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"convert-page-summary-to-page-header.js","sourceRoot":"","sources":["../../../../../../../../libs/components/packages/src/schematics/rules/convert-page-summary-to-page-header/convert-page-summary-to-page-header.ts"],"names":[],"mappings":";;AA4NA,wEAgBC;AA3OD,wDAA8E;AAC9E,yDAAyD;AAEzD,qDAOgC;AAChC,4DAAqE;AACrE,sFAAiF;AACjF,2EAAsE;AAEtE;;;;;GAKG;AACH,SAAS,YAAY,CAAC,WAAgC;IACpD,MAAM,OAAO,GAAG,IAAA,+BAAoB,EAClC,wBAAwB,EACxB,WAAW,CACZ,CAAC,CAAC,CAAC,CAAC;IACL,IACE,IAAA,uBAAY,EAAC,OAAO,CAAC;QACrB,OAAO,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC;QAC/B,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,EAC1C,CAAC;QACD,OACE,OAAO,CAAC,UAAU,CAAC,CAAC,CACrB,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IACjB,CAAC;SAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACpB,OAAO,EAAE,CAAC;IACZ,CAAC;SAAM,CAAC;QACN,mEAAmE;QACnE,iEAAiE;QACjE,MAAM,IAAI,KAAK,CACb,+IAA+I,CAChJ,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,WAAW,CAClB,WAAgC,EAChC,QAAwB,EACxB,OAAe,EACf,MAAc;IAEd,MAAM,eAAe,GAAG;QACtB,2BAA2B;QAC3B,yBAAyB;QACzB,0BAA0B;QAC1B,2BAA2B;KAC5B;SACE,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;QACf,MAAM,QAAQ,GAAG,IAAA,+BAAoB,EAAC,GAAG,EAAE,WAAW,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CAAC,OAAO,CAAC,EAAE,CAAC;oBAC/B,eAAe,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;gBAClC,CAAC;qBAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;oBACpC,qBAAqB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;gBACxC,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,0BAA0B;gBAC1B,MAAM,GAAG,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACnE,MAAM,IAAI,KAAK,CAAC,qBAAqB,QAAQ,MAAM,GAAG,EAAE,CAAC,CAAC;YAC5D,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
@@ -2,7 +2,10 @@ import { UpdateRecorder } from '@angular-devkit/schematics';
2
2
  import ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
3
3
  export interface SwapImportedClassOptions {
4
4
  classNames: Record<string, string>;
5
- moduleName: string;
5
+ moduleName: string | {
6
+ old: string;
7
+ new: string;
8
+ };
6
9
  filter?: (node: ts.Identifier) => boolean;
7
10
  }
8
11
  export declare function swapImportedClass(recorder: UpdateRecorder, filePath: string, sourceFile: ts.SourceFile, options: SwapImportedClassOptions[]): void;
@@ -6,6 +6,7 @@ const schematics_1 = require("@angular/cdk/schematics");
6
6
  const typescript_1 = tslib_1.__importDefault(require("@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript"));
7
7
  const ast_utils_1 = require("@schematics/angular/utility/ast-utils");
8
8
  const change_1 = require("@schematics/angular/utility/change");
9
+ const eol_1 = require("@schematics/angular/utility/eol");
9
10
  const remove_import_1 = require("./remove-import");
10
11
  function findReferences(sourceFile, className) {
11
12
  return (0, ast_utils_1.findNodes)(sourceFile, typescript_1.default.SyntaxKind.Identifier).filter((node) => typescript_1.default.isIdentifier(node) && node.text === className);
@@ -15,14 +16,29 @@ function swapReference(recorder, reference, newClassName) {
15
16
  recorder.remove(start, reference.getWidth());
16
17
  recorder.insertRight(start, newClassName);
17
18
  }
19
+ function shiftLineBreakForInsertedImport(change, eol) {
20
+ if (change.toAdd.startsWith(`;${eol}import `)) {
21
+ // If the import is added after a semicolon, we need to remove the semicolon.
22
+ change.toAdd = change.toAdd.substring(`;${eol}`.length) + `;${eol}`;
23
+ change.pos += `;${eol}`.length;
24
+ }
25
+ }
26
+ function getModuleName(moduleName, field) {
27
+ return typeof moduleName === 'object' ? moduleName[field] : moduleName;
28
+ }
18
29
  function swapImportedClass(recorder, filePath, sourceFile, options) {
19
- const applicableOptions = options.filter((option) => Object.keys(option.classNames).some((className) => (0, schematics_1.isImported)(sourceFile, className, option.moduleName)));
30
+ const eol = (0, eol_1.getEOL)(sourceFile.text);
31
+ const applicableOptions = options.filter((option) => Object.keys(option.classNames).some((className) => typeof option.moduleName === 'object'
32
+ ? (0, schematics_1.isImported)(sourceFile, className, option.moduleName.old)
33
+ : (0, schematics_1.isImported)(sourceFile, className, option.moduleName)));
20
34
  if (applicableOptions.length === 0) {
21
35
  return;
22
36
  }
23
37
  const endOfImports = (0, ast_utils_1.findNodes)(sourceFile, typescript_1.default.SyntaxKind.ImportDeclaration).reduce((max, node) => Math.max(max, node.getEnd()), 0);
24
38
  const removeImports = {};
25
39
  applicableOptions.forEach(({ classNames, moduleName, filter }) => {
40
+ const oldModuleName = getModuleName(moduleName, 'old');
41
+ const newModuleName = getModuleName(moduleName, 'new');
26
42
  Object.entries(classNames).forEach(([oldClassName, newClassName]) => {
27
43
  const referencesInCode = findReferences(sourceFile, oldClassName).filter((reference) => reference.getStart() > endOfImports);
28
44
  const referencesFiltered = referencesInCode.filter(filter ?? (() => true));
@@ -31,25 +47,34 @@ function swapImportedClass(recorder, filePath, sourceFile, options) {
31
47
  });
32
48
  if (referencesFiltered.length > 0) {
33
49
  const allReferencesToBeReplaced = referencesFiltered.length === referencesInCode.length;
34
- if (!(0, schematics_1.isImported)(sourceFile, newClassName, moduleName)) {
50
+ if (!(0, schematics_1.isImported)(sourceFile, newClassName, newModuleName)) {
35
51
  if (allReferencesToBeReplaced) {
36
- const referencesInImport = findReferences(sourceFile, oldClassName).filter((reference) => reference.getEnd() < endOfImports);
37
- /* istanbul ignore if */
38
- if (referencesInImport.length !== 1) {
39
- throw new Error(`Expected exactly one import for ${oldClassName} from ${moduleName}, found ${referencesInImport.length}.`);
52
+ if (oldModuleName === newModuleName) {
53
+ const referencesInImport = findReferences(sourceFile, oldClassName).filter((reference) => reference.getEnd() <= endOfImports);
54
+ /* istanbul ignore if */
55
+ if (referencesInImport.length !== 1) {
56
+ throw new Error(`Expected exactly one import for ${oldClassName} from ${oldModuleName}, found ${referencesInImport.length}.`);
57
+ }
58
+ swapReference(recorder, referencesInImport[0], newClassName);
59
+ }
60
+ else {
61
+ const change = (0, ast_utils_1.insertImport)(sourceFile, filePath, newClassName, newModuleName);
62
+ shiftLineBreakForInsertedImport(change, eol);
63
+ (0, change_1.applyToUpdateRecorder)(recorder, [change]);
64
+ removeImports[oldModuleName] ??= [];
65
+ removeImports[oldModuleName].push(oldClassName);
40
66
  }
41
- swapReference(recorder, referencesInImport[0], newClassName);
42
67
  }
43
68
  else {
44
69
  (0, change_1.applyToUpdateRecorder)(recorder, [
45
- (0, ast_utils_1.insertImport)(sourceFile, filePath, newClassName, moduleName),
70
+ (0, ast_utils_1.insertImport)(sourceFile, filePath, newClassName, newModuleName),
46
71
  ]);
47
72
  }
48
73
  }
49
74
  else {
50
75
  if (allReferencesToBeReplaced) {
51
- removeImports[moduleName] ??= [];
52
- removeImports[moduleName].push(oldClassName);
76
+ removeImports[oldModuleName] ??= [];
77
+ removeImports[oldModuleName].push(oldClassName);
53
78
  }
54
79
  }
55
80
  }
@@ -1 +1 @@
1
- {"version":3,"file":"swap-imported-class.js","sourceRoot":"","sources":["../../../../../../../../libs/components/pack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M,KAAK,CAAC,EAAE,CAAC;4BACpC,MAAM,IAAI,KAAK,CACb,mCAAmC,YAAY,SAAS,UAAU,WAAW,kBAAkB,CAAC,MAAM,GAAG,CAC1G,CAAC;wBACJ,CAAC;wBACD,aAAa,CAAC,QAAQ,EAAE,kBAAkB,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;oBAC/D,CAAC;yBAAM,CAAC;wBACN,IAAA,8BAAqB,EAAC,QAAQ,EAAE;4BAC9B,IAAA,wBAAY,EAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,CAAC;yBAC7D,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,IAAI,yBAAyB,EAAE,CAAC;wBAC9B,aAAa,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;wBACjC,aAAa,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;oBAC/C,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1D,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE,CACvD,IAAA,4BAAY,EAAC,QAAQ,EAAE,UAAU,EAAE;YACjC,UAAU;YACV,UAAU;SACX,CAAC,CACH,CAAC;IACJ,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"swap-imported-class.js","sourceRoot":"","sources":["../../../../../../../../libs/components/packages/src/schematics/utility/typescript/swap-imported-class.ts"],"names":[],"mappings":";;AAwDA,8CA0FC;;AAjJD,wDAAqD;AACrD,wIAAgG;AAChG,qEAAgF;AAChF,+DAG4C;AAC5C,yDAAyD;AAEzD,mDAA+C;AAQ/C,SAAS,cAAc,CACrB,UAA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AAC;4BAC1C,aAAa,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;4BACpC,aAAa,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;wBAClD,CAAC;oBACH,CAAC;yBAAM,CAAC;wBACN,IAAA,8BAAqB,EAAC,QAAQ,EAAE;4BAC9B,IAAA,wBAAY,EAAC,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,aAAa,CAAC;yBAChE,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;qBAAM,CAAC;oBACN,IAAI,yBAAyB,EAAE,CAAC;wBAC9B,aAAa,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;wBACpC,aAAa,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;oBAClD,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAC1D,IAAI,mBAAmB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACnC,mBAAmB,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,EAAE,EAAE,CACvD,IAAA,4BAAY,EAAC,QAAQ,EAAE,UAAU,EAAE;YACjC,UAAU;YACV,UAAU;SACX,CAAC,CACH,CAAC;IACJ,CAAC;AACH,CAAC"}
package/src/version.js CHANGED
@@ -19,5 +19,5 @@ exports.Version = Version;
19
19
  /**
20
20
  * Represents the version of @skyux/core.
21
21
  */
22
- exports.VERSION = new Version('12.30.0');
22
+ exports.VERSION = new Version('12.32.0');
23
23
  //# sourceMappingURL=version.js.map
@@ -1,11 +0,0 @@
1
- /**
2
- * The contents of this file are heavily inspired by Angular's source code.
3
- * @see https://github.com/angular/angular/blob/14.3.x/packages/core/schematics/utils/typescript/imports.ts
4
- */
5
- import * as ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
6
- export interface ImportUsage {
7
- node: ts.Node;
8
- importName: string;
9
- }
10
- export declare function getImports(sourceFile: ts.SourceFile, packages: Map<string, string[]>): ts.ImportSpecifier[];
11
- export declare function getUsages(sourceFile: ts.SourceFile, importSpecifier: ts.ImportSpecifier): ImportUsage[];
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getImports = getImports;
4
- exports.getUsages = getUsages;
5
- const tslib_1 = require("tslib");
6
- /**
7
- * The contents of this file are heavily inspired by Angular's source code.
8
- * @see https://github.com/angular/angular/blob/14.3.x/packages/core/schematics/utils/typescript/imports.ts
9
- */
10
- const ts = tslib_1.__importStar(require("@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript"));
11
- function getImports(sourceFile, packages) {
12
- const importSpecifiers = [];
13
- for (const [packageName, classes] of packages.entries()) {
14
- for (const cc of classes) {
15
- const specifiers = getImportSpecifiers(sourceFile, packageName, cc);
16
- if (specifiers) {
17
- importSpecifiers.push(...specifiers);
18
- }
19
- }
20
- }
21
- return importSpecifiers;
22
- }
23
- function getUsages(sourceFile, importSpecifier) {
24
- const usages = [];
25
- const visitNode = (node) => {
26
- // Skip this node and all of its children; imports are a special case.
27
- if (ts.isImportSpecifier(node)) {
28
- return;
29
- }
30
- const importName = importSpecifier.getText(sourceFile);
31
- if (ts.isIdentifier(node) && node.escapedText === importName) {
32
- usages.push({ node, importName });
33
- }
34
- ts.forEachChild(node, visitNode);
35
- };
36
- ts.forEachChild(sourceFile, visitNode);
37
- return usages;
38
- }
39
- /**
40
- * Gets top-level import specifiers with a specific name that is imported from a particular module.
41
- * E.g. given a file that looks like:
42
- *
43
- * ```
44
- * import { Component, Directive } from '@angular/core';
45
- * import { Foo } from './foo';
46
- * ```
47
- *
48
- * Calling `getImportSpecifiers(sourceFile, '@angular/core', 'Directive')` will yield the nodes
49
- * referring to `Directive` in the top import.
50
- *
51
- * @param sourceFile File in which to look for imports.
52
- * @param moduleName Name of the import's module.
53
- * @param specifierName Original name of the specifier to look for. Aliases will be resolved to
54
- * their original name.
55
- */
56
- function getImportSpecifiers(sourceFile, moduleName, specifierName) {
57
- const importSpecifiers = [];
58
- for (const node of sourceFile.statements) {
59
- if (ts.isImportDeclaration(node) &&
60
- ts.isStringLiteral(node.moduleSpecifier) &&
61
- node.moduleSpecifier.text === moduleName) {
62
- const namedBindings = node.importClause && node.importClause.namedBindings;
63
- if (namedBindings && ts.isNamedImports(namedBindings)) {
64
- const match = findImportSpecifier(namedBindings.elements, specifierName);
65
- if (match) {
66
- importSpecifiers.push(match);
67
- }
68
- }
69
- }
70
- }
71
- return importSpecifiers;
72
- }
73
- /**
74
- * Finds an import specifier with a particular name.
75
- */
76
- function findImportSpecifier(nodes, specifierName) {
77
- return nodes.find((element) => {
78
- const { name, propertyName } = element;
79
- return propertyName?.text === specifierName || name.text === specifierName;
80
- });
81
- }
82
- //# sourceMappingURL=imports.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"imports.js","sourceRoot":"","sources":["../../../../../../../../libs/components/packages/src/schematics/utility/typescript/imports.ts"],"names":[],"mappings":";;AAWA,gCAiBC;AAED,8BAwBC;;AAtDD;;;GAGG;AACH,2HAAqG;AAOrG,SAAgB,UAAU,CACxB,UAAyB,EACzB,QAA+B;IAE/B,MAAM,gBAAgB,GAAyB,EAAE,CAAC;IAElD,KAAK,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,IAAI,QAAQ,CAAC,OAAO,EAAE,EAAE,CAAC;QACxD,KAAK,MAAM,EAAE,IAAI,OAAO,EAAE,CAAC;YACzB,MAAM,UAAU,GAAG,mBAAmB,CAAC,UAAU,EAAE,WAAW,EAAE,EAAE,CAAC,CAAC;YAEpE,IAAI,UAAU,EAAE,CAAC;gBACf,gBAAgB,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;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B,aAAa,CACd,CAAC;gBAEF,IAAI,KAAK,EAAE,CAAC;oBACV,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAC1B,KAAuC,EACvC,aAAqB;IAErB,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;QAC5B,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC;QAEvC,OAAO,YAAY,EAAE,IAAI,KAAK,aAAa,IAAI,IAAI,CAAC,IAAI,KAAK,aAAa,CAAC;IAC7E,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -1,2 +0,0 @@
1
- import * as ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
2
- export declare function createSourceFile(filePath: string, fileContents: string): ts.SourceFile;
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSourceFile = createSourceFile;
4
- const tslib_1 = require("tslib");
5
- const ts = tslib_1.__importStar(require("@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript"));
6
- function createSourceFile(filePath, fileContents) {
7
- return ts.createSourceFile(filePath, fileContents, ts.ScriptTarget.Latest, false, ts.ScriptKind.TS);
8
- }
9
- //# sourceMappingURL=source-file.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"source-file.js","sourceRoot":"","sources":["../../../../../../../../libs/components/packages/src/schematics/utility/typescript/source-file.ts"],"names":[],"mappings":";;AAEA,4CAWC;;AAbD,2HAAqG;AAErG,SAAgB,gBAAgB,CAC9B,QAAgB,EAChB,YAAoB;IAEpB,OAAO,EAAE,CAAC,gBAAgB,CACxB,QAAQ,EACR,YAAY,EACZ,EAAE,CAAC,YAAY,CAAC,MAAM,EACtB,KAAK,EACL,EAAE,CAAC,UAAU,CAAC,EAAE,CACjB,CAAC;AACJ,CAAC"}