@igo2/common
Version:
119 lines (112 loc) • 6.75 kB
JavaScript
import * as i0 from '@angular/core';
import { Injectable, makeEnvironmentProviders, provideAppInitializer, inject, Input, Component } from '@angular/core';
import * as i1 from '@angular/material/icon';
import { MatIconModule, MatIconRegistry } from '@angular/material/icon';
import * as i2 from '@angular/platform-browser';
/**
* Source: https://pictogrammers.com/library/mdi/
*/
const MICROSOFT_ICON = {
name: 'microsoft',
svg: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>microsoft</title><path d="M2,3H11V12H2V3M11,22H2V13H11V22M21,3V12H12V3H21M21,22H12V13H21V22Z" /></svg>
`
};
const KEYBOARD_ESC_ICON = {
name: 'keyboard-esc',
svg: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>keyboard-esc</title><path d="M1 7H7V9H3V11H7V13H3V15H7V17H1V7M11 7H15V9H11V11H13C14.11 11 15 11.9 15 13V15C15 16.11 14.11 17 13 17H9V15H13V13H11C9.9 13 9 12.11 9 11V9C9 7.9 9.9 7 11 7M19 7H21C22.11 7 23 7.9 23 9V10H21V9H19V15H21V14H23V15C23 16.11 22.11 17 21 17H19C17.9 17 17 16.11 17 15V9C17 7.9 17.9 7 19 7Z" /></svg>
`
};
const ENGINE_ICON = {
name: 'engine',
svg: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>engine</title><path d="M7,4V6H10V8H7L5,10V13H3V10H1V18H3V15H5V18H8L10,20H18V16H20V19H23V9H20V12H18V8H12V6H15V4H7Z" /></svg>
`
};
const SELECTION_MARKER_ICON = {
name: 'selection-marker',
svg: `
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>selection-marker</title><path d="M2 4C2 2.89 2.9 2 4 2H7V4H4V7H2V4M22 4V7H20V4H17V2H20C21.1 2 22 2.89 22 4M2 20V17H4V20H7V22H4C2.9 22 2 21.11 2 20M10 2H14V4H10V2M10 20H14V22H10V20M2 10H4V14H2V10M18.5 13C20.4 13 22 14.6 22 16.5C22 19.1 18.5 23 18.5 23C18.5 23 15 19.1 15 16.5C15 14.6 16.6 13 18.5 13M18.5 17.8C19.2 17.8 19.8 17.2 19.7 16.6C19.7 16 19.1 15.4 18.5 15.4C17.9 15.4 17.3 15.9 17.3 16.6C17.3 17.2 17.8 17.8 18.5 17.8M20 10H22V12.34C21.42 11.84 20.74 11.45 20 11.23V10Z" /></svg>
`
};
const PRESENTATION_PLAY_ICON = {
name: 'presentation-play',
svg: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>presentation-play</title><path d="M2,3H10A2,2 0 0,1 12,1A2,2 0 0,1 14,3H22V5H21V16H15.25L17,22H15L13.25,16H10.75L9,22H7L8.75,16H3V5H2V3M5,5V14H19V5H5M11.85,11.85C11.76,11.94 11.64,12 11.5,12A0.5,0.5 0 0,1 11,11.5V7.5A0.5,0.5 0 0,1 11.5,7C11.64,7 11.76,7.06 11.85,7.15L13.25,8.54C13.57,8.86 13.89,9.18 13.89,9.5C13.89,9.82 13.57,10.14 13.25,10.46L11.85,11.85Z" /></svg>`
};
const CIRCLE_SMALL_ICON = {
name: 'presentation-play',
svg: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>circle-small</title><path d="M12,10A2,2 0 0,0 10,12C10,13.11 10.9,14 12,14C13.11,14 14,13.11 14,12A2,2 0 0,0 12,10Z" /></svg>`
};
const VECTOR_SQUARE_ICON = {
name: 'presentation-play',
svg: `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><title>vector-square</title><path d="M2,2H8V4H16V2H22V8H20V16H22V22H16V20H8V22H2V16H4V8H2V2M16,8V6H8V8H6V16H8V18H16V16H18V8H16M4,4V6H6V4H4M18,4V6H20V4H18M4,18V20H6V18H4M18,18V20H20V18H18Z" /></svg>`
};
class IconService {
iconRegistry;
sanitizer;
constructor(iconRegistry, sanitizer) {
this.iconRegistry = iconRegistry;
this.sanitizer = sanitizer;
}
registerSvg(icon) {
this.iconRegistry.addSvgIconLiteral(icon.name, this.sanitizer.bypassSecurityTrustHtml(icon.svg));
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IconService, deps: [{ token: i1.MatIconRegistry }, { token: i2.DomSanitizer }], target: i0.ɵɵFactoryTarget.Injectable });
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IconService, providedIn: 'root' });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IconService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root'
}]
}], ctorParameters: () => [{ type: i1.MatIconRegistry }, { type: i2.DomSanitizer }] });
function provideIcon(style = 'outlined') {
return makeEnvironmentProviders([
MatIconModule,
provideAppInitializer(() => {
const iconRegistry = inject(MatIconRegistry);
iconRegistry.setDefaultFontSetClass(`material-symbols-${style}`);
return;
})
]);
}
class IgoIconComponent {
iconService;
color;
set icon(icon) {
if (this.isSvg(icon)) {
this.registerSvg(icon);
}
this._icon = icon;
}
get icon() {
return this._icon;
}
_icon;
constructor(iconService) {
this.iconService = iconService;
}
registerSvg(icon) {
this.iconService.registerSvg(icon);
}
isSvg(icon) {
return typeof icon != 'string';
}
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IgoIconComponent, deps: [{ token: IconService }], target: i0.ɵɵFactoryTarget.Component });
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.15", type: IgoIconComponent, isStandalone: true, selector: "igo-icon", inputs: { color: "color", icon: "icon" }, ngImport: i0, template: "@if (isSvg(icon)) {\n <mat-icon [svgIcon]=\"icon.name\" [color]=\"color\"></mat-icon>\n} @else {\n <mat-icon [color]=\"color\">{{ icon }}</mat-icon>\n}\n", styles: [":host{display:flex;align-items:center;justify-content:center}\n"], dependencies: [{ kind: "ngmodule", type: MatIconModule }, { kind: "component", type: i1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }] });
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.15", ngImport: i0, type: IgoIconComponent, decorators: [{
type: Component,
args: [{ selector: 'igo-icon', imports: [MatIconModule], template: "@if (isSvg(icon)) {\n <mat-icon [svgIcon]=\"icon.name\" [color]=\"color\"></mat-icon>\n} @else {\n <mat-icon [color]=\"color\">{{ icon }}</mat-icon>\n}\n", styles: [":host{display:flex;align-items:center;justify-content:center}\n"] }]
}], ctorParameters: () => [{ type: IconService }], propDecorators: { color: [{
type: Input
}], icon: [{
type: Input,
args: [{ required: true }]
}] } });
/**
* Generated bundle index. Do not edit.
*/
export { CIRCLE_SMALL_ICON, ENGINE_ICON, IconService, IgoIconComponent, KEYBOARD_ESC_ICON, MICROSOFT_ICON, PRESENTATION_PLAY_ICON, SELECTION_MARKER_ICON, VECTOR_SQUARE_ICON, provideIcon };
//# sourceMappingURL=igo2-common-icon.mjs.map