ngx-daterangepicker-material
Version:
Angular 9 and 10 date range picker (with material design theme)
79 lines • 3.3 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
const schematics_1 = require("@angular-devkit/schematics");
const schematics_2 = require("@angular/cdk/schematics");
const core_1 = require("@angular-devkit/core");
const moduleName = 'NgxDaterangepickerMd';
/**
* Scaffolds the basics of a Angular Material application, this includes:
* - Add Packages to package.json
* - Adds pre-built themes to styles.ext
* - Adds Browser Animation to app.module
*/
function default_1(options) {
return (0, schematics_1.chain)([
addDateRangePickerModule(options),
]);
}
exports.default = default_1;
/**
* Adds an animation module to the root module of the specified project. In case the "animations"
* option is set to false, we still add the `NoopAnimationsModule` because otherwise various
* components of Angular Material will throw an exception.
*/
function addDateRangePickerModule(options) {
return (tree) => {
(() => __awaiter(this, void 0, void 0, function* () {
const host = createHost(tree);
const { workspace } = yield core_1.workspaces.readWorkspace('/', host);
const project = (0, schematics_2.getProjectFromWorkspace)(workspace, options.project);
(0, schematics_2.addModuleImportToRootModule)(tree, moduleName + '.forRoot()', 'ngx-daterangepicker-material', project);
}))();
return tree;
};
}
function createHost(tree) {
return {
readFile(path) {
return __awaiter(this, void 0, void 0, function* () {
const data = tree.read(path);
if (!data) {
throw new schematics_1.SchematicsException('File not found.');
}
return core_1.virtualFs.fileBufferToString(data);
});
},
writeFile(path, data) {
return __awaiter(this, void 0, void 0, function* () {
return tree.overwrite(path, data);
});
},
isDirectory(path) {
return __awaiter(this, void 0, void 0, function* () {
return !tree.exists(path) && tree.getDir(path).subfiles.length > 0;
});
},
isFile(path) {
return __awaiter(this, void 0, void 0, function* () {
return tree.exists(path);
});
},
};
}
//# sourceMappingURL=setup-project.js.map
;