@obliczeniowo/elementary
Version:
Library made in Angular version 20
75 lines (70 loc) • 4.35 kB
JavaScript
import * as i0 from '@angular/core';
import { input, effect, Component, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import * as i1 from '@obliczeniowo/elementary/json-def-table';
import { JsonDefTableModule } from '@obliczeniowo/elementary/json-def-table';
import { symbols } from '@obliczeniowo/elementary/utils';
class ChemicalTextComponent {
text = input();
fontSize = input();
type = input('color');
prepared = [];
constructor() {
effect(() => {
const text = this.text();
if (text) {
const convert = text.split(' ');
convert.forEach((toConvert, i) => {
let symbols$1 = [...symbols];
let index = -1;
let s = '';
symbols$1.forEach(symbol => {
const found = toConvert.toLowerCase().search(symbol.toLowerCase());
if ((index > -1 && found <= index && s.length <= symbol.length && found !== -1) || (index === -1 && found !== -1)) {
index = found;
s = symbol;
}
});
if (index !== -1) {
convert[i] = toConvert.replace(new RegExp(s, 'i'), `<span class="${this.type()}">${s}</span>`);
}
symbols$1 = symbols$1.filter(symbol => symbol !== s);
});
this.prepared = convert.join(' ').split('\n');
}
});
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: ChemicalTextComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.0.4", type: ChemicalTextComponent, isStandalone: false, selector: "obl-chemical-text", inputs: { text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, fontSize: { classPropertyName: "fontSize", publicName: "fontSize", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null } }, ngImport: i0, template: "@for (line of prepared; track line) {\n <div [innerHtml]=\"line | safe : 'html'\" [style.fontSize]=\"fontSize()\"></div>\n}\n", styles: [""], dependencies: [{ kind: "pipe", type: i1.SafePipeDirective, name: "safe" }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: ChemicalTextComponent, decorators: [{
type: Component,
args: [{ selector: 'obl-chemical-text', standalone: false, template: "@for (line of prepared; track line) {\n <div [innerHtml]=\"line | safe : 'html'\" [style.fontSize]=\"fontSize()\"></div>\n}\n" }]
}], ctorParameters: () => [] });
class ChemicalTextModule {
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: ChemicalTextModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.0.4", ngImport: i0, type: ChemicalTextModule, declarations: [ChemicalTextComponent], imports: [CommonModule,
JsonDefTableModule], exports: [ChemicalTextComponent] });
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: ChemicalTextModule, imports: [CommonModule,
JsonDefTableModule] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.4", ngImport: i0, type: ChemicalTextModule, decorators: [{
type: NgModule,
args: [{
declarations: [
ChemicalTextComponent
],
imports: [
CommonModule,
JsonDefTableModule
],
exports: [
ChemicalTextComponent
]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { ChemicalTextComponent, ChemicalTextModule };
//# sourceMappingURL=obliczeniowo-elementary-chemical-text.mjs.map