@design-factory/angular 21.1.0 → 22.0.0-next.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.
- package/.ai/docs/components/accordion/accessibility.md +45 -0
- package/.ai/docs/components/accordion/api.md +279 -0
- package/.ai/docs/components/accordion/developer.md +43 -0
- package/.ai/docs/components/accordion/guidelines.md +99 -0
- package/.ai/docs/components/accordion/overview.md +17 -0
- package/.ai/docs/components/alert/accessibility.md +24 -0
- package/.ai/docs/components/alert/api.md +65 -0
- package/.ai/docs/components/alert/developer.md +63 -0
- package/.ai/docs/components/alert/guidelines.md +62 -0
- package/.ai/docs/components/alert/overview.md +12 -0
- package/.ai/docs/components/button/accessibility.md +25 -0
- package/.ai/docs/components/button/api.md +71 -0
- package/.ai/docs/components/button/developer.md +52 -0
- package/.ai/docs/components/button/guidelines.md +75 -0
- package/.ai/docs/components/button/overview.md +15 -0
- package/.ai/docs/components/buttongroup/api.md +16 -0
- package/.ai/docs/components/buttongroup/developer.md +32 -0
- package/.ai/docs/components/drawer/accessibility.md +15 -0
- package/.ai/docs/components/drawer/api.md +56 -0
- package/.ai/docs/components/drawer/developer.md +36 -0
- package/.ai/docs/components/drawer/examples.md +9 -0
- package/.ai/docs/components/drawer/guidelines.md +58 -0
- package/.ai/docs/components/drawer/overview.md +19 -0
- package/.ai/docs/components/dropdown/accessibility.md +27 -0
- package/.ai/docs/components/dropdown/api.md +85 -0
- package/.ai/docs/components/dropdown/developer.md +59 -0
- package/.ai/docs/components/dropdown/guidelines.md +80 -0
- package/.ai/docs/components/dropdown/overview.md +16 -0
- package/.ai/docs/components/sidenav/accessibility.md +48 -0
- package/.ai/docs/components/sidenav/api.md +110 -0
- package/.ai/docs/components/sidenav/developer.md +14 -0
- package/.ai/docs/components/sidenav/guidelines.md +83 -0
- package/.ai/docs/components/sidenav/overview.md +16 -0
- package/.ai/docs/components/tooltip/accessibility.md +11 -0
- package/.ai/docs/components/tooltip/api.md +39 -0
- package/.ai/docs/components/tooltip/developer.md +16 -0
- package/.ai/docs/components/tooltip/guidelines.md +84 -0
- package/.ai/docs/components/tooltip/overview.md +23 -0
- package/.ai/docs/components/topnav/accessibility.md +51 -0
- package/.ai/docs/components/topnav/api.md +190 -0
- package/.ai/docs/components/topnav/developer.md +43 -0
- package/.ai/docs/components/topnav/guidelines.md +121 -0
- package/.ai/docs/components/topnav/overview.md +17 -0
- package/.ai/docs/demos/accordion/addons-subtitle/accordion-addons-subtitle.html +75 -0
- package/.ai/docs/demos/accordion/addons-subtitle/accordion-addons-subtitle.ts +27 -0
- package/.ai/docs/demos/accordion/basic/accordion-basic.html +16 -0
- package/.ai/docs/demos/accordion/basic/accordion-basic.ts +14 -0
- package/.ai/docs/demos/accordion/close-others/accordion-close-others.html +16 -0
- package/.ai/docs/demos/accordion/close-others/accordion-close-others.ts +14 -0
- package/.ai/docs/demos/accordion/interactive/accordion-interactive.html +84 -0
- package/.ai/docs/demos/accordion/interactive/accordion-interactive.ts +30 -0
- package/.ai/docs/demos/accordion/interactive-addons-subtitle/accordion-interactive-addons-subtitle.html +126 -0
- package/.ai/docs/demos/accordion/interactive-addons-subtitle/accordion-interactive-addons-subtitle.ts +33 -0
- package/.ai/docs/demos/accordion/programmatic-control/accordion-programmatic-control.html +36 -0
- package/.ai/docs/demos/accordion/programmatic-control/accordion-programmatic-control.ts +15 -0
- package/.ai/docs/demos/accordion/selectable/accordion-selectable.html +16 -0
- package/.ai/docs/demos/accordion/selectable/accordion-selectable.ts +14 -0
- package/.ai/docs/demos/accordion/selectable-extended/accordion-selectable-extended.html +28 -0
- package/.ai/docs/demos/accordion/selectable-extended/accordion-selectable-extended.ts +80 -0
- package/.ai/docs/demos/accordion/separator/accordion-separator.html +16 -0
- package/.ai/docs/demos/accordion/separator/accordion-separator.ts +14 -0
- package/.ai/docs/demos/alert/banner/alert-banner.html +15 -0
- package/.ai/docs/demos/alert/banner/alert-banner.ts +16 -0
- package/.ai/docs/demos/alert/basic/alert-basic.html +6 -0
- package/.ai/docs/demos/alert/basic/alert-basic.ts +9 -0
- package/.ai/docs/demos/alert/card/alert-card.html +15 -0
- package/.ai/docs/demos/alert/card/alert-card.ts +9 -0
- package/.ai/docs/demos/alert/dismissal/alert-dismissal.html +5 -0
- package/.ai/docs/demos/alert/dismissal/alert-dismissal.ts +27 -0
- package/.ai/docs/demos/alert/expandable/alert-expandable.html +9 -0
- package/.ai/docs/demos/alert/expandable/alert-expandable.ts +11 -0
- package/.ai/docs/demos/button/basic/button-basic.html +4 -0
- package/.ai/docs/demos/button/basic/button-basic.ts +9 -0
- package/.ai/docs/demos/button/disabled/button-disabled.html +18 -0
- package/.ai/docs/demos/button/disabled/button-disabled.ts +12 -0
- package/.ai/docs/demos/button/icons/button-icons.html +17 -0
- package/.ai/docs/demos/button/icons/button-icons.ts +10 -0
- package/.ai/docs/demos/button/surfaces/button-surfaces.html +13 -0
- package/.ai/docs/demos/button/surfaces/button-surfaces.ts +9 -0
- package/.ai/docs/demos/button/variants/button-variants.html +49 -0
- package/.ai/docs/demos/button/variants/button-variants.ts +9 -0
- package/.ai/docs/demos/buttongroup/basic/buttongroup-basic.html +6 -0
- package/.ai/docs/demos/buttongroup/basic/buttongroup-basic.ts +10 -0
- package/.ai/docs/demos/buttongroup/disabled/buttongroup-disabled.html +6 -0
- package/.ai/docs/demos/buttongroup/disabled/buttongroup-disabled.ts +10 -0
- package/.ai/docs/demos/buttongroup/mirror/buttongroup-mirror.html +8 -0
- package/.ai/docs/demos/buttongroup/mirror/buttongroup-mirror.ts +10 -0
- package/.ai/docs/demos/buttongroup/orientation/buttongroup-orientation.html +19 -0
- package/.ai/docs/demos/buttongroup/orientation/buttongroup-orientation.ts +10 -0
- package/.ai/docs/demos/buttongroup/sizing/buttongroup-sizing.html +19 -0
- package/.ai/docs/demos/buttongroup/sizing/buttongroup-sizing.ts +10 -0
- package/.ai/docs/demos/drawer/inline/drawer-inline-basic.html +46 -0
- package/.ai/docs/demos/drawer/inline/drawer-inline-basic.ts +33 -0
- package/.ai/docs/demos/drawer/overlay/drawer-overlay-basic.html +30 -0
- package/.ai/docs/demos/drawer/overlay/drawer-overlay-basic.ts +25 -0
- package/.ai/docs/demos/dropdown/basic/dropdown-basic.html +8 -0
- package/.ai/docs/demos/dropdown/basic/dropdown-basic.ts +15 -0
- package/.ai/docs/demos/dropdown/sizes/dropdown-sizes.html +9 -0
- package/.ai/docs/demos/dropdown/sizes/dropdown-sizes.ts +21 -0
- package/.ai/docs/demos/dropdown/split/dropdown-split.html +9 -0
- package/.ai/docs/demos/dropdown/split/dropdown-split.ts +11 -0
- package/.ai/docs/demos/dropdown/toggle/dropdown-toggle.html +22 -0
- package/.ai/docs/demos/dropdown/toggle/dropdown-toggle.ts +10 -0
- package/.ai/docs/demos/sidenav/sidenav-basic-no-icon/routes.ts +95 -0
- package/.ai/docs/demos/sidenav/sidenav-basic-no-icon/sidenav-basic-no-icon.html +42 -0
- package/.ai/docs/demos/sidenav/sidenav-basic-no-icon/sidenav-basic-no-icon.ts +12 -0
- package/.ai/docs/demos/sidenav/sidenav-basic-with-icon/routes.ts +41 -0
- package/.ai/docs/demos/sidenav/sidenav-basic-with-icon/sidenav-basic-with-icon.html +34 -0
- package/.ai/docs/demos/sidenav/sidenav-basic-with-icon/sidenav-basic-with-icon.ts +12 -0
- package/.ai/docs/demos/tooltip/basic/tooltip-basic.html +1 -0
- package/.ai/docs/demos/tooltip/basic/tooltip-basic.ts +10 -0
- package/.ai/docs/demos/tooltip/placements/tooltip-placements.html +35 -0
- package/.ai/docs/demos/tooltip/placements/tooltip-placements.ts +12 -0
- package/.ai/docs/demos/tooltip/sizes/tooltip-sizes.html +5 -0
- package/.ai/docs/demos/tooltip/sizes/tooltip-sizes.ts +10 -0
- package/.ai/docs/demos/topnav/brand/topnav-brand.ts +64 -0
- package/.ai/docs/demos/topnav/environment-banner/topnav-environment-banner.ts +20 -0
- package/.ai/docs/demos/topnav/navigation/routes.ts +35 -0
- package/.ai/docs/demos/topnav/navigation/topnav-navigation-flat.ts +67 -0
- package/.ai/docs/demos/topnav/navigation/topnav-navigation-tree.ts +82 -0
- package/.ai/docs/demos/topnav/quick-actions/notifications.ts +75 -0
- package/.ai/docs/demos/topnav/quick-actions/topnav-quick-actions.ts +108 -0
- package/.ai/docs/demos/topnav/quick-actions/user-account.ts +23 -0
- package/.ai/index.md +26 -0
- package/fesm2022/design-factory-angular-accordion.mjs +1153 -0
- package/fesm2022/design-factory-angular-accordion.mjs.map +1 -0
- package/fesm2022/design-factory-angular-alert.mjs +312 -0
- package/fesm2022/design-factory-angular-alert.mjs.map +1 -0
- package/fesm2022/design-factory-angular-breakpoints.mjs +53 -0
- package/fesm2022/design-factory-angular-breakpoints.mjs.map +1 -0
- package/fesm2022/design-factory-angular-button.mjs +240 -0
- package/fesm2022/design-factory-angular-button.mjs.map +1 -0
- package/fesm2022/design-factory-angular-buttongroup.mjs +75 -0
- package/fesm2022/design-factory-angular-buttongroup.mjs.map +1 -0
- package/fesm2022/design-factory-angular-drawer.mjs +64 -62
- package/fesm2022/design-factory-angular-drawer.mjs.map +1 -1
- package/fesm2022/design-factory-angular-dropdown.mjs +323 -0
- package/fesm2022/design-factory-angular-dropdown.mjs.map +1 -0
- package/fesm2022/design-factory-angular-form-field.mjs +287 -0
- package/fesm2022/design-factory-angular-form-field.mjs.map +1 -0
- package/fesm2022/design-factory-angular-icon.mjs +24 -0
- package/fesm2022/design-factory-angular-icon.mjs.map +1 -0
- package/fesm2022/design-factory-angular-input.mjs +34 -0
- package/fesm2022/design-factory-angular-input.mjs.map +1 -0
- package/fesm2022/design-factory-angular-internals.mjs +119 -39
- package/fesm2022/design-factory-angular-internals.mjs.map +1 -1
- package/fesm2022/design-factory-angular-separator.mjs +43 -0
- package/fesm2022/design-factory-angular-separator.mjs.map +1 -0
- package/fesm2022/design-factory-angular-sidenav.mjs +652 -401
- package/fesm2022/design-factory-angular-sidenav.mjs.map +1 -1
- package/fesm2022/design-factory-angular-slider.mjs +451 -0
- package/fesm2022/design-factory-angular-slider.mjs.map +1 -0
- package/fesm2022/design-factory-angular-theme.mjs +29 -19
- package/fesm2022/design-factory-angular-theme.mjs.map +1 -1
- package/fesm2022/design-factory-angular-toggle.mjs +172 -0
- package/fesm2022/design-factory-angular-toggle.mjs.map +1 -0
- package/fesm2022/design-factory-angular-tooltip.mjs +138 -0
- package/fesm2022/design-factory-angular-tooltip.mjs.map +1 -0
- package/fesm2022/design-factory-angular-topnav.mjs +589 -589
- package/fesm2022/design-factory-angular-topnav.mjs.map +1 -1
- package/package.json +61 -8
- package/schematics/collection.json +35 -0
- package/schematics/component-migration/accordion/constants.d.ts +10 -0
- package/schematics/component-migration/accordion/constants.js +46 -0
- package/schematics/component-migration/accordion/guide.md +257 -0
- package/schematics/component-migration/accordion/index.d.ts +2 -0
- package/schematics/component-migration/accordion/index.js +5 -0
- package/schematics/component-migration/accordion/migration.d.ts +2 -0
- package/schematics/component-migration/accordion/migration.js +13 -0
- package/schematics/component-migration/accordion/schema.json +25 -0
- package/schematics/component-migration/accordion/steps/accordion-imports.d.ts +3 -0
- package/schematics/component-migration/accordion/steps/accordion-imports.js +41 -0
- package/schematics/component-migration/accordion/steps/template-migration.d.ts +3 -0
- package/schematics/component-migration/accordion/steps/template-migration.js +554 -0
- package/schematics/component-migration/accordion/steps/title-content.d.ts +9 -0
- package/schematics/component-migration/accordion/steps/title-content.js +75 -0
- package/schematics/component-migration/ai/prompt.md +83 -0
- package/schematics/component-migration/alert/guide.md +246 -0
- package/schematics/component-migration/alert/index.d.ts +2 -0
- package/schematics/component-migration/alert/index.js +5 -0
- package/schematics/component-migration/alert/migration.d.ts +2 -0
- package/schematics/component-migration/alert/migration.js +50 -0
- package/schematics/component-migration/alert/schema.json +25 -0
- package/schematics/component-migration/alert/steps/alert-imports.d.ts +4 -0
- package/schematics/component-migration/alert/steps/alert-imports.js +97 -0
- package/schematics/component-migration/alert/steps/animation-input.d.ts +3 -0
- package/schematics/component-migration/alert/steps/animation-input.js +17 -0
- package/schematics/component-migration/alert/steps/close-output.d.ts +3 -0
- package/schematics/component-migration/alert/steps/close-output.js +17 -0
- package/schematics/component-migration/alert/steps/icon-directive-imports.d.ts +3 -0
- package/schematics/component-migration/alert/steps/icon-directive-imports.js +84 -0
- package/schematics/component-migration/alert/steps/icon-directive.d.ts +3 -0
- package/schematics/component-migration/alert/steps/icon-directive.js +10 -0
- package/schematics/component-migration/alert/steps/legacy-module-imports.d.ts +3 -0
- package/schematics/component-migration/alert/steps/legacy-module-imports.js +57 -0
- package/schematics/component-migration/alert/steps/programmatic-close.d.ts +3 -0
- package/schematics/component-migration/alert/steps/programmatic-close.js +44 -0
- package/schematics/component-migration/alert/steps/selector.d.ts +3 -0
- package/schematics/component-migration/alert/steps/selector.js +18 -0
- package/schematics/component-migration/alert/steps/static-classes.d.ts +3 -0
- package/schematics/component-migration/alert/steps/static-classes.js +97 -0
- package/schematics/component-migration/alert/steps/static-type.d.ts +3 -0
- package/schematics/component-migration/alert/steps/static-type.js +28 -0
- package/schematics/component-migration/alert/steps/template-reference.d.ts +3 -0
- package/schematics/component-migration/alert/steps/template-reference.js +15 -0
- package/schematics/component-migration/alert/steps/template-todos.d.ts +3 -0
- package/schematics/component-migration/alert/steps/template-todos.js +78 -0
- package/schematics/component-migration/button/guide.md +278 -0
- package/schematics/component-migration/button/index.d.ts +2 -0
- package/schematics/component-migration/button/index.js +5 -0
- package/schematics/component-migration/button/migration.d.ts +2 -0
- package/schematics/component-migration/button/migration.js +180 -0
- package/schematics/component-migration/button/schema.json +25 -0
- package/schematics/component-migration/button/steps/static-classes.d.ts +10 -0
- package/schematics/component-migration/button/steps/static-classes.js +128 -0
- package/schematics/component-migration/button/steps/template-todos.d.ts +19 -0
- package/schematics/component-migration/button/steps/template-todos.js +120 -0
- package/schematics/component-migration/button/types.d.ts +7 -0
- package/schematics/component-migration/button/types.js +2 -0
- package/schematics/component-migration/dropdown/guide.md +252 -0
- package/schematics/component-migration/dropdown/index.d.ts +2 -0
- package/schematics/component-migration/dropdown/index.js +5 -0
- package/schematics/component-migration/dropdown/migration.d.ts +2 -0
- package/schematics/component-migration/dropdown/migration.js +41 -0
- package/schematics/component-migration/dropdown/schema.json +25 -0
- package/schematics/component-migration/dropdown/steps/dropdown-imports.d.ts +3 -0
- package/schematics/component-migration/dropdown/steps/dropdown-imports.js +308 -0
- package/schematics/component-migration/dropdown/steps/template-attributes.d.ts +10 -0
- package/schematics/component-migration/dropdown/steps/template-attributes.js +57 -0
- package/schematics/component-migration/dropdown/steps/template-helpers.d.ts +20 -0
- package/schematics/component-migration/dropdown/steps/template-helpers.js +125 -0
- package/schematics/component-migration/dropdown/steps/template-imports.d.ts +22 -0
- package/schematics/component-migration/dropdown/steps/template-imports.js +12 -0
- package/schematics/component-migration/dropdown/steps/template-items.d.ts +7 -0
- package/schematics/component-migration/dropdown/steps/template-items.js +58 -0
- package/schematics/component-migration/dropdown/steps/template-menu.d.ts +14 -0
- package/schematics/component-migration/dropdown/steps/template-menu.js +107 -0
- package/schematics/component-migration/dropdown/steps/template-todos.d.ts +19 -0
- package/schematics/component-migration/dropdown/steps/template-todos.js +118 -0
- package/schematics/component-migration/dropdown/steps/template-toggle.d.ts +9 -0
- package/schematics/component-migration/dropdown/steps/template-toggle.js +70 -0
- package/schematics/component-migration/dropdown/steps/template-wrapper.d.ts +12 -0
- package/schematics/component-migration/dropdown/steps/template-wrapper.js +105 -0
- package/schematics/component-migration/index.d.ts +3 -0
- package/schematics/component-migration/index.js +26 -0
- package/schematics/component-migration/next-steps/index.d.ts +13 -0
- package/schematics/component-migration/next-steps/index.js +34 -0
- package/schematics/component-migration/registry.d.ts +1 -0
- package/schematics/component-migration/registry.js +15 -0
- package/schematics/component-migration/schema.json +20 -0
- package/schematics/component-migration/shared/ai-handoff.d.ts +2 -0
- package/schematics/component-migration/shared/ai-handoff.js +28 -0
- package/schematics/component-migration/shared/angular-component.d.ts +10 -0
- package/schematics/component-migration/shared/angular-component.js +125 -0
- package/schematics/component-migration/shared/button-visual-classes.d.ts +24 -0
- package/schematics/component-migration/shared/button-visual-classes.js +111 -0
- package/schematics/component-migration/shared/component-context.d.ts +7 -0
- package/schematics/component-migration/shared/component-context.js +24 -0
- package/schematics/component-migration/shared/component-imports.d.ts +45 -0
- package/schematics/component-migration/shared/component-imports.js +380 -0
- package/schematics/component-migration/shared/create-component-schematic.d.ts +3 -0
- package/schematics/component-migration/shared/create-component-schematic.js +55 -0
- package/schematics/component-migration/shared/import-edits.d.ts +11 -0
- package/schematics/component-migration/shared/import-edits.js +157 -0
- package/schematics/component-migration/shared/legacy-config-todos.d.ts +3 -0
- package/schematics/component-migration/shared/legacy-config-todos.js +90 -0
- package/schematics/component-migration/shared/migrate-project.d.ts +12 -0
- package/schematics/component-migration/shared/migrate-project.js +151 -0
- package/schematics/component-migration/shared/project-templates.d.ts +15 -0
- package/schematics/component-migration/shared/project-templates.js +43 -0
- package/schematics/component-migration/shared/scan-project.d.ts +3 -0
- package/schematics/component-migration/shared/scan-project.js +24 -0
- package/schematics/component-migration/shared/static-placement.d.ts +1 -0
- package/schematics/component-migration/shared/static-placement.js +45 -0
- package/schematics/component-migration/shared/template-edits.d.ts +28 -0
- package/schematics/component-migration/shared/template-edits.js +153 -0
- package/schematics/component-migration/shared/template-result.d.ts +3 -0
- package/schematics/component-migration/shared/template-result.js +11 -0
- package/schematics/component-migration/shared/testing.d.ts +13 -0
- package/schematics/component-migration/shared/testing.js +59 -0
- package/schematics/component-migration/shared/todo-comments.d.ts +10 -0
- package/schematics/component-migration/shared/todo-comments.js +81 -0
- package/schematics/component-migration/shared/types.d.ts +41 -0
- package/schematics/component-migration/shared/types.js +2 -0
- package/schematics/component-migration/tooltip/guide.md +196 -0
- package/schematics/component-migration/tooltip/index.d.ts +2 -0
- package/schematics/component-migration/tooltip/index.js +5 -0
- package/schematics/component-migration/tooltip/migration.d.ts +2 -0
- package/schematics/component-migration/tooltip/migration.js +50 -0
- package/schematics/component-migration/tooltip/schema.json +25 -0
- package/schematics/component-migration/tooltip/steps/template-attributes.d.ts +13 -0
- package/schematics/component-migration/tooltip/steps/template-attributes.js +266 -0
- package/schematics/component-migration/tooltip/steps/template-todos.d.ts +24 -0
- package/schematics/component-migration/tooltip/steps/template-todos.js +115 -0
- package/schematics/component-migration/tooltip/steps/tooltip-imports.d.ts +3 -0
- package/schematics/component-migration/tooltip/steps/tooltip-imports.js +79 -0
- package/schematics/component-migration/utils/component-resource-collector.d.ts +34 -0
- package/schematics/component-migration/utils/component-resource-collector.js +107 -0
- package/schematics/component-migration/utils/project_tsconfig_paths.d.ts +18 -0
- package/schematics/component-migration/utils/project_tsconfig_paths.js +105 -0
- package/schematics/component-migration/utils/typescript/compiler_host.d.ts +44 -0
- package/schematics/component-migration/utils/typescript/compiler_host.js +87 -0
- package/schematics/component-migration/utils/typescript/decorators.d.ts +22 -0
- package/schematics/component-migration/utils/typescript/decorators.js +41 -0
- package/schematics/component-migration/utils/typescript/functions.d.ts +14 -0
- package/schematics/component-migration/utils/typescript/functions.js +20 -0
- package/schematics/component-migration/utils/typescript/imports.d.ts +17 -0
- package/schematics/component-migration/utils/typescript/imports.js +110 -0
- package/schematics/component-migration/utils/typescript/parse_tsconfig.d.ts +9 -0
- package/schematics/component-migration/utils/typescript/parse_tsconfig.js +29 -0
- package/schematics/component-migration/utils/typescript/property-name.d.ts +13 -0
- package/schematics/component-migration/utils/typescript/property-name.js +22 -0
- package/schematics/package.json +3 -0
- package/types/design-factory-angular-accordion.d.ts +553 -0
- package/types/design-factory-angular-alert.d.ts +166 -0
- package/types/design-factory-angular-breakpoints.d.ts +13 -0
- package/types/design-factory-angular-button.d.ts +166 -0
- package/types/design-factory-angular-buttongroup.d.ts +45 -0
- package/types/design-factory-angular-drawer.d.ts +10 -16
- package/types/design-factory-angular-dropdown.d.ts +148 -0
- package/types/design-factory-angular-form-field.d.ts +122 -0
- package/types/design-factory-angular-icon.d.ts +11 -0
- package/types/design-factory-angular-input.d.ts +16 -0
- package/types/design-factory-angular-internals.d.ts +78 -19
- package/types/design-factory-angular-separator.d.ts +29 -0
- package/types/design-factory-angular-sidenav.d.ts +98 -14
- package/types/design-factory-angular-slider.d.ts +239 -0
- package/types/design-factory-angular-toggle.d.ts +93 -0
- package/types/design-factory-angular-tooltip.d.ts +113 -0
- package/types/design-factory-angular-topnav.d.ts +35 -47
- package/drawer/README.md +0 -54
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getComponentNamedImports = getComponentNamedImports;
|
|
4
|
+
exports.editComponentScopeImports = editComponentScopeImports;
|
|
5
|
+
exports.editStandaloneComponentImports = editStandaloneComponentImports;
|
|
6
|
+
exports.hasIdentifierReferenceOutsideImports = hasIdentifierReferenceOutsideImports;
|
|
7
|
+
exports.editRemovableLegacyImports = editRemovableLegacyImports;
|
|
8
|
+
exports.editLegacyImportTodos = editLegacyImportTodos;
|
|
9
|
+
const tslib_1 = require("tslib");
|
|
10
|
+
const ts = tslib_1.__importStar(require("typescript"));
|
|
11
|
+
const angular_component_1 = require("./angular-component");
|
|
12
|
+
const component_context_1 = require("./component-context");
|
|
13
|
+
const import_edits_1 = require("./import-edits");
|
|
14
|
+
const todo_comments_1 = require("./todo-comments");
|
|
15
|
+
function toSet(values) {
|
|
16
|
+
return new Set(values ?? []);
|
|
17
|
+
}
|
|
18
|
+
function getNamedBindings(statement) {
|
|
19
|
+
const namedBindings = statement.importClause?.namedBindings;
|
|
20
|
+
return namedBindings && ts.isNamedImports(namedBindings) ? namedBindings : null;
|
|
21
|
+
}
|
|
22
|
+
function getComponentNamedImports(sourceFile, moduleNames, importedNames) {
|
|
23
|
+
const modules = toSet(moduleNames);
|
|
24
|
+
const names = importedNames ? toSet(importedNames) : null;
|
|
25
|
+
const imports = [];
|
|
26
|
+
for (const statement of sourceFile.statements) {
|
|
27
|
+
if (!ts.isImportDeclaration(statement) ||
|
|
28
|
+
!ts.isStringLiteral(statement.moduleSpecifier) ||
|
|
29
|
+
!modules.has(statement.moduleSpecifier.text)) {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
for (const element of getNamedBindings(statement)?.elements ?? []) {
|
|
33
|
+
const importedName = element.propertyName?.text ?? element.name.text;
|
|
34
|
+
if (!names || names.has(importedName)) {
|
|
35
|
+
imports.push({
|
|
36
|
+
importedName,
|
|
37
|
+
localName: element.name.text,
|
|
38
|
+
moduleName: statement.moduleSpecifier.text
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return imports;
|
|
44
|
+
}
|
|
45
|
+
function findComponentImportsProperty(sourceFile, component) {
|
|
46
|
+
const metadata = (0, angular_component_1.findComponentMetadata)(component);
|
|
47
|
+
if (!metadata) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
for (const property of metadata.properties) {
|
|
51
|
+
if (ts.isPropertyAssignment(property) && property.name.getText(sourceFile) === 'imports') {
|
|
52
|
+
return property;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
function componentHasImportsProperty(sourceFile, component) {
|
|
58
|
+
return !!findComponentImportsProperty(sourceFile, component);
|
|
59
|
+
}
|
|
60
|
+
function editNewComponentImportsProperty(component, _sourceFile, symbolName) {
|
|
61
|
+
const metadata = (0, angular_component_1.findComponentMetadata)(component);
|
|
62
|
+
const lastProperty = metadata?.properties[metadata.properties.length - 1];
|
|
63
|
+
if (!lastProperty) {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
return [{ start: lastProperty.getEnd(), end: lastProperty.getEnd(), text: `,\n imports: [${symbolName}]` }];
|
|
67
|
+
}
|
|
68
|
+
function editNewNgModuleImportsProperty(moduleClass, _sourceFile, symbolName) {
|
|
69
|
+
const metadata = (0, angular_component_1.findNgModuleMetadata)(moduleClass);
|
|
70
|
+
const lastProperty = metadata?.properties[metadata.properties.length - 1];
|
|
71
|
+
if (!lastProperty) {
|
|
72
|
+
return [];
|
|
73
|
+
}
|
|
74
|
+
return [{ start: lastProperty.getEnd(), end: lastProperty.getEnd(), text: `,\n imports: [${symbolName}]` }];
|
|
75
|
+
}
|
|
76
|
+
function isDeclaredInSourceNgModule(context, component) {
|
|
77
|
+
return (0, angular_component_1.getNgModuleClasses)(context.sourceFile).some((moduleClass) => {
|
|
78
|
+
const declarations = (0, angular_component_1.findNgModuleDeclarationsArray)(moduleClass);
|
|
79
|
+
return declarations?.elements.some((element) => (0, angular_component_1.resolveClassDeclaration)(context.typeChecker, element) === component);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
function getDuplicateIdentifierElements(importsArray) {
|
|
83
|
+
const seenIdentifiers = new Set();
|
|
84
|
+
const duplicateElements = [];
|
|
85
|
+
for (const element of importsArray.elements) {
|
|
86
|
+
if (!ts.isIdentifier(element)) {
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
if (seenIdentifiers.has(element.text)) {
|
|
90
|
+
duplicateElements.push(element);
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
seenIdentifiers.add(element.text);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return duplicateElements;
|
|
97
|
+
}
|
|
98
|
+
function renderArrayElements(sourceFile, importsArray, elements) {
|
|
99
|
+
const content = sourceFile.text.slice(importsArray.getStart(sourceFile) + 1, importsArray.getEnd() - 1);
|
|
100
|
+
if (!content.includes('\n')) {
|
|
101
|
+
return elements.join(', ');
|
|
102
|
+
}
|
|
103
|
+
const elementIndent = content.match(/\n(\s*)\S/)?.[1] ?? ' ';
|
|
104
|
+
const closingIndent = content.match(/\n(\s*)$/)?.[1] ?? '';
|
|
105
|
+
return elements.length > 0 ? `\n${elementIndent}${elements.join(`,\n${elementIndent}`)}\n${closingIndent}` : '';
|
|
106
|
+
}
|
|
107
|
+
function editArrayIdentifierImportsWithCleanup(sourceFile, importsArray, symbolNames, removableElements) {
|
|
108
|
+
if (removableElements.length === 0) {
|
|
109
|
+
return (0, import_edits_1.editArrayIdentifierImports)(sourceFile, importsArray, symbolNames);
|
|
110
|
+
}
|
|
111
|
+
const removableIndexes = new Set(removableElements.map((element) => importsArray.elements.indexOf(element)));
|
|
112
|
+
const existingElements = importsArray.elements
|
|
113
|
+
.filter((_element, index) => !removableIndexes.has(index))
|
|
114
|
+
.map((element) => element.getText(sourceFile));
|
|
115
|
+
const existingIdentifiers = new Set(importsArray.elements.flatMap((element, index) => !removableIndexes.has(index) && ts.isIdentifier(element) ? [element.text] : []));
|
|
116
|
+
const missingSymbols = symbolNames.filter((symbolName) => !existingIdentifiers.has(symbolName));
|
|
117
|
+
return [
|
|
118
|
+
{
|
|
119
|
+
start: importsArray.getStart(sourceFile) + 1,
|
|
120
|
+
end: importsArray.getEnd() - 1,
|
|
121
|
+
text: renderArrayElements(sourceFile, importsArray, [...existingElements, ...missingSymbols])
|
|
122
|
+
}
|
|
123
|
+
];
|
|
124
|
+
}
|
|
125
|
+
function uniqueElements(elements) {
|
|
126
|
+
return elements.filter((element, index) => elements.indexOf(element) === index);
|
|
127
|
+
}
|
|
128
|
+
function getLegacyScopeElements(importsArray, legacyImports, importedNames) {
|
|
129
|
+
const legacyLocalNames = new Set(legacyImports
|
|
130
|
+
.filter((legacyImport) => importedNames.has(legacyImport.importedName))
|
|
131
|
+
.map(({ localName }) => localName));
|
|
132
|
+
return importsArray.elements.filter((element) => ts.isIdentifier(element) && legacyLocalNames.has(element.text));
|
|
133
|
+
}
|
|
134
|
+
function editScopeImportsArray(sourceFile, importsArray, options, needsNewImport, keepsLegacyScope, newImports) {
|
|
135
|
+
const legacyScopeImportedNames = toSet(options.legacyScopeImportedNames);
|
|
136
|
+
const cleanupScopeImportedNames = toSet(options.cleanupScopeImportedNames);
|
|
137
|
+
const identifiers = importsArray.elements.filter(ts.isIdentifier);
|
|
138
|
+
const hasNewSymbol = identifiers.some((element) => element.text === options.newImport.symbolName);
|
|
139
|
+
const legacyElements = keepsLegacyScope
|
|
140
|
+
? []
|
|
141
|
+
: getLegacyScopeElements(importsArray, options.legacyImports, legacyScopeImportedNames);
|
|
142
|
+
const cleanupElements = getLegacyScopeElements(importsArray, options.legacyImports, cleanupScopeImportedNames);
|
|
143
|
+
const duplicateElements = getDuplicateIdentifierElements(importsArray);
|
|
144
|
+
const removableElements = uniqueElements([...legacyElements, ...cleanupElements, ...duplicateElements]);
|
|
145
|
+
if (!needsNewImport) {
|
|
146
|
+
return (0, import_edits_1.editListElements)(importsArray, removableElements, sourceFile);
|
|
147
|
+
}
|
|
148
|
+
if (hasNewSymbol) {
|
|
149
|
+
return (0, import_edits_1.editListElements)(importsArray, removableElements, sourceFile);
|
|
150
|
+
}
|
|
151
|
+
const replaceableElement = legacyElements[0];
|
|
152
|
+
if (replaceableElement) {
|
|
153
|
+
const legacyImport = options.legacyImports.find((candidate) => candidate.localName === replaceableElement.text);
|
|
154
|
+
const replacement = legacyImport
|
|
155
|
+
? (options.getReplacement?.(legacyImport) ?? {
|
|
156
|
+
scopeName: options.newImport.symbolName,
|
|
157
|
+
importName: options.newImport.symbolName
|
|
158
|
+
})
|
|
159
|
+
: { scopeName: options.newImport.symbolName, importName: options.newImport.symbolName };
|
|
160
|
+
const [first, ...rest] = removableElements;
|
|
161
|
+
newImports.add(replacement.importName);
|
|
162
|
+
return [
|
|
163
|
+
{ start: first.getStart(sourceFile), end: first.getEnd(), text: replacement.scopeName },
|
|
164
|
+
...(0, import_edits_1.editListElements)(importsArray, rest, sourceFile)
|
|
165
|
+
];
|
|
166
|
+
}
|
|
167
|
+
newImports.add(options.newImport.symbolName);
|
|
168
|
+
return [
|
|
169
|
+
...(0, import_edits_1.editListElements)(importsArray, removableElements, sourceFile),
|
|
170
|
+
...(0, import_edits_1.editArrayIdentifierImports)(sourceFile, importsArray, [options.newImport.symbolName])
|
|
171
|
+
];
|
|
172
|
+
}
|
|
173
|
+
function editComponentScopeImports(options) {
|
|
174
|
+
const { context } = options;
|
|
175
|
+
const edits = [];
|
|
176
|
+
const newImports = new Set();
|
|
177
|
+
for (const [component, templates] of context.templatesByComponent) {
|
|
178
|
+
const needsNewImport = options.componentNeedsNewImport(templates);
|
|
179
|
+
const keepsLegacyScope = options.componentKeepsLegacyScope?.(templates) ?? false;
|
|
180
|
+
if ((!needsNewImport && !options.cleanupScopeImportedNames) || (0, angular_component_1.isExplicitlyNonStandaloneComponent)(component)) {
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
const importsArray = (0, angular_component_1.findComponentImportsArray)(component);
|
|
184
|
+
if (importsArray) {
|
|
185
|
+
edits.push(...editScopeImportsArray(context.sourceFile, importsArray, options, needsNewImport, keepsLegacyScope, newImports));
|
|
186
|
+
}
|
|
187
|
+
else if (needsNewImport &&
|
|
188
|
+
!componentHasImportsProperty(context.sourceFile, component) &&
|
|
189
|
+
!isDeclaredInSourceNgModule(context, component)) {
|
|
190
|
+
edits.push(...editNewComponentImportsProperty(component, context.sourceFile, options.newImport.symbolName));
|
|
191
|
+
newImports.add(options.newImport.symbolName);
|
|
192
|
+
}
|
|
193
|
+
else if (needsNewImport && options.indirectComponentImportsTodo) {
|
|
194
|
+
const importsProperty = findComponentImportsProperty(context.sourceFile, component);
|
|
195
|
+
if (importsProperty && !ts.isArrayLiteralExpression(importsProperty.initializer)) {
|
|
196
|
+
const edit = (0, todo_comments_1.editSourceTodo)(context.sourceFile, importsProperty, options.indirectComponentImportsTodo);
|
|
197
|
+
if (edit) {
|
|
198
|
+
edits.push(edit);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
for (const moduleClass of (0, angular_component_1.getNgModuleClasses)(context.sourceFile)) {
|
|
204
|
+
const needsNewImport = (0, component_context_1.moduleDeclaresComponentTemplate)(context, moduleClass, options.componentNeedsNewImport);
|
|
205
|
+
const keepsLegacyScope = options.componentKeepsLegacyScope
|
|
206
|
+
? (0, component_context_1.moduleDeclaresComponentTemplate)(context, moduleClass, options.componentKeepsLegacyScope)
|
|
207
|
+
: false;
|
|
208
|
+
if (!needsNewImport && !options.cleanupScopeImportedNames) {
|
|
209
|
+
continue;
|
|
210
|
+
}
|
|
211
|
+
const importsArray = (0, angular_component_1.findNgModuleImportsArray)(moduleClass);
|
|
212
|
+
if (importsArray) {
|
|
213
|
+
edits.push(...editScopeImportsArray(context.sourceFile, importsArray, options, needsNewImport, keepsLegacyScope, newImports));
|
|
214
|
+
}
|
|
215
|
+
else if (needsNewImport) {
|
|
216
|
+
edits.push(...editNewNgModuleImportsProperty(moduleClass, context.sourceFile, options.newImport.symbolName));
|
|
217
|
+
newImports.add(options.newImport.symbolName);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (newImports.size > 0 && options.addTopLevelImport !== false) {
|
|
221
|
+
edits.push(...(0, import_edits_1.addNamedImports)(context.sourceFile, options.newImport.moduleName, [...newImports]));
|
|
222
|
+
}
|
|
223
|
+
return { edits, newImports };
|
|
224
|
+
}
|
|
225
|
+
function getSortedSymbolNames(requirements) {
|
|
226
|
+
return [...new Set(requirements.map((requirement) => requirement.symbolName))].sort();
|
|
227
|
+
}
|
|
228
|
+
function editComponentStandaloneImports(context, component, symbolNames, templates, options) {
|
|
229
|
+
if ((0, angular_component_1.isExplicitlyNonStandaloneComponent)(component)) {
|
|
230
|
+
return { edits: [], addsScopeImport: false };
|
|
231
|
+
}
|
|
232
|
+
const importsArray = (0, angular_component_1.findComponentImportsArray)(component);
|
|
233
|
+
if (importsArray) {
|
|
234
|
+
const keepsLegacyScope = options.componentKeepsLegacyScope?.(templates) ?? false;
|
|
235
|
+
const removableElements = keepsLegacyScope
|
|
236
|
+
? []
|
|
237
|
+
: getLegacyScopeElements(importsArray, options.legacyImports ?? [], toSet(options.legacyScopeImportedNames));
|
|
238
|
+
return {
|
|
239
|
+
edits: editArrayIdentifierImportsWithCleanup(context.sourceFile, importsArray, symbolNames, removableElements),
|
|
240
|
+
addsScopeImport: true
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
if (componentHasImportsProperty(context.sourceFile, component)) {
|
|
244
|
+
const indirectComponentImportsTodo = options.indirectComponentImportsTodo;
|
|
245
|
+
if (!indirectComponentImportsTodo) {
|
|
246
|
+
return { edits: [], addsScopeImport: false };
|
|
247
|
+
}
|
|
248
|
+
const importsProperty = findComponentImportsProperty(context.sourceFile, component);
|
|
249
|
+
const edit = importsProperty && !ts.isArrayLiteralExpression(importsProperty.initializer)
|
|
250
|
+
? (0, todo_comments_1.editSourceTodo)(context.sourceFile, importsProperty, indirectComponentImportsTodo)
|
|
251
|
+
: null;
|
|
252
|
+
return { edits: edit ? [edit] : [], addsScopeImport: false };
|
|
253
|
+
}
|
|
254
|
+
if (isDeclaredInSourceNgModule(context, component)) {
|
|
255
|
+
return { edits: [], addsScopeImport: false };
|
|
256
|
+
}
|
|
257
|
+
return {
|
|
258
|
+
edits: editNewComponentImportsProperty(component, context.sourceFile, symbolNames.join(', ')),
|
|
259
|
+
addsScopeImport: true
|
|
260
|
+
};
|
|
261
|
+
}
|
|
262
|
+
function editNgModuleStandaloneImports(context, moduleClass, symbolNames, options) {
|
|
263
|
+
const importsArray = (0, angular_component_1.findNgModuleImportsArray)(moduleClass);
|
|
264
|
+
if (importsArray) {
|
|
265
|
+
const keepsLegacyScope = options.componentKeepsLegacyScope
|
|
266
|
+
? (0, component_context_1.moduleDeclaresComponentTemplate)(context, moduleClass, options.componentKeepsLegacyScope)
|
|
267
|
+
: false;
|
|
268
|
+
const removableElements = keepsLegacyScope
|
|
269
|
+
? []
|
|
270
|
+
: getLegacyScopeElements(importsArray, options.legacyImports ?? [], toSet(options.legacyScopeImportedNames));
|
|
271
|
+
return {
|
|
272
|
+
edits: editArrayIdentifierImportsWithCleanup(context.sourceFile, importsArray, symbolNames, removableElements),
|
|
273
|
+
addsScopeImport: true
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
return {
|
|
277
|
+
edits: editNewNgModuleImportsProperty(moduleClass, context.sourceFile, symbolNames.join(', ')),
|
|
278
|
+
addsScopeImport: true
|
|
279
|
+
};
|
|
280
|
+
}
|
|
281
|
+
function editStandaloneComponentImports(context, moduleName, optionsOrTodo) {
|
|
282
|
+
const edits = [];
|
|
283
|
+
const fileRequirements = [];
|
|
284
|
+
const options = optionsOrTodo && 'code' in optionsOrTodo ? { indirectComponentImportsTodo: optionsOrTodo } : (optionsOrTodo ?? {});
|
|
285
|
+
for (const [component, requirements] of context.standaloneImportsByComponent) {
|
|
286
|
+
const moduleRequirements = requirements.filter((requirement) => requirement.moduleName === moduleName);
|
|
287
|
+
if (moduleRequirements.length === 0) {
|
|
288
|
+
continue;
|
|
289
|
+
}
|
|
290
|
+
const componentImportEdits = editComponentStandaloneImports(context, component, getSortedSymbolNames(moduleRequirements), context.templatesByComponent.get(component) ?? [], options);
|
|
291
|
+
if (componentImportEdits.edits.length > 0) {
|
|
292
|
+
if (componentImportEdits.addsScopeImport) {
|
|
293
|
+
fileRequirements.push(...moduleRequirements);
|
|
294
|
+
}
|
|
295
|
+
edits.push(...componentImportEdits.edits);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
for (const moduleClass of (0, angular_component_1.getNgModuleClasses)(context.sourceFile)) {
|
|
299
|
+
const declarationsArray = (0, angular_component_1.findNgModuleDeclarationsArray)(moduleClass);
|
|
300
|
+
if (!declarationsArray) {
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
const moduleRequirements = declarationsArray.elements
|
|
304
|
+
.flatMap((element) => {
|
|
305
|
+
const component = (0, angular_component_1.resolveClassDeclaration)(context.typeChecker, element);
|
|
306
|
+
return component ? (context.projectStandaloneImportsByComponent.get(component) ?? []) : [];
|
|
307
|
+
})
|
|
308
|
+
.filter((requirement) => requirement.moduleName === moduleName);
|
|
309
|
+
if (moduleRequirements.length === 0) {
|
|
310
|
+
continue;
|
|
311
|
+
}
|
|
312
|
+
const moduleImportEdits = editNgModuleStandaloneImports(context, moduleClass, getSortedSymbolNames(moduleRequirements), options);
|
|
313
|
+
if (moduleImportEdits.edits.length > 0) {
|
|
314
|
+
if (moduleImportEdits.addsScopeImport) {
|
|
315
|
+
fileRequirements.push(...moduleRequirements);
|
|
316
|
+
}
|
|
317
|
+
edits.push(...moduleImportEdits.edits);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (fileRequirements.length > 0) {
|
|
321
|
+
edits.push(...(0, import_edits_1.addNamedImports)(context.sourceFile, moduleName, getSortedSymbolNames(fileRequirements)));
|
|
322
|
+
}
|
|
323
|
+
return edits;
|
|
324
|
+
}
|
|
325
|
+
function getSkippedRanges(sourceFile) {
|
|
326
|
+
const importDeclarationRanges = sourceFile.statements.flatMap((statement) => ts.isImportDeclaration(statement) ? [{ start: statement.getFullStart(), end: statement.getEnd() }] : []);
|
|
327
|
+
const decoratorImportsArrayRanges = (0, angular_component_1.findDecoratorImportsArrays)(sourceFile).map((importsArray) => ({
|
|
328
|
+
start: importsArray.getStart(sourceFile),
|
|
329
|
+
end: importsArray.getEnd()
|
|
330
|
+
}));
|
|
331
|
+
return [...importDeclarationRanges, ...decoratorImportsArrayRanges];
|
|
332
|
+
}
|
|
333
|
+
function hasIdentifierReferenceOutsideImports(sourceFile, symbolName) {
|
|
334
|
+
const skippedRanges = getSkippedRanges(sourceFile);
|
|
335
|
+
const scanner = ts.createScanner(ts.ScriptTarget.Latest, false, ts.LanguageVariant.Standard, sourceFile.text);
|
|
336
|
+
let token = scanner.scan();
|
|
337
|
+
while (token !== ts.SyntaxKind.EndOfFileToken) {
|
|
338
|
+
const start = scanner.getTokenStart();
|
|
339
|
+
const end = scanner.getTokenEnd();
|
|
340
|
+
if (token === ts.SyntaxKind.Identifier &&
|
|
341
|
+
scanner.getTokenText() === symbolName &&
|
|
342
|
+
!skippedRanges.some((range) => start >= range.start && end <= range.end)) {
|
|
343
|
+
return true;
|
|
344
|
+
}
|
|
345
|
+
token = scanner.scan();
|
|
346
|
+
}
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
349
|
+
function editRemovableLegacyImports(sourceFile, moduleNames, legacyImports, shouldRemove) {
|
|
350
|
+
const removableImports = legacyImports
|
|
351
|
+
.filter((legacyImport) => shouldRemove(legacyImport))
|
|
352
|
+
.filter((legacyImport) => !hasIdentifierReferenceOutsideImports(sourceFile, legacyImport.localName))
|
|
353
|
+
.map((legacyImport) => legacyImport.importedName);
|
|
354
|
+
return (0, import_edits_1.removeNamedImports)(sourceFile, moduleNames, removableImports);
|
|
355
|
+
}
|
|
356
|
+
function editLegacyImportTodos(sourceFile, moduleNames, shouldAddTodo, todo) {
|
|
357
|
+
const modules = toSet(moduleNames);
|
|
358
|
+
const edits = [];
|
|
359
|
+
for (const statement of sourceFile.statements) {
|
|
360
|
+
if (!ts.isImportDeclaration(statement) ||
|
|
361
|
+
!ts.isStringLiteral(statement.moduleSpecifier) ||
|
|
362
|
+
!modules.has(statement.moduleSpecifier.text)) {
|
|
363
|
+
continue;
|
|
364
|
+
}
|
|
365
|
+
const moduleName = statement.moduleSpecifier.text;
|
|
366
|
+
const imports = getNamedBindings(statement)?.elements.map((element) => ({
|
|
367
|
+
importedName: element.propertyName?.text ?? element.name.text,
|
|
368
|
+
localName: element.name.text,
|
|
369
|
+
moduleName
|
|
370
|
+
}));
|
|
371
|
+
if (!imports?.some(shouldAddTodo)) {
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
const edit = (0, todo_comments_1.editSourceTodo)(sourceFile, statement, todo);
|
|
375
|
+
if (edit) {
|
|
376
|
+
edits.push(edit);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
return edits;
|
|
380
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Rule } from '@angular-devkit/schematics';
|
|
2
|
+
import { ComponentMigrationDefinition, ComponentMigrationSchema } from './types';
|
|
3
|
+
export declare function createComponentMigrationSchematic(migration: ComponentMigrationDefinition): (options: ComponentMigrationSchema) => Rule;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createComponentMigrationSchematic = createComponentMigrationSchematic;
|
|
4
|
+
const project_tsconfig_paths_1 = require("../utils/project_tsconfig_paths");
|
|
5
|
+
const ai_handoff_1 = require("./ai-handoff");
|
|
6
|
+
const migrate_project_1 = require("./migrate-project");
|
|
7
|
+
const next_steps_1 = require("../next-steps");
|
|
8
|
+
const scan_project_1 = require("./scan-project");
|
|
9
|
+
function emptyMigrationResult() {
|
|
10
|
+
return {
|
|
11
|
+
analyzedSourceFiles: 0,
|
|
12
|
+
analyzedComponents: 0,
|
|
13
|
+
analyzedTemplates: 0,
|
|
14
|
+
changedTemplates: 0,
|
|
15
|
+
changes: 0,
|
|
16
|
+
changedFiles: []
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function mergeMigrationResults(target, source) {
|
|
20
|
+
target.analyzedSourceFiles += source.analyzedSourceFiles;
|
|
21
|
+
target.analyzedComponents += source.analyzedComponents;
|
|
22
|
+
target.analyzedTemplates += source.analyzedTemplates;
|
|
23
|
+
target.changedTemplates += source.changedTemplates;
|
|
24
|
+
target.changes += source.changes;
|
|
25
|
+
target.changedFiles.push(...source.changedFiles);
|
|
26
|
+
}
|
|
27
|
+
function createComponentMigrationSchematic(migration) {
|
|
28
|
+
return (options) => async (tree, context) => {
|
|
29
|
+
const projectNames = await (0, project_tsconfig_paths_1.resolveProjectNames)(tree, options.project, options.all);
|
|
30
|
+
const runContext = (0, migrate_project_1.createComponentMigrationRunContext)();
|
|
31
|
+
if (options.scan) {
|
|
32
|
+
const usageCounts = new Map([[migration.id, 0]]);
|
|
33
|
+
for (const projectName of projectNames) {
|
|
34
|
+
const [result] = await (0, scan_project_1.scanProjectForComponentMigrations)(tree, projectName, [migration], runContext);
|
|
35
|
+
usageCounts.set(migration.id, (usageCounts.get(migration.id) ?? 0) + result.legacyUsages);
|
|
36
|
+
}
|
|
37
|
+
const result = { migration, legacyUsages: usageCounts.get(migration.id) ?? 0 };
|
|
38
|
+
context.logger.info(`${result.migration.id}: ${result.legacyUsages} usages`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const migrationResult = emptyMigrationResult();
|
|
42
|
+
for (const projectName of projectNames) {
|
|
43
|
+
mergeMigrationResults(migrationResult, await (0, migrate_project_1.migrateProjectComponentTemplates)(tree, projectName, migration, runContext));
|
|
44
|
+
}
|
|
45
|
+
(0, ai_handoff_1.writeAiMigrationHandoff)(tree, migration.id);
|
|
46
|
+
(0, next_steps_1.scheduleComponentMigrationNextSteps)(context, {
|
|
47
|
+
componentId: migration.id,
|
|
48
|
+
analyzedSourceFiles: migrationResult.analyzedSourceFiles,
|
|
49
|
+
analyzedComponents: migrationResult.analyzedComponents,
|
|
50
|
+
analyzedTemplates: migrationResult.analyzedTemplates,
|
|
51
|
+
changedTemplates: migrationResult.changedTemplates,
|
|
52
|
+
changes: migrationResult.changes
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
import { TemplateEdit } from './template-edits';
|
|
3
|
+
type NodeList<T extends ts.Node> = {
|
|
4
|
+
elements: ts.NodeArray<T>;
|
|
5
|
+
};
|
|
6
|
+
export declare function editListElements<T extends ts.Node>(list: NodeList<T>, elementsToRemove: T[], sourceFile: ts.SourceFile): TemplateEdit[];
|
|
7
|
+
export declare function editListElement<T extends ts.Node>(list: NodeList<T>, element: T, sourceFile: ts.SourceFile): TemplateEdit;
|
|
8
|
+
export declare function editArrayIdentifierImports(sourceFile: ts.SourceFile, importsArray: ts.ArrayLiteralExpression, symbolNames: string[]): TemplateEdit[];
|
|
9
|
+
export declare function addNamedImports(sourceFile: ts.SourceFile, moduleName: string, importNames: string[]): TemplateEdit[];
|
|
10
|
+
export declare function removeNamedImports(sourceFile: ts.SourceFile, moduleNames: string | Iterable<string>, importedNames: Iterable<string>): TemplateEdit[];
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.editListElements = editListElements;
|
|
4
|
+
exports.editListElement = editListElement;
|
|
5
|
+
exports.editArrayIdentifierImports = editArrayIdentifierImports;
|
|
6
|
+
exports.addNamedImports = addNamedImports;
|
|
7
|
+
exports.removeNamedImports = removeNamedImports;
|
|
8
|
+
const tslib_1 = require("tslib");
|
|
9
|
+
const ts = tslib_1.__importStar(require("typescript"));
|
|
10
|
+
function toModuleNames(moduleNames) {
|
|
11
|
+
return typeof moduleNames === 'string' ? new Set([moduleNames]) : new Set(moduleNames);
|
|
12
|
+
}
|
|
13
|
+
function editListElements(list, elementsToRemove, sourceFile) {
|
|
14
|
+
if (elementsToRemove.length === 0) {
|
|
15
|
+
return [];
|
|
16
|
+
}
|
|
17
|
+
const removeIndexes = new Set(elementsToRemove.map((element) => list.elements.indexOf(element)));
|
|
18
|
+
const edits = [];
|
|
19
|
+
let index = 0;
|
|
20
|
+
while (index < list.elements.length) {
|
|
21
|
+
if (!removeIndexes.has(index)) {
|
|
22
|
+
index++;
|
|
23
|
+
continue;
|
|
24
|
+
}
|
|
25
|
+
const firstIndex = index;
|
|
26
|
+
while (index + 1 < list.elements.length && removeIndexes.has(index + 1)) {
|
|
27
|
+
index++;
|
|
28
|
+
}
|
|
29
|
+
const lastIndex = index;
|
|
30
|
+
const previous = list.elements[firstIndex - 1];
|
|
31
|
+
const next = list.elements[lastIndex + 1];
|
|
32
|
+
if (next) {
|
|
33
|
+
edits.push({
|
|
34
|
+
start: list.elements[firstIndex].getStart(sourceFile),
|
|
35
|
+
end: next.getStart(sourceFile),
|
|
36
|
+
text: ''
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else if (previous) {
|
|
40
|
+
edits.push({
|
|
41
|
+
start: previous.getEnd(),
|
|
42
|
+
end: list.elements[lastIndex].getEnd(),
|
|
43
|
+
text: ''
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
edits.push({
|
|
48
|
+
start: list.elements[firstIndex].getStart(sourceFile),
|
|
49
|
+
end: list.elements[lastIndex].getEnd(),
|
|
50
|
+
text: ''
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
index++;
|
|
54
|
+
}
|
|
55
|
+
return edits;
|
|
56
|
+
}
|
|
57
|
+
function editListElement(list, element, sourceFile) {
|
|
58
|
+
return editListElements(list, [element], sourceFile)[0];
|
|
59
|
+
}
|
|
60
|
+
function editArrayIdentifierImports(sourceFile, importsArray, symbolNames) {
|
|
61
|
+
const existingSymbols = new Set(importsArray.elements.flatMap((element) => (ts.isIdentifier(element) ? [element.text] : [])));
|
|
62
|
+
const missingSymbols = symbolNames.filter((symbolName) => !existingSymbols.has(symbolName));
|
|
63
|
+
if (missingSymbols.length === 0) {
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
const insertOffset = importsArray.elements.length > 0
|
|
67
|
+
? importsArray.elements[importsArray.elements.length - 1].getEnd()
|
|
68
|
+
: importsArray.getStart(sourceFile) + 1;
|
|
69
|
+
return [
|
|
70
|
+
{
|
|
71
|
+
start: insertOffset,
|
|
72
|
+
end: insertOffset,
|
|
73
|
+
text: `${importsArray.elements.length > 0 ? ', ' : ''}${missingSymbols.join(', ')}`
|
|
74
|
+
}
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
function getNamedBindings(statement) {
|
|
78
|
+
const namedBindings = statement.importClause?.namedBindings;
|
|
79
|
+
return namedBindings && ts.isNamedImports(namedBindings) ? namedBindings : null;
|
|
80
|
+
}
|
|
81
|
+
function getNamedImportText(sourceFile, element) {
|
|
82
|
+
return element.getText(sourceFile);
|
|
83
|
+
}
|
|
84
|
+
function addNamedImports(sourceFile, moduleName, importNames) {
|
|
85
|
+
const uniqueImportNames = [...new Set(importNames)].sort();
|
|
86
|
+
if (uniqueImportNames.length === 0) {
|
|
87
|
+
return [];
|
|
88
|
+
}
|
|
89
|
+
for (const statement of sourceFile.statements) {
|
|
90
|
+
if (!ts.isImportDeclaration(statement) ||
|
|
91
|
+
!ts.isStringLiteral(statement.moduleSpecifier) ||
|
|
92
|
+
statement.moduleSpecifier.text !== moduleName) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const namedBindings = getNamedBindings(statement);
|
|
96
|
+
if (namedBindings) {
|
|
97
|
+
const existing = new Set(namedBindings.elements.map((element) => getNamedImportText(sourceFile, element)));
|
|
98
|
+
const missing = uniqueImportNames.filter((importName) => !existing.has(importName));
|
|
99
|
+
if (missing.length === 0) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
const insertOffset = namedBindings.elements.length > 0
|
|
103
|
+
? namedBindings.elements[namedBindings.elements.length - 1].getEnd()
|
|
104
|
+
: namedBindings.getStart(sourceFile) + 1;
|
|
105
|
+
return [
|
|
106
|
+
{
|
|
107
|
+
start: insertOffset,
|
|
108
|
+
end: insertOffset,
|
|
109
|
+
text: namedBindings.elements.length > 0 ? `, ${missing.join(', ')}` : ` ${missing.join(', ')} `
|
|
110
|
+
}
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
if (statement.importClause?.name) {
|
|
114
|
+
const insertOffset = statement.importClause.name.getEnd();
|
|
115
|
+
return [{ start: insertOffset, end: insertOffset, text: `, { ${uniqueImportNames.join(', ')} }` }];
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
const firstStatement = sourceFile.statements[0];
|
|
119
|
+
return [
|
|
120
|
+
{
|
|
121
|
+
start: firstStatement?.getStart(sourceFile) ?? 0,
|
|
122
|
+
end: firstStatement?.getStart(sourceFile) ?? 0,
|
|
123
|
+
text: `import { ${uniqueImportNames.join(', ')} } from '${moduleName}';\n`
|
|
124
|
+
}
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
function removeNamedImports(sourceFile, moduleNames, importedNames) {
|
|
128
|
+
const modules = toModuleNames(moduleNames);
|
|
129
|
+
const names = new Set(importedNames);
|
|
130
|
+
const edits = [];
|
|
131
|
+
for (const statement of sourceFile.statements) {
|
|
132
|
+
if (!ts.isImportDeclaration(statement) ||
|
|
133
|
+
!ts.isStringLiteral(statement.moduleSpecifier) ||
|
|
134
|
+
!modules.has(statement.moduleSpecifier.text)) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
const namedBindings = getNamedBindings(statement);
|
|
138
|
+
if (!namedBindings) {
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const remaining = namedBindings.elements.filter((element) => {
|
|
142
|
+
const importedName = element.propertyName?.text ?? element.name.text;
|
|
143
|
+
return !names.has(importedName);
|
|
144
|
+
});
|
|
145
|
+
if (remaining.length === namedBindings.elements.length) {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
edits.push(remaining.length === 0 && !statement.importClause?.name
|
|
149
|
+
? { start: statement.getFullStart(), end: statement.getEnd(), text: '' }
|
|
150
|
+
: {
|
|
151
|
+
start: namedBindings.getStart(sourceFile),
|
|
152
|
+
end: namedBindings.getEnd(),
|
|
153
|
+
text: `{ ${remaining.map((element) => element.getText(sourceFile)).join(', ')} }`
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
return edits;
|
|
157
|
+
}
|