import * as i0 from '@angular/core';
import { OnDestroy, ElementRef } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { SafeHtml, DomSanitizer } from '@angular/platform-browser';
import { Observable } from 'rxjs';
import * as i2 from '@angular/common';
interface Icon {
svgString?: string;
url: SafeHtml;
name: string;
}
/**
* Registering icons service for icon.component
*
* Registering own:
* @example
*
* constructor(private iconResource: IconResourceService) {
* iconResource.registerIcon(
* this.sanitizer.bypassSecurityTrustHtml('/assets/icons/your-icon.svg'),
* 'icon-name'
* );
* }
*
* @
* Use in html with icon component:
*
* @example
*
*
*
* @ To correctly work in library component you need to copy assets folder adding script to npm:
*
* @example
*
* "copy-assets": "node ./node_modules/@obliczeniowo/elementary/assets/scripts/copy.js ./src/assets/",
*
* @ and run in console:
*
* @example
* npm run copy-assets
*/
declare class IconResourceService implements OnDestroy {
private readonly http;
private readonly sanitizer;
private readonly document;
protected icons: Map;
protected urls: Map>>;
protected loading: Map>;
protected base: string;
constructor(http: HttpClient, sanitizer: DomSanitizer, document: Document);
/**
* Registering own:
* @param url SafeHTML object with path to icon in your asset folder
* @param name your icon name
*
* @example
*
* constructor(private iconResource: IconResourceService) {
* iconResource.registerIcon(
* this.sanitizer.bypassSecurityTrustHtml('/assets/icons/your-icon.svg'),
* 'icon-name'
* );
* }
*
* @
* Use in html with icon component:
*
* @example
*
*
*/
registerIcon(url: SafeHtml, name: string): void;
/**
* Download once icon from server and keep it in buffer
* @param name name of icon
* @returns observable with SVGSVGElement or undefined
*/
getIcon(name: string): Observable;
/**
* Register url to SVG file
* @param url url string
* @returns SVGSVGElement/undefined or throwing error
*/
fromUrl(url: string): Observable;
protected _fromUrl(url: string, cb?: (svg: string) => void, cbError?: () => Error): Observable;
ngOnDestroy(): void;
protected err(name?: string, url?: string): Error;
protected createSvgFromString(svgString: string): SVGSVGElement | undefined;
static ɵfac: i0.ɵɵFactoryDeclaration;
static ɵprov: i0.ɵɵInjectableDeclaration;
}
/**
* Icon component that let you display registered icon with IconResourceService
*
* @example
*
*
*/
declare class IconComponent {
protected iconResource: IconResourceService;
protected elementRef: ElementRef;
/**
* registered icon name
*/
name: i0.InputSignal;
/**
* Width in px or css like things
*/
width: i0.InputSignal;
get widthStyle(): string | number;
constructor(iconResource: IconResourceService, elementRef: ElementRef);
static ɵfac: i0.ɵɵFactoryDeclaration;
static ɵcmp: i0.ɵɵComponentDeclaration;
}
declare class IconsModule {
static ɵfac: i0.ɵɵFactoryDeclaration;
static ɵmod: i0.ɵɵNgModuleDeclaration;
static ɵinj: i0.ɵɵInjectorDeclaration;
}
export { IconComponent, IconResourceService, IconsModule };
export type { Icon };