index.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. "use strict";
  2. /**
  3. * @license
  4. * Copyright Google LLC All Rights Reserved.
  5. *
  6. * Use of this source code is governed by an MIT-style license that can be
  7. * found in the LICENSE file at https://angular.dev/license
  8. */
  9. Object.defineProperty(exports, "__esModule", { value: true });
  10. exports.default = default_1;
  11. const schematics_1 = require("@angular-devkit/schematics");
  12. const schematics_2 = require("@angular/cdk/schematics");
  13. /**
  14. * Scaffolds a new table component.
  15. * Internally it bootstraps the base component schematic
  16. */
  17. function default_1(options) {
  18. return (0, schematics_1.chain)([
  19. (0, schematics_2.buildComponent)({ ...options }, {
  20. template: './__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template',
  21. stylesheet: './__path__/__name@dasherize@if-flat__/__name@dasherize__.component.__style__.template',
  22. }),
  23. options.skipImport ? (0, schematics_1.noop)() : addTableModulesToModule(options),
  24. ]);
  25. }
  26. /**
  27. * Adds the required modules to the relative module.
  28. */
  29. function addTableModulesToModule(options) {
  30. return async (host) => {
  31. const isStandalone = await (0, schematics_2.isStandaloneSchematic)(host, options);
  32. if (!isStandalone) {
  33. const modulePath = (await (0, schematics_2.findModuleFromOptions)(host, options));
  34. (0, schematics_2.addModuleImportToModule)(host, modulePath, 'MatTableModule', '@angular/material/table');
  35. (0, schematics_2.addModuleImportToModule)(host, modulePath, 'MatPaginatorModule', '@angular/material/paginator');
  36. (0, schematics_2.addModuleImportToModule)(host, modulePath, 'MatSortModule', '@angular/material/sort');
  37. }
  38. };
  39. }
  40. //# sourceMappingURL=index.js.map