UNPKG

@carbon/icons-angular

Version:

Angular components for icons in digital and software products using the Carbon Design System

174 lines (171 loc) 11.2 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var CloudSatelliteDirective_1; let CloudSatelliteComponent = class CloudSatelliteComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], CloudSatelliteComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], CloudSatelliteComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CloudSatelliteComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], CloudSatelliteComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CloudSatelliteComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], CloudSatelliteComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], CloudSatelliteComponent.prototype, "size", void 0); CloudSatelliteComponent = __decorate([ Component({ selector: "ibm-icon-cloud-satellite", template: ` <svg ibmIconCloudSatellite [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], CloudSatelliteComponent); let CloudSatelliteDirective = CloudSatelliteDirective_1 = class CloudSatelliteDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "CloudSatellite32", "filepath": "cloud-satellite/32.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 32 32", "fill": "currentColor", "width": 32, "height": 32 }, "content": [{ "elem": "circle", "attrs": { "cx": "9", "cy": "20", "r": "2" } }, { "elem": "path", "attrs": { "d": "M16,20a4,4,0,1,1,4-4A4.0118,4.0118,0,0,1,16,20Zm0-6a2,2,0,1,0,2,2A2.0059,2.0059,0,0,0,16,14Z" } }, { "elem": "circle", "attrs": { "cx": "23", "cy": "12", "r": "2" } }, { "elem": "path", "attrs": { "d": "M23,24.7588l-7,4.0835L5,22.4258V9.5742L16,3.1577,27,9.5742V22h2V9a1,1,0,0,0-.4961-.8638l-12-7a1,1,0,0,0-1.0078,0l-12,7A1,1,0,0,0,3,9V23a1,1,0,0,0,.4961.8638l12,7a1,1,0,0,0,1.0078,0L24,26.4907Z" } }], "name": "cloud-satellite", "size": 32 }, "size": 32 }, svg: `<svg focusable="false" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><circle cx="9" cy="20" r="2"></circle><path d="M16,20a4,4,0,1,1,4-4A4.0118,4.0118,0,0,1,16,20Zm0-6a2,2,0,1,0,2,2A2.0059,2.0059,0,0,0,16,14Z"></path><circle cx="23" cy="12" r="2"></circle><path d="M23,24.7588l-7,4.0835L5,22.4258V9.5742L16,3.1577,27,9.5742V22h2V9a1,1,0,0,0-.4961-.8638l-12-7a1,1,0,0,0-1.0078,0l-12,7A1,1,0,0,0,3,9V23a1,1,0,0,0,.4961.8638l12,7a1,1,0,0,0,1.0078,0L24,26.4907Z"></path></svg>` }, "24": { metadata: { "moduleName": "CloudSatellite24", "filepath": "cloud-satellite/24.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 32 32", "fill": "currentColor", "width": 24, "height": 24 }, "content": [{ "elem": "circle", "attrs": { "cx": "9", "cy": "20", "r": "2" } }, { "elem": "path", "attrs": { "d": "M16,20a4,4,0,1,1,4-4A4.0118,4.0118,0,0,1,16,20Zm0-6a2,2,0,1,0,2,2A2.0059,2.0059,0,0,0,16,14Z" } }, { "elem": "circle", "attrs": { "cx": "23", "cy": "12", "r": "2" } }, { "elem": "path", "attrs": { "d": "M23,24.7588l-7,4.0835L5,22.4258V9.5742L16,3.1577,27,9.5742V22h2V9a1,1,0,0,0-.4961-.8638l-12-7a1,1,0,0,0-1.0078,0l-12,7A1,1,0,0,0,3,9V23a1,1,0,0,0,.4961.8638l12,7a1,1,0,0,0,1.0078,0L24,26.4907Z" } }], "name": "cloud-satellite", "size": 24 }, "size": 24 }, svg: `<svg focusable="false" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="24" height="24" viewBox="0 0 32 32" aria-hidden="true"><circle cx="9" cy="20" r="2"></circle><path d="M16,20a4,4,0,1,1,4-4A4.0118,4.0118,0,0,1,16,20Zm0-6a2,2,0,1,0,2,2A2.0059,2.0059,0,0,0,16,14Z"></path><circle cx="23" cy="12" r="2"></circle><path d="M23,24.7588l-7,4.0835L5,22.4258V9.5742L16,3.1577,27,9.5742V22h2V9a1,1,0,0,0-.4961-.8638l-12-7a1,1,0,0,0-1.0078,0l-12,7A1,1,0,0,0,3,9V23a1,1,0,0,0,.4961.8638l12,7a1,1,0,0,0,1.0078,0L24,26.4907Z"></path></svg>` }, "20": { metadata: { "moduleName": "CloudSatellite20", "filepath": "cloud-satellite/20.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 32 32", "fill": "currentColor", "width": 20, "height": 20 }, "content": [{ "elem": "circle", "attrs": { "cx": "9", "cy": "20", "r": "2" } }, { "elem": "path", "attrs": { "d": "M16,20a4,4,0,1,1,4-4A4.0118,4.0118,0,0,1,16,20Zm0-6a2,2,0,1,0,2,2A2.0059,2.0059,0,0,0,16,14Z" } }, { "elem": "circle", "attrs": { "cx": "23", "cy": "12", "r": "2" } }, { "elem": "path", "attrs": { "d": "M23,24.7588l-7,4.0835L5,22.4258V9.5742L16,3.1577,27,9.5742V22h2V9a1,1,0,0,0-.4961-.8638l-12-7a1,1,0,0,0-1.0078,0l-12,7A1,1,0,0,0,3,9V23a1,1,0,0,0,.4961.8638l12,7a1,1,0,0,0,1.0078,0L24,26.4907Z" } }], "name": "cloud-satellite", "size": 20 }, "size": 20 }, svg: `<svg focusable="false" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="20" height="20" viewBox="0 0 32 32" aria-hidden="true"><circle cx="9" cy="20" r="2"></circle><path d="M16,20a4,4,0,1,1,4-4A4.0118,4.0118,0,0,1,16,20Zm0-6a2,2,0,1,0,2,2A2.0059,2.0059,0,0,0,16,14Z"></path><circle cx="23" cy="12" r="2"></circle><path d="M23,24.7588l-7,4.0835L5,22.4258V9.5742L16,3.1577,27,9.5742V22h2V9a1,1,0,0,0-.4961-.8638l-12-7a1,1,0,0,0-1.0078,0l-12,7A1,1,0,0,0,3,9V23a1,1,0,0,0,.4961.8638l12,7a1,1,0,0,0,1.0078,0L24,26.4907Z"></path></svg>` }, "16": { metadata: { "moduleName": "CloudSatellite16", "filepath": "cloud-satellite/16.js", "descriptor": { "elem": "svg", "attrs": { "xmlns": "http://www.w3.org/2000/svg", "viewBox": "0 0 32 32", "fill": "currentColor", "width": 16, "height": 16 }, "content": [{ "elem": "circle", "attrs": { "cx": "9", "cy": "20", "r": "2" } }, { "elem": "path", "attrs": { "d": "M16,20a4,4,0,1,1,4-4A4.0118,4.0118,0,0,1,16,20Zm0-6a2,2,0,1,0,2,2A2.0059,2.0059,0,0,0,16,14Z" } }, { "elem": "circle", "attrs": { "cx": "23", "cy": "12", "r": "2" } }, { "elem": "path", "attrs": { "d": "M23,24.7588l-7,4.0835L5,22.4258V9.5742L16,3.1577,27,9.5742V22h2V9a1,1,0,0,0-.4961-.8638l-12-7a1,1,0,0,0-1.0078,0l-12,7A1,1,0,0,0,3,9V23a1,1,0,0,0,.4961.8638l12,7a1,1,0,0,0,1.0078,0L24,26.4907Z" } }], "name": "cloud-satellite", "size": 16 }, "size": 16 }, svg: `<svg focusable="false" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" fill="currentColor" width="16" height="16" viewBox="0 0 32 32" aria-hidden="true"><circle cx="9" cy="20" r="2"></circle><path d="M16,20a4,4,0,1,1,4-4A4.0118,4.0118,0,0,1,16,20Zm0-6a2,2,0,1,0,2,2A2.0059,2.0059,0,0,0,16,14Z"></path><circle cx="23" cy="12" r="2"></circle><path d="M23,24.7588l-7,4.0835L5,22.4258V9.5742L16,3.1577,27,9.5742V22h2V9a1,1,0,0,0-.4961-.8638l-12-7a1,1,0,0,0-1.0078,0l-12,7A1,1,0,0,0,3,9V23a1,1,0,0,0,.4961.8638l12,7a1,1,0,0,0,1.0078,0L24,26.4907Z"></path></svg>` }, }; } ngAfterViewInit() { const svg = this.elementRef.nativeElement; svg.setAttribute("xmlns", "http://www.w3.org/2000/svg"); const icon = this.icons[this.size]; const domParser = new DOMParser(); const rawSVG = icon.svg; const svgElement = domParser.parseFromString(rawSVG, "image/svg+xml").documentElement; let node = svgElement.firstChild; while (node) { // importNode makes a clone of the node // this ensures we keep looping over the nodes in the parsed document svg.appendChild(svg.ownerDocument.importNode(node, true)); node = node.nextSibling; } const attributes = getAttributes({ width: icon.metadata.descriptor.attrs.height, height: icon.metadata.descriptor.attrs.height, viewBox: icon.metadata.descriptor.attrs.viewBox, title: this.title, "aria-label": this.ariaLabel, "aria-labelledby": this.ariaLabelledby, "aria-hidden": this.ariaHidden, focusable: this.isFocusable.toString() }); const attrKeys = Object.keys(attributes); for (let i = 0; i < attrKeys.length; i++) { const key = attrKeys[i]; const value = attributes[key]; if (key === "title") { continue; } if (value) { svg.setAttribute(key, value); } } if (attributes.title) { const title = document.createElement("title"); title.textContent = attributes.title; CloudSatelliteDirective_1.titleIdCounter++; title.setAttribute("id", `cloud-satellite-${CloudSatelliteDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `cloud-satellite-${CloudSatelliteDirective_1.titleIdCounter}`); } } }; CloudSatelliteDirective.titleIdCounter = 0; CloudSatelliteDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], CloudSatelliteDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], CloudSatelliteDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CloudSatelliteDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], CloudSatelliteDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], CloudSatelliteDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], CloudSatelliteDirective.prototype, "size", void 0); CloudSatelliteDirective = CloudSatelliteDirective_1 = __decorate([ Directive({ selector: "[ibmIconCloudSatellite]" }), __metadata("design:paramtypes", [ElementRef]) ], CloudSatelliteDirective); let CloudSatelliteModule = class CloudSatelliteModule { }; CloudSatelliteModule = __decorate([ NgModule({ declarations: [ CloudSatelliteComponent, CloudSatelliteDirective, ], exports: [ CloudSatelliteComponent, CloudSatelliteDirective, ] }) ], CloudSatelliteModule); export { CloudSatelliteComponent, CloudSatelliteDirective, CloudSatelliteModule };