UNPKG

smart-webcomponents-angular

Version:

[![Price](https://img.shields.io/badge/price-COMMERCIAL-0098f7.svg)](https://jqwidgets.com/license/)

77 lines 3.76 kB
"use strict"; 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 }); const schematics_1 = require("@angular-devkit/schematics"); const schematics_2 = require("../../cdk/schematics"); const config_1 = require("@schematics/angular/utility/workspace"); const material_fonts_1 = require("../../fonts/material-fonts"); const theming_1 = require("../../theming/theming"); /** * Scaffolds a new table component. * Internally it bootstraps the base component schematic */ function default_1(options) { return schematics_1.chain([ schematics_2.buildComponent(Object.assign({}, options), { template: './__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template', stylesheet: './__path__/__name@dasherize@if-flat__/__name@dasherize__.component.__style__.template' }), theming_1.addThemeToAppStyles(options), material_fonts_1.addFontsToIndex(options), theming_1.addTypographyClass(options), options.skipImport ? schematics_1.noop() : addTableModulesToModule(options) ]); } exports.default = default_1; /** * Adds custom Material styles to the project style file. The custom CSS sets up the Roboto font * and reset the default browser body margin. */ function addMaterialAppStyles(options) { return (host, context) => { const workspace = config_1.getWorkspace(host); const project = schematics_2.getProjectFromWorkspace(workspace, options.project); const styleFilePath = schematics_2.getProjectStyleFile(project); const logger = context.logger; if (!styleFilePath) { logger.error(`Could not find the default style file for this project.`); logger.info(`Please consider manually setting up the Roboto font in your CSS.`); return; } const buffer = host.read(styleFilePath); if (!buffer) { logger.error(`Could not read the default style file within the project ` + `(${styleFilePath})`); logger.info(`Please consider manually setting up the Robot font.`); return; } const htmlContent = buffer.toString(); const insertion = '\n' + `html, body { height: 100%; }\n` + `body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }\n`; if (htmlContent.includes(insertion)) { return; } const recorder = host.beginUpdate(styleFilePath); recorder.insertLeft(htmlContent.length, insertion); host.commitUpdate(recorder); }; } /** * Adds the required modules to the relative module. */ function addTableModulesToModule(options) { return (host) => __awaiter(this, void 0, void 0, function* () { const modulePath = (yield schematics_2.findModuleFromOptions(host, options)); schematics_2.addModuleImportToModule(host, modulePath, 'TreeModule', 'smart-webcomponents-angular/tree'); }); } //# sourceMappingURL=index.js.map