@rxap/pipes
Version:
Provides a set of Angular pipes for common data transformations, including currency formatting, string manipulation, and object property access. These pipes offer standalone functionality for easy integration into Angular templates. The package includes p
69 lines (63 loc) • 3 kB
JavaScript
import * as i0 from '@angular/core';
import { SecurityContext, Injectable, Inject, Pipe } from '@angular/core';
import * as i1 from '@angular/platform-browser';
import { DomSanitizer } from '@angular/platform-browser';
// TODO : move to @rxap/services
class SantizationService {
constructor(_sanitizer) {
this._sanitizer = _sanitizer;
}
transform(value, type = 'url') {
if (value === null) {
return this._sanitizer.sanitize(SecurityContext.NONE, value);
}
switch (type) {
case 'html':
return this._sanitizer.bypassSecurityTrustHtml(value);
case 'style':
return this._sanitizer.bypassSecurityTrustStyle(value);
case 'script':
return this._sanitizer.bypassSecurityTrustScript(value);
case 'url':
return this._sanitizer.bypassSecurityTrustUrl(value);
case 'resourceUrl':
return this._sanitizer.bypassSecurityTrustResourceUrl(value);
}
throw new Error('type is not set');
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: SantizationService, deps: [{ token: DomSanitizer }], target: i0.ɵɵFactoryTarget.Injectable }); }
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: SantizationService, providedIn: 'root' }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: SantizationService, decorators: [{
type: Injectable,
args: [{
providedIn: 'root',
}]
}], ctorParameters: () => [{ type: i1.DomSanitizer, decorators: [{
type: Inject,
args: [DomSanitizer]
}] }] });
class SantizationPipe {
constructor(santizationService) {
this.santizationService = santizationService;
}
transform(value, type = 'url') {
return this.santizationService.transform(value, type);
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: SantizationPipe, deps: [{ token: SantizationService }], target: i0.ɵɵFactoryTarget.Pipe }); }
static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "19.2.1", ngImport: i0, type: SantizationPipe, isStandalone: true, name: "santization" }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: SantizationPipe, decorators: [{
type: Pipe,
args: [{
name: 'santization',
standalone: true,
}]
}], ctorParameters: () => [{ type: SantizationService }] });
// region
// endregion
/**
* Generated bundle index. Do not edit.
*/
export { SantizationPipe, SantizationService };
//# sourceMappingURL=rxap-pipes-santization.mjs.map