ng-inline-svg
Advanced tools
Comparing version 8.5.1 to 8.6.0
@@ -1,10 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var inline_svg_config_1 = require("./inline-svg.config"); | ||
exports.InlineSVGConfig = inline_svg_config_1.InlineSVGConfig; | ||
var inline_svg_directive_1 = require("./inline-svg.directive"); | ||
exports.InlineSVGDirective = inline_svg_directive_1.InlineSVGDirective; | ||
var inline_svg_module_1 = require("./inline-svg.module"); | ||
exports.InlineSVGModule = inline_svg_module_1.InlineSVGModule; | ||
var svg_cache_service_1 = require("./svg-cache.service"); | ||
exports.SVGCacheService = svg_cache_service_1.SVGCacheService; | ||
export { InlineSVGConfig } from './inline-svg.config'; | ||
export { InlineSVGDirective } from './inline-svg.directive'; | ||
export { InlineSVGModule } from './inline-svg.module'; | ||
export { SVGCacheService } from './svg-cache.service'; |
@@ -1,6 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = require("@angular/core"); | ||
var inline_svg_directive_1 = require("./inline-svg.directive"); | ||
var inline_svg_service_1 = require("./inline-svg.service"); | ||
import { ChangeDetectionStrategy, Component, ElementRef, Input } from '@angular/core'; | ||
import { InlineSVGDirective } from './inline-svg.directive'; | ||
import { InlineSVGService } from './inline-svg.service'; | ||
var InlineSVGComponent = (function () { | ||
@@ -23,20 +21,20 @@ function InlineSVGComponent(_inlineSVGService, el) { | ||
InlineSVGComponent.decorators = [ | ||
{ type: core_1.Component, args: [{ | ||
{ type: Component, args: [{ | ||
selector: 'inline-svg', | ||
template: '', | ||
changeDetection: core_1.ChangeDetectionStrategy.OnPush | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
},] }, | ||
]; | ||
InlineSVGComponent.ctorParameters = function () { return [ | ||
{ type: inline_svg_service_1.InlineSVGService }, | ||
{ type: core_1.ElementRef } | ||
{ type: InlineSVGService }, | ||
{ type: ElementRef } | ||
]; }; | ||
InlineSVGComponent.propDecorators = { | ||
context: [{ type: core_1.Input }], | ||
content: [{ type: core_1.Input }], | ||
replaceContents: [{ type: core_1.Input }], | ||
prepend: [{ type: core_1.Input }] | ||
context: [{ type: Input }], | ||
content: [{ type: Input }], | ||
replaceContents: [{ type: Input }], | ||
prepend: [{ type: Input }] | ||
}; | ||
return InlineSVGComponent; | ||
}()); | ||
exports.InlineSVGComponent = InlineSVGComponent; | ||
export { InlineSVGComponent }; |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var InlineSVGConfig = (function () { | ||
@@ -8,2 +6,2 @@ function InlineSVGConfig() { | ||
}()); | ||
exports.InlineSVGConfig = InlineSVGConfig; | ||
export { InlineSVGConfig }; |
@@ -20,3 +20,3 @@ import { ComponentFactoryResolver, ElementRef, EventEmitter, OnChanges, OnDestroy, OnInit, Renderer2, SimpleChanges, ViewContainerRef } from '@angular/core'; | ||
setSVGAttributes: { | ||
string: any; | ||
[key: string]: any; | ||
}; | ||
@@ -23,0 +23,0 @@ removeSVGAttributes: Array<string>; |
@@ -1,10 +0,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = require("@angular/core"); | ||
var common_1 = require("@angular/common"); | ||
var inline_svg_component_1 = require("./inline-svg.component"); | ||
var svg_cache_service_1 = require("./svg-cache.service"); | ||
var inline_svg_service_1 = require("./inline-svg.service"); | ||
var inline_svg_config_1 = require("./inline-svg.config"); | ||
var SvgUtil = require("./svg-util"); | ||
import { ComponentFactoryResolver, Directive, ElementRef, EventEmitter, Inject, Input, Optional, Output, PLATFORM_ID, Renderer2, ViewContainerRef, } from '@angular/core'; | ||
import { isPlatformBrowser, isPlatformServer } from '@angular/common'; | ||
import { InlineSVGComponent } from './inline-svg.component'; | ||
import { SVGCacheService } from './svg-cache.service'; | ||
import { InlineSVGService } from './inline-svg.service'; | ||
import { InlineSVGConfig } from './inline-svg.config'; | ||
import * as SvgUtil from './svg-util'; | ||
var InlineSVGDirective = (function () { | ||
@@ -26,6 +24,6 @@ function InlineSVGDirective(_el, _viewContainerRef, _resolver, _svgCache, _renderer, _inlineSVGService, _config, platformId) { | ||
this.evalScripts = "always"; | ||
this.onSVGInserted = new core_1.EventEmitter(); | ||
this.onSVGFailed = new core_1.EventEmitter(); | ||
this.onSVGInserted = new EventEmitter(); | ||
this.onSVGFailed = new EventEmitter(); | ||
this._supportsSVG = SvgUtil.isSvgSupported(); | ||
if (!common_1.isPlatformServer(this.platformId) && !this._supportsSVG) { | ||
if (!isPlatformServer(this.platformId) && !this._supportsSVG) { | ||
this._fail('Embed SVG are not supported by this browser'); | ||
@@ -55,3 +53,3 @@ } | ||
var _this = this; | ||
if (!common_1.isPlatformServer(this.platformId) && !this._supportsSVG) { | ||
if (!isPlatformServer(this.platformId) && !this._supportsSVG) { | ||
return; | ||
@@ -82,3 +80,3 @@ } | ||
} | ||
if (this.removeSVGAttributes && common_1.isPlatformBrowser(this.platformId)) { | ||
if (this.removeSVGAttributes && isPlatformBrowser(this.platformId)) { | ||
SvgUtil.removeAttributes(svg, this.removeSVGAttributes); | ||
@@ -93,3 +91,3 @@ } | ||
this._insertEl(svg); | ||
if (common_1.isPlatformBrowser(this.platformId)) { | ||
if (isPlatformBrowser(this.platformId)) { | ||
this._inlineSVGService.evalScripts(svg, this.inlineSVG, this.evalScripts); | ||
@@ -106,3 +104,3 @@ } | ||
if (!this._svgComp) { | ||
var factory = this._resolver.resolveComponentFactory(inline_svg_component_1.InlineSVGComponent); | ||
var factory = this._resolver.resolveComponentFactory(InlineSVGComponent); | ||
this._svgComp = this._viewContainerRef.createComponent(factory); | ||
@@ -114,3 +112,3 @@ } | ||
this._svgComp.instance.content = el; | ||
this._renderer.appendChild(this._el.nativeElement, this._svgComp.injector.get(inline_svg_component_1.InlineSVGComponent)._el.nativeElement); | ||
this._renderer.appendChild(this._el.nativeElement, this._svgComp.injector.get(InlineSVGComponent)._el.nativeElement); | ||
} | ||
@@ -130,40 +128,40 @@ else { | ||
InlineSVGDirective.prototype._isValidPlatform = function () { | ||
return common_1.isPlatformServer(this.platformId) || common_1.isPlatformBrowser(this.platformId); | ||
return isPlatformServer(this.platformId) || isPlatformBrowser(this.platformId); | ||
}; | ||
InlineSVGDirective.prototype._isSSRDisabled = function () { | ||
return common_1.isPlatformServer(this.platformId) && this._config && this._config.clientOnly; | ||
return isPlatformServer(this.platformId) && this._config && this._config.clientOnly; | ||
}; | ||
InlineSVGDirective.decorators = [ | ||
{ type: core_1.Directive, args: [{ | ||
{ type: Directive, args: [{ | ||
selector: '[inlineSVG]', | ||
providers: [svg_cache_service_1.SVGCacheService] | ||
providers: [SVGCacheService] | ||
},] }, | ||
]; | ||
InlineSVGDirective.ctorParameters = function () { return [ | ||
{ type: core_1.ElementRef }, | ||
{ type: core_1.ViewContainerRef }, | ||
{ type: core_1.ComponentFactoryResolver }, | ||
{ type: svg_cache_service_1.SVGCacheService }, | ||
{ type: core_1.Renderer2 }, | ||
{ type: inline_svg_service_1.InlineSVGService }, | ||
{ type: inline_svg_config_1.InlineSVGConfig, decorators: [{ type: core_1.Optional }] }, | ||
{ type: Object, decorators: [{ type: core_1.Inject, args: [core_1.PLATFORM_ID,] }] } | ||
{ type: ElementRef }, | ||
{ type: ViewContainerRef }, | ||
{ type: ComponentFactoryResolver }, | ||
{ type: SVGCacheService }, | ||
{ type: Renderer2 }, | ||
{ type: InlineSVGService }, | ||
{ type: InlineSVGConfig, decorators: [{ type: Optional }] }, | ||
{ type: Object, decorators: [{ type: Inject, args: [PLATFORM_ID,] }] } | ||
]; }; | ||
InlineSVGDirective.propDecorators = { | ||
inlineSVG: [{ type: core_1.Input }], | ||
replaceContents: [{ type: core_1.Input }], | ||
prepend: [{ type: core_1.Input }], | ||
injectComponent: [{ type: core_1.Input }], | ||
cacheSVG: [{ type: core_1.Input }], | ||
setSVGAttributes: [{ type: core_1.Input }], | ||
removeSVGAttributes: [{ type: core_1.Input }], | ||
forceEvalStyles: [{ type: core_1.Input }], | ||
evalScripts: [{ type: core_1.Input }], | ||
fallbackImgUrl: [{ type: core_1.Input }], | ||
onSVGLoaded: [{ type: core_1.Input }], | ||
onSVGInserted: [{ type: core_1.Output }], | ||
onSVGFailed: [{ type: core_1.Output }] | ||
inlineSVG: [{ type: Input }], | ||
replaceContents: [{ type: Input }], | ||
prepend: [{ type: Input }], | ||
injectComponent: [{ type: Input }], | ||
cacheSVG: [{ type: Input }], | ||
setSVGAttributes: [{ type: Input }], | ||
removeSVGAttributes: [{ type: Input }], | ||
forceEvalStyles: [{ type: Input }], | ||
evalScripts: [{ type: Input }], | ||
fallbackImgUrl: [{ type: Input }], | ||
onSVGLoaded: [{ type: Input }], | ||
onSVGInserted: [{ type: Output }], | ||
onSVGFailed: [{ type: Output }] | ||
}; | ||
return InlineSVGDirective; | ||
}()); | ||
exports.InlineSVGDirective = InlineSVGDirective; | ||
export { InlineSVGDirective }; |
@@ -1,7 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = require("@angular/core"); | ||
var inline_svg_component_1 = require("./inline-svg.component"); | ||
var inline_svg_config_1 = require("./inline-svg.config"); | ||
var inline_svg_directive_1 = require("./inline-svg.directive"); | ||
import { NgModule } from '@angular/core'; | ||
import { InlineSVGComponent } from './inline-svg.component'; | ||
import { InlineSVGConfig } from './inline-svg.config'; | ||
import { InlineSVGDirective } from './inline-svg.directive'; | ||
var InlineSVGModule = (function () { | ||
@@ -14,3 +12,3 @@ function InlineSVGModule() { | ||
providers: [ | ||
{ provide: inline_svg_config_1.InlineSVGConfig, useValue: config } | ||
{ provide: InlineSVGConfig, useValue: config } | ||
] | ||
@@ -20,6 +18,6 @@ }; | ||
InlineSVGModule.decorators = [ | ||
{ type: core_1.NgModule, args: [{ | ||
declarations: [inline_svg_directive_1.InlineSVGDirective, inline_svg_component_1.InlineSVGComponent], | ||
exports: [inline_svg_directive_1.InlineSVGDirective], | ||
entryComponents: [inline_svg_component_1.InlineSVGComponent] | ||
{ type: NgModule, args: [{ | ||
declarations: [InlineSVGDirective, InlineSVGComponent], | ||
exports: [InlineSVGDirective], | ||
entryComponents: [InlineSVGComponent] | ||
},] }, | ||
@@ -29,2 +27,2 @@ ]; | ||
}()); | ||
exports.InlineSVGModule = InlineSVGModule; | ||
export { InlineSVGModule }; |
@@ -1,5 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = require("@angular/core"); | ||
var i0 = require("@angular/core"); | ||
import { Injectable, RendererFactory2 } from '@angular/core'; | ||
import * as i0 from "@angular/core"; | ||
var InlineSVGService = (function () { | ||
@@ -48,3 +46,3 @@ function InlineSVGService(rendererFactory) { | ||
InlineSVGService.decorators = [ | ||
{ type: core_1.Injectable, args: [{ | ||
{ type: Injectable, args: [{ | ||
providedIn: 'root' | ||
@@ -54,3 +52,3 @@ },] }, | ||
InlineSVGService.ctorParameters = function () { return [ | ||
{ type: core_1.RendererFactory2 } | ||
{ type: RendererFactory2 } | ||
]; }; | ||
@@ -60,2 +58,2 @@ InlineSVGService.ngInjectableDef = i0.defineInjectable({ factory: function InlineSVGService_Factory() { return new InlineSVGService(i0.inject(i0.RendererFactory2)); }, token: InlineSVGService, providedIn: "root" }); | ||
}()); | ||
exports.InlineSVGService = InlineSVGService; | ||
export { InlineSVGService }; |
@@ -1,13 +0,11 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var core_1 = require("@angular/core"); | ||
var common_1 = require("@angular/common"); | ||
var http_1 = require("@angular/common/http"); | ||
var rxjs_1 = require("rxjs"); | ||
var operators_1 = require("rxjs/operators"); | ||
var inline_svg_config_1 = require("./inline-svg.config"); | ||
var i0 = require("@angular/core"); | ||
var i1 = require("@angular/common"); | ||
var i2 = require("./inline-svg.config"); | ||
var i3 = require("@angular/common/http"); | ||
import { Inject, Injectable, Optional, RendererFactory2 } from '@angular/core'; | ||
import { APP_BASE_HREF, PlatformLocation } from '@angular/common'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { of } from 'rxjs'; | ||
import { map, finalize, share } from 'rxjs/operators'; | ||
import { InlineSVGConfig } from './inline-svg.config'; | ||
import * as i0 from "@angular/core"; | ||
import * as i1 from "@angular/common"; | ||
import * as i2 from "./inline-svg.config"; | ||
import * as i3 from "@angular/common/http"; | ||
var SVGCacheService = (function () { | ||
@@ -33,3 +31,3 @@ function SVGCacheService(_appBase, _location, _config, _http, rendererFactory) { | ||
if (cache && SVGCacheService._cache.has(absUrl)) { | ||
return rxjs_1.of(this._cloneSVG(SVGCacheService._cache.get(absUrl))); | ||
return of(this._cloneSVG(SVGCacheService._cache.get(absUrl))); | ||
} | ||
@@ -40,5 +38,5 @@ if (SVGCacheService._inProgressReqs.has(absUrl)) { | ||
var req = this._http.get(absUrl, { responseType: 'text' }) | ||
.pipe(operators_1.finalize(function () { | ||
.pipe(finalize(function () { | ||
SVGCacheService._inProgressReqs.delete(absUrl); | ||
}), operators_1.share(), operators_1.map(function (svgText) { | ||
}), share(), map(function (svgText) { | ||
var svgEl = _this._svgElementFromString(svgText); | ||
@@ -86,3 +84,3 @@ SVGCacheService._cache.set(absUrl, svgEl); | ||
SVGCacheService.decorators = [ | ||
{ type: core_1.Injectable, args: [{ | ||
{ type: Injectable, args: [{ | ||
providedIn: 'root' | ||
@@ -92,7 +90,7 @@ },] }, | ||
SVGCacheService.ctorParameters = function () { return [ | ||
{ type: String, decorators: [{ type: core_1.Optional }, { type: core_1.Inject, args: [common_1.APP_BASE_HREF,] }] }, | ||
{ type: common_1.PlatformLocation, decorators: [{ type: core_1.Optional }] }, | ||
{ type: inline_svg_config_1.InlineSVGConfig, decorators: [{ type: core_1.Optional }] }, | ||
{ type: http_1.HttpClient }, | ||
{ type: core_1.RendererFactory2 } | ||
{ type: String, decorators: [{ type: Optional }, { type: Inject, args: [APP_BASE_HREF,] }] }, | ||
{ type: PlatformLocation, decorators: [{ type: Optional }] }, | ||
{ type: InlineSVGConfig, decorators: [{ type: Optional }] }, | ||
{ type: HttpClient }, | ||
{ type: RendererFactory2 } | ||
]; }; | ||
@@ -102,2 +100,2 @@ SVGCacheService.ngInjectableDef = i0.defineInjectable({ factory: function SVGCacheService_Factory() { return new SVGCacheService(i0.inject(i1.APP_BASE_HREF, 8), i0.inject(i1.PlatformLocation, 8), i0.inject(i2.InlineSVGConfig, 8), i0.inject(i3.HttpClient), i0.inject(i0.RendererFactory2)); }, token: SVGCacheService, providedIn: "root" }); | ||
}()); | ||
exports.SVGCacheService = SVGCacheService; | ||
export { SVGCacheService }; |
@@ -7,3 +7,3 @@ import { Renderer2 } from '@angular/core'; | ||
export declare function setAttributes(element: Element, attrs: { | ||
string: any; | ||
[key: string]: any; | ||
}): void; |
@@ -1,12 +0,8 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function isUrlSymbol(url) { | ||
export function isUrlSymbol(url) { | ||
return url.charAt(0) === '#' || url.indexOf('.svg#') > -1; | ||
} | ||
exports.isUrlSymbol = isUrlSymbol; | ||
function isSvgSupported() { | ||
export function isSvgSupported() { | ||
return typeof SVGRect !== 'undefined'; | ||
} | ||
exports.isSvgSupported = isSvgSupported; | ||
function createSymbolSvg(renderer, svg, symbolId) { | ||
export function createSymbolSvg(renderer, svg, symbolId) { | ||
var symbol = svg.querySelector("[id=\"" + symbolId + "\"]"); | ||
@@ -23,4 +19,3 @@ if (!symbol) { | ||
} | ||
exports.createSymbolSvg = createSymbolSvg; | ||
function removeAttributes(element, attrs) { | ||
export function removeAttributes(element, attrs) { | ||
for (var i = 0; i < attrs.length; i++) { | ||
@@ -37,4 +32,3 @@ var elAttr = element.getAttribute(attrs[i]); | ||
} | ||
exports.removeAttributes = removeAttributes; | ||
function setAttributes(element, attrs) { | ||
export function setAttributes(element, attrs) { | ||
for (var attr in attrs) { | ||
@@ -44,2 +38,1 @@ element.setAttribute(attr, attrs[attr]); | ||
} | ||
exports.setAttributes = setAttributes; |
{ | ||
"name": "ng-inline-svg", | ||
"version": "8.5.1", | ||
"version": "8.6.0", | ||
"description": "Angular directive for inserting an SVG inline within an element.", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -70,3 +70,3 @@ # ng-inline-svg | ||
| injectComponent | boolean | `false` | Injects an `<inline-svg>` component containing the SVG inside the element with the directive. | | ||
| setSVGAttributes | `{ string: any }` | | Sets attributes on the SVG element. Runs after `removeSVGAttributes`. | | ||
| setSVGAttributes | `{ [key: string]: any }` | | Sets attributes on the SVG element. Runs after `removeSVGAttributes`. | | ||
| removeSVGAttributes | string[] | | An array of attribute names to remove from all child elements within the SVG. | | ||
@@ -73,0 +73,0 @@ | forceEvalStyles | boolean | `false` | Forces embeded style tags' contents to be evaluated (for IE 11). | |
@@ -38,3 +38,3 @@ import { | ||
@Input() cacheSVG: boolean = true; | ||
@Input() setSVGAttributes: { string: any }; | ||
@Input() setSVGAttributes: { [key: string]: any }; | ||
@Input() removeSVGAttributes: Array<string>; | ||
@@ -41,0 +41,0 @@ @Input() forceEvalStyles: boolean = false; |
@@ -70,3 +70,3 @@ import { Renderer2 } from '@angular/core'; | ||
*/ | ||
export function setAttributes(element: Element, attrs: { string: any }): void { | ||
export function setAttributes(element: Element, attrs: { [key: string]: any }): void { | ||
for (const attr in attrs) { | ||
@@ -73,0 +73,0 @@ element.setAttribute(attr, attrs[attr]); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56246
1006