index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  10. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  11. return new (P || (P = Promise))(function (resolve, reject) {
  12. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  13. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  14. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  15. step((generator = generator.apply(thisArg, _arguments || [])).next());
  16. });
  17. };
  18. Object.defineProperty(exports, "__esModule", { value: true });
  19. exports.default = default_1;
  20. const schematics_1 = require("@angular-devkit/schematics");
  21. const utils_1 = require("../../utils");
  22. /** Scaffolds a new Angular component that uses the Drag and Drop module. */
  23. function default_1(options) {
  24. return (0, schematics_1.chain)([
  25. (0, utils_1.buildComponent)(Object.assign({}, options), {
  26. template: './__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template',
  27. stylesheet: './__path__/__name@dasherize@if-flat__/__name@dasherize__.component.__style__.template',
  28. }),
  29. options.skipImport ? (0, schematics_1.noop)() : addDragDropModulesToModule(options),
  30. ]);
  31. }
  32. /** Adds the required modules to the main module of the CLI project. */
  33. function addDragDropModulesToModule(options) {
  34. return (host) => __awaiter(this, void 0, void 0, function* () {
  35. const isStandalone = yield (0, utils_1.isStandaloneSchematic)(host, options);
  36. if (!isStandalone) {
  37. const modulePath = yield (0, utils_1.findModuleFromOptions)(host, options);
  38. (0, utils_1.addModuleImportToModule)(host, modulePath, 'DragDropModule', '@angular/cdk/drag-drop');
  39. }
  40. });
  41. }
  42. //# sourceMappingURL=index.js.map