@lucca-front/ng 21.1.0-split.0 → 21.1.1-rc.1
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/fesm2022/lucca-front-ng-a11y.mjs +2 -2
- package/fesm2022/lucca-front-ng-a11y.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-api.mjs +13 -45
- package/fesm2022/lucca-front-ng-api.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-app-layout.mjs +2 -2
- package/fesm2022/lucca-front-ng-app-layout.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-box.mjs +5 -4
- package/fesm2022/lucca-front-ng-box.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-breadcrumbs.mjs +2 -2
- package/fesm2022/lucca-front-ng-breadcrumbs.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-bubble-icon.mjs +2 -2
- package/fesm2022/lucca-front-ng-bubble-illustration.mjs +6 -1
- package/fesm2022/lucca-front-ng-bubble-illustration.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-callout.mjs +41 -15
- package/fesm2022/lucca-front-ng-callout.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-chip.mjs +35 -5
- package/fesm2022/lucca-front-ng-chip.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-clear.mjs +17 -2
- package/fesm2022/lucca-front-ng-clear.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-comment.mjs +20 -18
- package/fesm2022/lucca-front-ng-comment.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-container.mjs +5 -7
- package/fesm2022/lucca-front-ng-container.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-core-select-job-qualification.mjs +0 -2
- package/fesm2022/lucca-front-ng-core-select-job-qualification.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-core-select-user.mjs +2 -2
- package/fesm2022/lucca-front-ng-core-select-user.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-core-select.mjs +12 -19
- package/fesm2022/lucca-front-ng-core-select.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-data-table.mjs +5 -5
- package/fesm2022/lucca-front-ng-data-table.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-date.mjs +5 -37
- package/fesm2022/lucca-front-ng-date.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-date2.mjs +70 -31
- package/fesm2022/lucca-front-ng-date2.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-department.mjs +2 -18
- package/fesm2022/lucca-front-ng-department.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-dialog.mjs +13 -4
- package/fesm2022/lucca-front-ng-dialog.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-divider.mjs +12 -3
- package/fesm2022/lucca-front-ng-divider.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-dropdown.mjs +9 -8
- package/fesm2022/lucca-front-ng-dropdown.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-empty-state.mjs +20 -4
- package/fesm2022/lucca-front-ng-empty-state.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-establishment.mjs +2 -66
- package/fesm2022/lucca-front-ng-establishment.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-fancy-box.mjs +12 -0
- package/fesm2022/lucca-front-ng-fancy-box.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-file-upload.mjs +8 -8
- package/fesm2022/lucca-front-ng-file-upload.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-filter-pills.mjs +4 -4
- package/fesm2022/lucca-front-ng-filter-pills.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-footer.mjs +3 -0
- package/fesm2022/lucca-front-ng-footer.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-form-field.mjs +81 -11
- package/fesm2022/lucca-front-ng-form-field.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-form-header.mjs +3 -0
- package/fesm2022/lucca-front-ng-form-header.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-form.mjs +19 -5
- package/fesm2022/lucca-front-ng-form.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-phone-number-input.mjs +10 -9
- package/fesm2022/lucca-front-ng-forms-phone-number-input.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input-formatters-html.mjs +15 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input-formatters-html.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input-formatters-markdown.mjs +28 -3
- package/fesm2022/lucca-front-ng-forms-rich-text-input-formatters-markdown.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input-formatters-plain-text.mjs +15 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input-formatters-plain-text.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms-rich-text-input.mjs +53 -36
- package/fesm2022/lucca-front-ng-forms-rich-text-input.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-forms.mjs +97 -48
- package/fesm2022/lucca-front-ng-forms.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-gauge.mjs +28 -5
- package/fesm2022/lucca-front-ng-gauge.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-grid.mjs +3 -3
- package/fesm2022/lucca-front-ng-grid.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-highlight-data.mjs +31 -26
- package/fesm2022/lucca-front-ng-highlight-data.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-horizontal-navigation.mjs +5 -2
- package/fesm2022/lucca-front-ng-horizontal-navigation.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-index-table.mjs +5 -5
- package/fesm2022/lucca-front-ng-index-table.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-inline-message.mjs +14 -2
- package/fesm2022/lucca-front-ng-inline-message.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-link.mjs +17 -2
- package/fesm2022/lucca-front-ng-link.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-listbox.mjs +17 -5
- package/fesm2022/lucca-front-ng-listbox.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-listing.mjs +36 -7
- package/fesm2022/lucca-front-ng-listing.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-loading.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-main-layout.mjs +9 -2
- package/fesm2022/lucca-front-ng-main-layout.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-mobile-push.mjs +18 -10
- package/fesm2022/lucca-front-ng-mobile-push.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-modal.mjs +29 -18
- package/fesm2022/lucca-front-ng-modal.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-multi-select.mjs +18 -14
- package/fesm2022/lucca-front-ng-multi-select.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-new-badge.mjs +3 -0
- package/fesm2022/lucca-front-ng-new-badge.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-numeric-badge.mjs +12 -3
- package/fesm2022/lucca-front-ng-numeric-badge.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-option.mjs +203 -315
- package/fesm2022/lucca-front-ng-option.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-page-header.mjs +11 -2
- package/fesm2022/lucca-front-ng-page-header.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-pagination.mjs +24 -0
- package/fesm2022/lucca-front-ng-pagination.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-plg-push.mjs +7 -1
- package/fesm2022/lucca-front-ng-plg-push.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-popover.mjs +1 -33
- package/fesm2022/lucca-front-ng-popover.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-popover2.mjs +23 -19
- package/fesm2022/lucca-front-ng-popover2.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-progress-bar.mjs +12 -5
- package/fesm2022/lucca-front-ng-progress-bar.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-read-more.mjs +18 -3
- package/fesm2022/lucca-front-ng-read-more.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-resource-card.mjs +8 -8
- package/fesm2022/lucca-front-ng-resource-card.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-scroll-box.mjs +7 -4
- package/fesm2022/lucca-front-ng-scroll-box.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-segmented-control-tabs.mjs +11 -5
- package/fesm2022/lucca-front-ng-segmented-control-tabs.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-segmented-control.mjs +18 -3
- package/fesm2022/lucca-front-ng-segmented-control.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-simple-select.mjs +22 -7
- package/fesm2022/lucca-front-ng-simple-select.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-skeleton.mjs +71 -20
- package/fesm2022/lucca-front-ng-skeleton.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-software-icon.mjs +62 -0
- package/fesm2022/lucca-front-ng-software-icon.mjs.map +1 -0
- package/fesm2022/lucca-front-ng-sortable-list.mjs +24 -0
- package/fesm2022/lucca-front-ng-sortable-list.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-status-badge.mjs +14 -2
- package/fesm2022/lucca-front-ng-status-badge.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-tag.mjs +8 -2
- package/fesm2022/lucca-front-ng-tag.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-text-flow.mjs +20 -0
- package/fesm2022/lucca-front-ng-text-flow.mjs.map +1 -0
- package/fesm2022/lucca-front-ng-time.mjs +60 -16
- package/fesm2022/lucca-front-ng-time.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-tooltip.mjs +23 -22
- package/fesm2022/lucca-front-ng-tooltip.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-user-popover.mjs +2 -2
- package/fesm2022/lucca-front-ng-user-popover.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-user.mjs +11 -27
- package/fesm2022/lucca-front-ng-user.mjs.map +1 -1
- package/fesm2022/lucca-front-ng-vertical-navigation.mjs +32 -2
- package/fesm2022/lucca-front-ng-vertical-navigation.mjs.map +1 -1
- package/package.json +22 -14
- package/schematics/action-icon/index.js +4 -5
- package/schematics/action-icon/migration.js +3 -4
- package/schematics/action-icon/migration.spec.js +8 -8
- package/schematics/alignment-utilities/index.js +3 -4
- package/schematics/alignment-utilities/migration.spec.js +8 -8
- package/schematics/cdn-urls/index.js +3 -4
- package/schematics/cdn-urls/migration.js +8 -10
- package/schematics/cdn-urls/migration.spec.js +8 -8
- package/schematics/class-prefix/index.js +3 -4
- package/schematics/class-prefix/migration.spec.js +8 -8
- package/schematics/collection.json +10 -0
- package/schematics/color-text/index.js +3 -4
- package/schematics/color-text/migration.spec.js +8 -8
- package/schematics/component-path/index.js +3 -4
- package/schematics/component-path/migration.spec.js +8 -8
- package/schematics/empty-state-title/index.js +5 -7
- package/schematics/empty-state-title/migration.spec.js +5 -5
- package/schematics/lib/html-ast.js +11 -3
- package/schematics/lib/index.js +29 -0
- package/schematics/lib/schematic.utils.js +5 -0
- package/schematics/lu-button/index.js +3 -4
- package/schematics/lu-button/migration.js +5 -11
- package/schematics/lu-button/migration.spec.js +5 -5
- package/schematics/lu-container/index.js +23 -0
- package/schematics/lu-container/migration.js +116 -0
- package/schematics/lu-container/migration.spec.js +23 -0
- package/schematics/lu-container/schema.json +23 -0
- package/schematics/lu-icon/index.js +3 -4
- package/schematics/lu-icon/migration.js +8 -14
- package/schematics/lu-icon/migration.spec.js +5 -5
- package/schematics/lu-loading/index.js +23 -0
- package/schematics/lu-loading/migration.js +136 -0
- package/schematics/lu-loading/migration.spec.js +23 -0
- package/schematics/lu-loading/schema.json +28 -0
- package/schematics/lu-select/index.js +3 -4
- package/schematics/lu-select/migration.js +18 -21
- package/schematics/lu-select/migration.spec.js +5 -5
- package/schematics/lu-select/util.js +17 -19
- package/schematics/lu-text-input/index.js +3 -4
- package/schematics/lu-text-input/migration.js +22 -28
- package/schematics/lu-text-input/migration.spec.js +5 -5
- package/schematics/new-icons/index.js +5 -6
- package/schematics/new-icons/migration.js +11 -16
- package/schematics/new-icons/migration.spec.js +8 -8
- package/schematics/ng-add/file-content.js +6 -8
- package/schematics/ng-add/index.js +5 -5
- package/schematics/ng-add/tasks.js +22 -17
- package/schematics/palettes/index.js +3 -4
- package/schematics/palettes/migration.spec.js +8 -8
- package/schematics/tokens-radius/index.js +3 -4
- package/schematics/tokens-radius/migration.spec.js +8 -8
- package/schematics/tokens-spacing/index.js +3 -4
- package/schematics/tokens-spacing/migration.spec.js +8 -8
- package/schematics/tokens-typo/index.js +3 -4
- package/schematics/tokens-typo/migration.spec.js +8 -8
- package/src/components/cdk/_overlay.scss +5 -0
- package/src/definitions/option/_option-item.scss +1 -0
- package/types/lucca-front-ng-a11y.d.ts +1 -1
- package/types/lucca-front-ng-api.d.ts +1 -19
- package/types/lucca-front-ng-box.d.ts +2 -1
- package/types/lucca-front-ng-breadcrumbs.d.ts +1 -1
- package/types/lucca-front-ng-bubble-illustration.d.ts +1 -1
- package/types/lucca-front-ng-callout.d.ts +32 -2
- package/types/lucca-front-ng-chip.d.ts +32 -2
- package/types/lucca-front-ng-clear.d.ts +20 -5
- package/types/lucca-front-ng-comment.d.ts +19 -11
- package/types/lucca-front-ng-container.d.ts +4 -4
- package/types/lucca-front-ng-core-select.d.ts +3 -2
- package/types/lucca-front-ng-date.d.ts +1 -19
- package/types/lucca-front-ng-date2.d.ts +21 -18
- package/types/lucca-front-ng-department.d.ts +1 -10
- package/types/lucca-front-ng-dialog.d.ts +6 -3
- package/types/lucca-front-ng-divider.d.ts +10 -0
- package/types/lucca-front-ng-empty-state.d.ts +18 -2
- package/types/lucca-front-ng-establishment.d.ts +1 -37
- package/types/lucca-front-ng-fancy-box.d.ts +12 -0
- package/types/lucca-front-ng-footer.d.ts +3 -0
- package/types/lucca-front-ng-form-field.d.ts +36 -5
- package/types/lucca-front-ng-form-header.d.ts +3 -0
- package/types/lucca-front-ng-form.d.ts +9 -5
- package/types/lucca-front-ng-forms-phone-number-input.d.ts +1 -0
- package/types/lucca-front-ng-forms-rich-text-input-formatters-html.d.ts +7 -1
- package/types/lucca-front-ng-forms-rich-text-input-formatters-markdown.d.ts +11 -1
- package/types/lucca-front-ng-forms-rich-text-input-formatters-plain-text.d.ts +7 -1
- package/types/lucca-front-ng-forms-rich-text-input.d.ts +2 -0
- package/types/lucca-front-ng-forms.d.ts +21 -9
- package/types/lucca-front-ng-gauge.d.ts +25 -0
- package/types/lucca-front-ng-grid.d.ts +1 -1
- package/types/lucca-front-ng-highlight-data.d.ts +36 -15
- package/types/lucca-front-ng-horizontal-navigation.d.ts +3 -0
- package/types/lucca-front-ng-inline-message.d.ts +12 -0
- package/types/lucca-front-ng-link.d.ts +15 -0
- package/types/lucca-front-ng-listbox.d.ts +16 -4
- package/types/lucca-front-ng-listing.d.ts +33 -2
- package/types/lucca-front-ng-main-layout.d.ts +6 -0
- package/types/lucca-front-ng-mobile-push.d.ts +7 -0
- package/types/lucca-front-ng-modal.d.ts +3 -1
- package/types/lucca-front-ng-new-badge.d.ts +3 -0
- package/types/lucca-front-ng-numeric-badge.d.ts +9 -0
- package/types/lucca-front-ng-option.d.ts +78 -141
- package/types/lucca-front-ng-page-header.d.ts +9 -0
- package/types/lucca-front-ng-pagination.d.ts +25 -1
- package/types/lucca-front-ng-plg-push.d.ts +7 -1
- package/types/lucca-front-ng-popover.d.ts +1 -20
- package/types/lucca-front-ng-popover2.d.ts +7 -4
- package/types/lucca-front-ng-progress-bar.d.ts +9 -0
- package/types/lucca-front-ng-read-more.d.ts +16 -1
- package/types/lucca-front-ng-resource-card.d.ts +6 -0
- package/types/lucca-front-ng-scroll-box.d.ts +4 -1
- package/types/lucca-front-ng-segmented-control-tabs.d.ts +7 -1
- package/types/lucca-front-ng-segmented-control.d.ts +16 -1
- package/types/lucca-front-ng-skeleton.d.ts +61 -6
- package/types/lucca-front-ng-software-icon.d.ts +19 -0
- package/types/lucca-front-ng-sortable-list.d.ts +24 -0
- package/types/lucca-front-ng-status-badge.d.ts +12 -0
- package/types/lucca-front-ng-tag.d.ts +6 -0
- package/types/lucca-front-ng-text-flow.d.ts +8 -0
- package/types/lucca-front-ng-time.d.ts +18 -12
- package/types/lucca-front-ng-tooltip.d.ts +2 -11
- package/types/lucca-front-ng-user.d.ts +2 -11
- package/types/lucca-front-ng-vertical-navigation.d.ts +30 -0
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const path = require("path");
|
|
4
|
-
const
|
|
4
|
+
const lib_1 = require("../lib");
|
|
5
5
|
const collectionPath = path.normalize(path.join(__dirname, '..', 'collection.json'));
|
|
6
6
|
const testsRoot = path.join(__dirname, 'tests');
|
|
7
7
|
describe('lu-icon Migration', () => {
|
|
8
8
|
it('should handle basic case files', async () => {
|
|
9
9
|
// Arrange
|
|
10
|
-
const tree = (0,
|
|
11
|
-
const expectedTree = (0,
|
|
10
|
+
const tree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'input'));
|
|
11
|
+
const expectedTree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'output'));
|
|
12
12
|
// Act
|
|
13
13
|
try {
|
|
14
|
-
await (0,
|
|
14
|
+
await (0, lib_1.runSchematic)('collection', collectionPath, 'lu-icon', { skipInstallation: true }, tree);
|
|
15
15
|
}
|
|
16
16
|
catch (error) {
|
|
17
17
|
// eslint-disable-next-line no-console
|
|
18
18
|
console.log(error);
|
|
19
19
|
}
|
|
20
20
|
// Assert
|
|
21
|
-
(0,
|
|
21
|
+
(0, lib_1.expectTree)(tree).toMatchTree(expectedTree);
|
|
22
22
|
});
|
|
23
23
|
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const typescript_1 = require("typescript");
|
|
4
|
+
const lib_1 = require("../lib");
|
|
5
|
+
const migration_1 = require("./migration");
|
|
6
|
+
// Nx need to see "@angular-devkit/schematics" in order to run this migration correctly (see https://github.com/nrwl/nx/blob/d9fed4b832bf01d1b9a44ae9e486a5e5cd2d2253/packages/nx/src/command-line/migrate/migrate.ts#L1729-L1738)
|
|
7
|
+
require('@angular-devkit/schematics');
|
|
8
|
+
exports.default = (options) => {
|
|
9
|
+
return async (tree, context) => {
|
|
10
|
+
await lib_1.currentSchematicContext.init(context, options);
|
|
11
|
+
tree.visit((path, entry) => {
|
|
12
|
+
if (path.includes('node_modules') || !entry) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (path.endsWith('.ts')) {
|
|
16
|
+
(0, lib_1.migrateFile)(path, entry, tree, (content) => {
|
|
17
|
+
const sourceFile = (0, typescript_1.createSourceFile)(path, content, typescript_1.ScriptTarget.ESNext);
|
|
18
|
+
return (0, migration_1.migrateComponent)(sourceFile, path, tree);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.migrateComponent = migrateComponent;
|
|
4
|
+
const change_1 = require("@schematics/angular/utility/change");
|
|
5
|
+
const lib_1 = require("../lib");
|
|
6
|
+
function migrateComponent(sourceFile, path, tree) {
|
|
7
|
+
const htmlLoadings = findHTMLLoadings(sourceFile, path, tree);
|
|
8
|
+
if (htmlLoadings.length > 0) {
|
|
9
|
+
const tsUpdate = tree.beginUpdate(path);
|
|
10
|
+
const isInlineTemplate = htmlLoadings[0].filePath === path;
|
|
11
|
+
const templateUpdate = isInlineTemplate ? tsUpdate : tree.beginUpdate(htmlLoadings[0].filePath);
|
|
12
|
+
htmlLoadings.forEach((loading) => {
|
|
13
|
+
const classesNode = loading.node.attributes.find(attr => attr.name === 'class');
|
|
14
|
+
const loadingNodeLength = loading.node.name.length;
|
|
15
|
+
const hasAriaHidden = loading.node.attributes.find(attr => attr.name === 'aria-hidden');
|
|
16
|
+
const hasStyle = loading.node.attributes.find(attr => attr.name === 'style');
|
|
17
|
+
// remove element name attribute
|
|
18
|
+
templateUpdate.remove(loading.nodeOffset + loading.node.startSourceSpan.start.offset + 1, loadingNodeLength);
|
|
19
|
+
if (classesNode && classesNode.keySpan) {
|
|
20
|
+
/**
|
|
21
|
+
* Add stuff
|
|
22
|
+
*/
|
|
23
|
+
let thingsToAdd = `lu-loading${hasThingsToAdd(loading.inputs) || hasAriaHidden || hasStyle ? '' : ' '}`;
|
|
24
|
+
if (loading.inputs.block) {
|
|
25
|
+
thingsToAdd += ` block`;
|
|
26
|
+
}
|
|
27
|
+
if (loading.inputs.invert) {
|
|
28
|
+
thingsToAdd += ` invert`;
|
|
29
|
+
}
|
|
30
|
+
if (loading.inputs.size) {
|
|
31
|
+
thingsToAdd += ` size="L"`;
|
|
32
|
+
}
|
|
33
|
+
if (loading.inputs.template) {
|
|
34
|
+
thingsToAdd += ` template="${loading.inputs.template}"`;
|
|
35
|
+
}
|
|
36
|
+
// with content
|
|
37
|
+
if (loading.node.children.length > 0 && loading.node.endSourceSpan) {
|
|
38
|
+
templateUpdate.remove(loading.nodeOffset + loading.node.endSourceSpan.start.offset + 1, loadingNodeLength + 1);
|
|
39
|
+
templateUpdate.insertRight(loading.nodeOffset + loading.node.startSourceSpan.start.offset + 1, thingsToAdd);
|
|
40
|
+
templateUpdate.insertLeft(loading.nodeOffset + loading.node.endSourceSpan.start.offset + 1, '/lu-loading');
|
|
41
|
+
}
|
|
42
|
+
// without closing
|
|
43
|
+
else if (!loading.node.isSelfClosing) {
|
|
44
|
+
const endSpanOffset = loading.node.endSourceSpan?.start.offset || -1;
|
|
45
|
+
templateUpdate.remove(loading.nodeOffset + loading.node.startSourceSpan.end.offset, endSpanOffset - loading.node.startSourceSpan.end.offset);
|
|
46
|
+
if (loading.node.endSourceSpan?.start?.offset) {
|
|
47
|
+
templateUpdate.remove(loading.nodeOffset + loading.node.endSourceSpan?.start?.offset, loading.node.endSourceSpan?.toString().length);
|
|
48
|
+
}
|
|
49
|
+
templateUpdate.insertRight(loading.nodeOffset + loading.node.startSourceSpan.start.offset + 1, thingsToAdd);
|
|
50
|
+
templateUpdate.insertRight(loading.nodeOffset + loading.node.startSourceSpan.end.offset - 1, `${hasThingsToAdd(loading.inputs) || hasAriaHidden || hasStyle ? ' ' : ''}/`);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Modify classes
|
|
54
|
+
*/
|
|
55
|
+
if (classesNode && classesNode.keySpan) {
|
|
56
|
+
const classes = classesNode.value;
|
|
57
|
+
const cleanedClasses = classes.split(' ').filter(c => {
|
|
58
|
+
return ![`mod-L`, `mod-block`, `mod-invert`, `loading`, `mod-invert`, `mod-popin`, `mod-drawer`, `mod-fullPage`, `mod-fullpage`].includes(c);
|
|
59
|
+
}).join(' ');
|
|
60
|
+
templateUpdate.remove(loading.nodeOffset + classesNode.keySpan.start.offset - 1, classesNode.sourceSpan.toString().length + 1);
|
|
61
|
+
if (cleanedClasses) {
|
|
62
|
+
templateUpdate.insertRight(loading.nodeOffset + classesNode.keySpan.start.offset, `${hasThingsToAdd(loading.inputs) || hasAriaHidden || hasStyle ? ' ' : ''}class="${cleanedClasses}"`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
// Add import if needed
|
|
68
|
+
(0, change_1.applyToUpdateRecorder)(tsUpdate, [(0, lib_1.insertTSImportIfNeeded)(sourceFile, path, 'LoadingComponent', '@lucca-front/ng/loading'), (0, lib_1.insertAngularImportIfNeeded)(sourceFile, path, 'LoadingComponent')]);
|
|
69
|
+
tree.commitUpdate(tsUpdate);
|
|
70
|
+
if (!isInlineTemplate) {
|
|
71
|
+
tree.commitUpdate(templateUpdate);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return tree.readText(path);
|
|
75
|
+
}
|
|
76
|
+
function findHTMLLoadings(sourceFile, basePath, tree) {
|
|
77
|
+
const htmlLoadings = [];
|
|
78
|
+
const ngTemplates = (0, lib_1.extractNgTemplatesIncludingHtml)(sourceFile, tree, basePath);
|
|
79
|
+
ngTemplates.forEach((template) => {
|
|
80
|
+
const htmlAst = new lib_1.HtmlAst(template.content);
|
|
81
|
+
htmlAst.visitNodes((node) => {
|
|
82
|
+
if ((0, lib_1.isInterestingNode)(node)) {
|
|
83
|
+
const classes = node.attributes.find(attr => attr.name === 'class')?.value;
|
|
84
|
+
// match check if it's only "loading" not loading-custom ...
|
|
85
|
+
if (classes?.includes("loading") && classes?.match(/(^|\s)loading(\s|$)/)) {
|
|
86
|
+
const loading = classes.split(' ').find(c => c.startsWith('loading'));
|
|
87
|
+
if (loading) {
|
|
88
|
+
const inputs = {
|
|
89
|
+
size: classes.split(' ').find(c => /mod-L/.test(c)),
|
|
90
|
+
block: classes.includes('mod-block') ? true : undefined,
|
|
91
|
+
invert: classes.includes('mod-invert') ? true : undefined,
|
|
92
|
+
template: getLoadingTemplate(classes),
|
|
93
|
+
};
|
|
94
|
+
const loading = {
|
|
95
|
+
node: node,
|
|
96
|
+
inputs,
|
|
97
|
+
nodeOffset: template.offsetStart,
|
|
98
|
+
filePath: template.filePath,
|
|
99
|
+
componentTS: sourceFile,
|
|
100
|
+
};
|
|
101
|
+
htmlLoadings.push(loading);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
return htmlLoadings;
|
|
108
|
+
}
|
|
109
|
+
function hasThingsToAdd(inputs) {
|
|
110
|
+
if (inputs?.block) {
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
if (inputs?.invert) {
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
if (inputs?.size) {
|
|
117
|
+
return true;
|
|
118
|
+
}
|
|
119
|
+
if (inputs?.template) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
function getLoadingTemplate(classes) {
|
|
125
|
+
if (classes.includes('mod-popin')) {
|
|
126
|
+
return 'popin';
|
|
127
|
+
}
|
|
128
|
+
if (classes.includes('mod-drawer')) {
|
|
129
|
+
return 'drawer';
|
|
130
|
+
}
|
|
131
|
+
// fullpage is deprecated so we always use fullPage here
|
|
132
|
+
if (classes.includes('mod-fullPage') || classes.includes('mod-fullpage')) {
|
|
133
|
+
return 'fullPage';
|
|
134
|
+
}
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const lib_1 = require("../lib");
|
|
5
|
+
const collectionPath = path.normalize(path.join(__dirname, '..', 'collection.json'));
|
|
6
|
+
const testsRoot = path.join(__dirname, 'tests');
|
|
7
|
+
describe('lu-loading Migration', () => {
|
|
8
|
+
it('should handle basic case files', async () => {
|
|
9
|
+
// Arrange
|
|
10
|
+
const tree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'input'));
|
|
11
|
+
const expectedTree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'output'));
|
|
12
|
+
// Act
|
|
13
|
+
try {
|
|
14
|
+
await (0, lib_1.runSchematic)('collection', collectionPath, 'lu-loading', { skipInstallation: true }, tree);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
// eslint-disable-next-line no-console
|
|
18
|
+
console.log(error);
|
|
19
|
+
}
|
|
20
|
+
// Assert
|
|
21
|
+
(0, lib_1.expectTree)(tree).toMatchTree(expectedTree);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema",
|
|
3
|
+
"$id": "LuccaFrontLuLoading",
|
|
4
|
+
"title": "Lucca Front loading html migration into lu-loading angular component",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"properties": {
|
|
7
|
+
"dryRun": {
|
|
8
|
+
"type": "boolean",
|
|
9
|
+
"description": "Run through the migration without making any changes.",
|
|
10
|
+
"default": false
|
|
11
|
+
},
|
|
12
|
+
"skipInstall": {
|
|
13
|
+
"type": "boolean",
|
|
14
|
+
"description": "Skip installing dependencies.",
|
|
15
|
+
"default": false
|
|
16
|
+
},
|
|
17
|
+
"verbose": {
|
|
18
|
+
"type": "boolean",
|
|
19
|
+
"description": "Enable verbose logging.",
|
|
20
|
+
"default": false
|
|
21
|
+
},
|
|
22
|
+
"noComments": {
|
|
23
|
+
"type": "boolean",
|
|
24
|
+
"description": "Don't put comments about select migration rejections in result files.",
|
|
25
|
+
"default": false
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const typescript_1 = require("typescript");
|
|
4
|
-
const
|
|
5
|
-
const schematics_1 = require("../lib/schematics");
|
|
4
|
+
const lib_1 = require("../lib");
|
|
6
5
|
const migration_1 = require("./migration");
|
|
7
6
|
// Nx need to see "@angular-devkit/schematics" in order to run this migration correctly (see https://github.com/nrwl/nx/blob/d9fed4b832bf01d1b9a44ae9e486a5e5cd2d2253/packages/nx/src/command-line/migrate/migrate.ts#L1729-L1738)
|
|
8
7
|
require('@angular-devkit/schematics');
|
|
9
8
|
exports.default = (options) => {
|
|
10
9
|
return async (tree, context) => {
|
|
11
|
-
await
|
|
10
|
+
await lib_1.currentSchematicContext.init(context, options);
|
|
12
11
|
tree.visit((path, entry) => {
|
|
13
12
|
if (path.includes('node_modules') || !entry) {
|
|
14
13
|
return;
|
|
15
14
|
}
|
|
16
15
|
if (path.endsWith('.ts')) {
|
|
17
|
-
(0,
|
|
16
|
+
(0, lib_1.migrateFile)(path, entry, tree, (content) => {
|
|
18
17
|
const sourceFile = (0, typescript_1.createSourceFile)(path, content, typescript_1.ScriptTarget.ESNext);
|
|
19
18
|
return (0, migration_1.migrateComponent)(sourceFile, path, tree, options?.noComments);
|
|
20
19
|
});
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.migrateComponent = migrateComponent;
|
|
4
|
-
const html_ast_js_1 = require("../lib/html-ast.js");
|
|
5
|
-
const typescript_1 = require("typescript");
|
|
6
|
-
const angular_component_ast_1 = require("../lib/angular-component-ast");
|
|
7
|
-
const angular_template_1 = require("../lib/angular-template");
|
|
8
|
-
const util_1 = require("./util");
|
|
9
|
-
const select_context_1 = require("./model/select-context");
|
|
10
4
|
const change_1 = require("@schematics/angular/utility/change");
|
|
11
5
|
const eol_1 = require("@schematics/angular/utility/eol");
|
|
12
|
-
const
|
|
6
|
+
const typescript_1 = require("typescript");
|
|
7
|
+
const lib_1 = require("../lib");
|
|
8
|
+
const select_context_1 = require("./model/select-context");
|
|
9
|
+
const util_1 = require("./util");
|
|
13
10
|
const importSource = {
|
|
14
11
|
LuSimpleSelectInputComponent: '@lucca-front/ng/simple-select',
|
|
15
12
|
LuMultiSelectInputComponent: '@lucca-front/ng/multi-select',
|
|
@@ -55,13 +52,13 @@ function migrateComponent(sourceFile, path, tree, noComments = false) {
|
|
|
55
52
|
// We're not checking using else here because handle** methods can also add a rejection reason
|
|
56
53
|
// We want to handle both cases (before handling and after) here
|
|
57
54
|
if (select.rejection) {
|
|
58
|
-
|
|
55
|
+
lib_1.currentSchematicContext.logFailure(`Couldn't migrate ${select.component} in ${path}: ${util_1.RejectionReason[select.rejection.reason]}`);
|
|
59
56
|
if (!noComments) {
|
|
60
57
|
insertRejectionComment(templateUpdate, select);
|
|
61
58
|
}
|
|
62
59
|
}
|
|
63
60
|
else {
|
|
64
|
-
|
|
61
|
+
lib_1.currentSchematicContext.logSuccess(`Migrated ${select.component} in ${path}`);
|
|
65
62
|
}
|
|
66
63
|
});
|
|
67
64
|
tree.commitUpdate(tsUpdate);
|
|
@@ -99,18 +96,18 @@ function insertRejectionComment(update, select) {
|
|
|
99
96
|
update.insertLeft(select.nodeOffset + select.node.startSourceSpan.start.offset, `<!-- [lu-select migration] REJECTED: ${detailedReason || util_1.RejectionReason[select.rejection.reason]} -->\n${indentBefore}`);
|
|
100
97
|
}
|
|
101
98
|
function findSelectContexts(sourceFile, basePath, tree) {
|
|
102
|
-
const imports = (0,
|
|
99
|
+
const imports = (0, lib_1.extractComponentImports)(sourceFile);
|
|
103
100
|
if (possibleSelectComponents.some((c) => imports.includes(c))) {
|
|
104
101
|
const selects = [];
|
|
105
|
-
const template = (0,
|
|
106
|
-
const htmlAst = new
|
|
102
|
+
const template = (0, lib_1.extractNgTemplatesIncludingHtml)(sourceFile, tree, basePath)[0];
|
|
103
|
+
const htmlAst = new lib_1.HtmlAst(template.content);
|
|
107
104
|
htmlAst.visitNodes((node) => {
|
|
108
|
-
if (node instanceof
|
|
105
|
+
if (node instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstElement) {
|
|
109
106
|
const selectComponentClass = selectorToComponentNameRecord[node.name];
|
|
110
107
|
const multipleInput = node.inputs.find((attr) => attr.name === 'multiple');
|
|
111
|
-
const unsupportedMultiple = multipleInput?.value instanceof
|
|
108
|
+
const unsupportedMultiple = multipleInput?.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource && multipleInput.value.source !== 'true';
|
|
112
109
|
const multipleAttr = node.attributes.find((attr) => attr.name === 'multiple');
|
|
113
|
-
const multipleFromInput = multipleInput?.value instanceof
|
|
110
|
+
const multipleFromInput = multipleInput?.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource && multipleInput.value.source === 'true'
|
|
114
111
|
? { start: multipleInput?.sourceSpan?.start?.offset, end: multipleInput?.sourceSpan?.end?.offset + 1 }
|
|
115
112
|
: null;
|
|
116
113
|
const multipleFromAttr = multipleAttr && (multipleAttr.value === 'true' || multipleAttr.value === '') ? { start: multipleAttr?.sourceSpan?.start?.offset, end: multipleAttr?.sourceSpan?.end?.offset + 1 } : null;
|
|
@@ -145,7 +142,7 @@ function updateImports(sourceFile, selects, path, tree) {
|
|
|
145
142
|
const imports = new Set(selects.filter((s) => !s.rejection).flatMap((select) => select.requiredImports || []));
|
|
146
143
|
imports.forEach((importToAdd) => {
|
|
147
144
|
if (importSource[importToAdd]) {
|
|
148
|
-
(0, change_1.applyToUpdateRecorder)(update, [(0,
|
|
145
|
+
(0, change_1.applyToUpdateRecorder)(update, [(0, lib_1.insertTSImportIfNeeded)(sourceFile, path, importToAdd, importSource[importToAdd]), (0, lib_1.insertAngularImportIfNeeded)(sourceFile, path, importToAdd)]);
|
|
149
146
|
}
|
|
150
147
|
else {
|
|
151
148
|
console.error(`Can't add import for ${importToAdd} because source is unknown`);
|
|
@@ -155,11 +152,11 @@ function updateImports(sourceFile, selects, path, tree) {
|
|
|
155
152
|
const componentsCleanupUpdate = tree.beginUpdate(path);
|
|
156
153
|
// Cleanup unused select component imports
|
|
157
154
|
const updatedSourceFile = (0, typescript_1.createSourceFile)(path, tree.readText(path), typescript_1.ScriptTarget.ESNext);
|
|
158
|
-
const templatesAfterUpdate = (0,
|
|
155
|
+
const templatesAfterUpdate = (0, lib_1.extractNgTemplatesIncludingHtml)(updatedSourceFile, tree, path);
|
|
159
156
|
templatesAfterUpdate.forEach((template) => {
|
|
160
157
|
Object.entries(select_context_1.selectorToComponentName).forEach(([selector, className]) => {
|
|
161
158
|
if (!template.content.includes(selector)) {
|
|
162
|
-
(0, change_1.applyToUpdateRecorder)(componentsCleanupUpdate, [(0,
|
|
159
|
+
(0, change_1.applyToUpdateRecorder)(componentsCleanupUpdate, [(0, lib_1.removeTSImport)(updatedSourceFile, path, className), (0, lib_1.removeAngularImport)(updatedSourceFile, path, className)]);
|
|
163
160
|
}
|
|
164
161
|
});
|
|
165
162
|
});
|
|
@@ -178,7 +175,7 @@ function updateImports(sourceFile, selects, path, tree) {
|
|
|
178
175
|
function handleLuSelectInputComponent(select, update) {
|
|
179
176
|
const dataSource = (0, util_1.getDataSource)(select);
|
|
180
177
|
let hasClearer = false;
|
|
181
|
-
new
|
|
178
|
+
new lib_1.HtmlAstVisitor(select.node).visitElements(/lu-input-clearer/, (node) => {
|
|
182
179
|
// Doing the check just in case
|
|
183
180
|
if (node.name === 'lu-input-clearer') {
|
|
184
181
|
hasClearer = true;
|
|
@@ -275,14 +272,14 @@ function handleApiSelectInputComponent(select, update) {
|
|
|
275
272
|
}
|
|
276
273
|
});
|
|
277
274
|
select.node.inputs.forEach((input) => {
|
|
278
|
-
if (input.name === 'api' && input.value instanceof
|
|
275
|
+
if (input.name === 'api' && input.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource) {
|
|
279
276
|
apiEndpoint = input.value?.source || '';
|
|
280
277
|
oldApiInput = {
|
|
281
278
|
pos: input.sourceSpan.start.offset,
|
|
282
279
|
length: input.sourceSpan.end.offset - input.sourceSpan.start.offset
|
|
283
280
|
};
|
|
284
281
|
}
|
|
285
|
-
if (input.name === 'standard' && input.value instanceof
|
|
282
|
+
if (input.name === 'standard' && input.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource) {
|
|
286
283
|
apiStandard = (input.value?.source || 'v3');
|
|
287
284
|
oldApiStandard = {
|
|
288
285
|
pos: input.sourceSpan.start.offset,
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const path = require("path");
|
|
4
|
-
const
|
|
4
|
+
const lib_1 = require("../lib");
|
|
5
5
|
const collectionPath = path.normalize(path.join(__dirname, '..', 'collection.json'));
|
|
6
6
|
const testsRoot = path.join(__dirname, 'tests');
|
|
7
7
|
describe('lu-select Migration', () => {
|
|
8
8
|
it('should handle basic case files', async () => {
|
|
9
9
|
// Arrange
|
|
10
|
-
const tree = (0,
|
|
11
|
-
const expectedTree = (0,
|
|
10
|
+
const tree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'input'));
|
|
11
|
+
const expectedTree = (0, lib_1.createTreeFromFolder)(path.join(testsRoot, 'output'));
|
|
12
12
|
// Act
|
|
13
13
|
try {
|
|
14
|
-
await (0,
|
|
14
|
+
await (0, lib_1.runSchematic)('collection', collectionPath, 'lu-select', { skipInstallation: true }, tree);
|
|
15
15
|
}
|
|
16
16
|
catch (error) {
|
|
17
17
|
// eslint-disable-next-line no-console
|
|
18
18
|
console.log(error);
|
|
19
19
|
}
|
|
20
20
|
// Assert
|
|
21
|
-
(0,
|
|
21
|
+
(0, lib_1.expectTree)(tree).toMatchTree(expectedTree);
|
|
22
22
|
});
|
|
23
23
|
});
|
|
@@ -5,9 +5,7 @@ exports.isRejection = isRejection;
|
|
|
5
5
|
exports.getCommonMigrationRejectionReason = getCommonMigrationRejectionReason;
|
|
6
6
|
exports.getDataSource = getDataSource;
|
|
7
7
|
exports.getDisplayer = getDisplayer;
|
|
8
|
-
const
|
|
9
|
-
const angular_component_ast_1 = require("../lib/angular-component-ast");
|
|
10
|
-
const lf_schematic_context_1 = require("../lib/lf-schematic-context");
|
|
8
|
+
const lib_1 = require("../lib");
|
|
11
9
|
var RejectionReason;
|
|
12
10
|
(function (RejectionReason) {
|
|
13
11
|
RejectionReason[RejectionReason["UNSUPPORTED_ATTRIBUTE"] = 0] = "UNSUPPORTED_ATTRIBUTE";
|
|
@@ -28,7 +26,7 @@ function isRejection(value) {
|
|
|
28
26
|
return value?.reason !== undefined && RejectionReason[value.reason] != undefined;
|
|
29
27
|
}
|
|
30
28
|
function getCommonMigrationRejectionReason(node, sourceFile) {
|
|
31
|
-
if (node instanceof
|
|
29
|
+
if (node instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstElement) {
|
|
32
30
|
const unsupportedAttr = node.attributes.find((attr) => !allowedAttributes.some((rxp) => rxp.test(attr.name)));
|
|
33
31
|
if (unsupportedAttr) {
|
|
34
32
|
return {
|
|
@@ -43,7 +41,7 @@ function getCommonMigrationRejectionReason(node, sourceFile) {
|
|
|
43
41
|
details: unsupportedInput.name
|
|
44
42
|
};
|
|
45
43
|
}
|
|
46
|
-
const providers = (0,
|
|
44
|
+
const providers = (0, lib_1.extractProviders)(sourceFile);
|
|
47
45
|
if (providers.length > 0) {
|
|
48
46
|
switch (node.name) {
|
|
49
47
|
case 'lu-establishment-select':
|
|
@@ -99,7 +97,7 @@ function getDataSource(select) {
|
|
|
99
97
|
let result = {
|
|
100
98
|
reason: RejectionReason.NO_DATA_SOURCE
|
|
101
99
|
};
|
|
102
|
-
const htmlAstVisitor = new
|
|
100
|
+
const htmlAstVisitor = new lib_1.HtmlAstVisitor(select.node);
|
|
103
101
|
let rejected = false;
|
|
104
102
|
// First of all, check that there's no lu-option-select-all, because this is a rejection reason
|
|
105
103
|
htmlAstVisitor.visitElements(/(lu-option-select-all)|(lu-tree-.*)/, (node) => {
|
|
@@ -121,7 +119,7 @@ function getDataSource(select) {
|
|
|
121
119
|
}
|
|
122
120
|
htmlAstVisitor.visitElements(/lu-option-picker(-advanced)?/, (node) => {
|
|
123
121
|
// If picker doesn't have option as direct child, reject, we can't migrate this kind of custom stuff
|
|
124
|
-
const luOption = node.children.find((c) => c instanceof
|
|
122
|
+
const luOption = node.children.find((c) => c instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstTemplate && c.tagName === 'lu-option');
|
|
125
123
|
if (luOption === undefined) {
|
|
126
124
|
result = {
|
|
127
125
|
reason: RejectionReason.CUSTOM_PICKER_CONTENT
|
|
@@ -129,20 +127,20 @@ function getDataSource(select) {
|
|
|
129
127
|
}
|
|
130
128
|
else {
|
|
131
129
|
// TODO Handle advanced option picker
|
|
132
|
-
if (luOption instanceof
|
|
130
|
+
if (luOption instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstTemplate && node.name === 'lu-option-picker') {
|
|
133
131
|
let valueName = '';
|
|
134
132
|
let ngForOfName = '';
|
|
135
133
|
let ngForImplicitVarName = '';
|
|
136
134
|
// If that's a simple option picker, lu-option should have dataSource in its ngFor
|
|
137
135
|
luOption.templateAttrs.forEach((attr) => {
|
|
138
|
-
if (attr.name === 'ngForOf' && attr.value instanceof
|
|
136
|
+
if (attr.name === 'ngForOf' && attr.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource) {
|
|
139
137
|
ngForOfName = attr.value.source || '';
|
|
140
138
|
ngForImplicitVarName = luOption.variables.find((v) => v.value === '$implicit')?.name || '';
|
|
141
139
|
}
|
|
142
140
|
});
|
|
143
141
|
// Grab assigned value to make sure it's a supported one
|
|
144
142
|
luOption.inputs.forEach((attr) => {
|
|
145
|
-
if (attr.name === 'value' && attr.value instanceof
|
|
143
|
+
if (attr.name === 'value' && attr.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource) {
|
|
146
144
|
valueName = attr.value.source || '';
|
|
147
145
|
}
|
|
148
146
|
});
|
|
@@ -157,10 +155,10 @@ function getDataSource(select) {
|
|
|
157
155
|
// We have found value and it matches, now let's check how it's rendered
|
|
158
156
|
// Idk why but AST has two levels for a single node in this case
|
|
159
157
|
const contentHost = luOption.children[0];
|
|
160
|
-
if (contentHost instanceof
|
|
161
|
-
const templateNodes = contentHost.children.filter(c => c instanceof
|
|
158
|
+
if (contentHost instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstElement) {
|
|
159
|
+
const templateNodes = contentHost.children.filter(c => c instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstBoundText);
|
|
162
160
|
const firstValue = templateNodes[0];
|
|
163
|
-
if (firstValue instanceof
|
|
161
|
+
if (firstValue instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstBoundText && firstValue.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource) {
|
|
164
162
|
const firstTemplateSource = firstValue.value.source?.trim();
|
|
165
163
|
// First of all, check if it's a basic ?.name approach, in which case we can remove it
|
|
166
164
|
if ((templateNodes.length === 1 && firstTemplateSource === `{{ ${valueName} }}`) ||
|
|
@@ -190,7 +188,7 @@ function getDataSource(select) {
|
|
|
190
188
|
}
|
|
191
189
|
}
|
|
192
190
|
const comparerAST = node.inputs.find(attr => attr.name === 'option-comparer')?.value;
|
|
193
|
-
if (comparerAST instanceof
|
|
191
|
+
if (comparerAST instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource && comparerAST?.source && !isRejection(result)) {
|
|
194
192
|
result.comparer = comparerAST?.source;
|
|
195
193
|
}
|
|
196
194
|
}
|
|
@@ -199,23 +197,23 @@ function getDataSource(select) {
|
|
|
199
197
|
return result;
|
|
200
198
|
}
|
|
201
199
|
function getDisplayer(select) {
|
|
202
|
-
const displayerHostNode = select.node.children.find((node) => node instanceof
|
|
200
|
+
const displayerHostNode = select.node.children.find((node) => node instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstTemplate && node.templateAttrs.some((attr) => attr.name === 'luDisplayer'));
|
|
203
201
|
if (!displayerHostNode) {
|
|
204
202
|
return {
|
|
205
203
|
canBeRemoved: true
|
|
206
204
|
};
|
|
207
205
|
}
|
|
208
|
-
if (displayerHostNode instanceof
|
|
206
|
+
if (displayerHostNode instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstTemplate) {
|
|
209
207
|
const displayerVarName = displayerHostNode.variables.find((v) => v.value === '$implicit')?.name;
|
|
210
208
|
const templateNodes = [];
|
|
211
|
-
new
|
|
212
|
-
if (c instanceof
|
|
209
|
+
new lib_1.HtmlAstVisitor(displayerHostNode.children).visitNodes((c) => {
|
|
210
|
+
if (c instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstBoundText) {
|
|
213
211
|
templateNodes.push(c);
|
|
214
212
|
}
|
|
215
213
|
});
|
|
216
214
|
if (templateNodes?.length > 0) {
|
|
217
215
|
const firstValue = templateNodes[0];
|
|
218
|
-
if (firstValue instanceof
|
|
216
|
+
if (firstValue instanceof lib_1.currentSchematicContext.angularCompiler.TmplAstBoundText && firstValue.value instanceof lib_1.currentSchematicContext.angularCompiler.ASTWithSource) {
|
|
219
217
|
const firstTemplateSource = firstValue.value.source?.trim();
|
|
220
218
|
if ((templateNodes.length === 1 && firstTemplateSource === `{{ ${displayerVarName} }}`) ||
|
|
221
219
|
firstTemplateSource === `{{ ${displayerVarName}?.name }}` ||
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const typescript_1 = require("typescript");
|
|
4
|
-
const
|
|
5
|
-
const schematics_1 = require("../lib/schematics");
|
|
4
|
+
const lib_1 = require("../lib");
|
|
6
5
|
const migration_1 = require("./migration");
|
|
7
6
|
// Nx need to see "@angular-devkit/schematics" in order to run this migration correctly (see https://github.com/nrwl/nx/blob/d9fed4b832bf01d1b9a44ae9e486a5e5cd2d2253/packages/nx/src/command-line/migrate/migrate.ts#L1729-L1738)
|
|
8
7
|
require('@angular-devkit/schematics');
|
|
9
8
|
exports.default = (options) => {
|
|
10
9
|
return async (tree, context) => {
|
|
11
|
-
await
|
|
10
|
+
await lib_1.currentSchematicContext.init(context, options);
|
|
12
11
|
tree.visit((path, entry) => {
|
|
13
12
|
if (path.includes('node_modules') || !entry) {
|
|
14
13
|
return;
|
|
15
14
|
}
|
|
16
15
|
if (path.endsWith('.ts')) {
|
|
17
|
-
(0,
|
|
16
|
+
(0, lib_1.migrateFile)(path, entry, tree, (content) => {
|
|
18
17
|
const sourceFile = (0, typescript_1.createSourceFile)(path, content, typescript_1.ScriptTarget.ESNext);
|
|
19
18
|
return (0, migration_1.migrateComponent)(sourceFile, path, tree);
|
|
20
19
|
});
|