UNPKG

@carbon/icons-angular

Version:

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

174 lines (171 loc) 10.2 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var UserCertificationDirective_1; let UserCertificationComponent = class UserCertificationComponent { constructor() { this.focusable = false; } }; __decorate([ Input(), __metadata("design:type", String) ], UserCertificationComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], UserCertificationComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], UserCertificationComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], UserCertificationComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], UserCertificationComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], UserCertificationComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], UserCertificationComponent.prototype, "size", void 0); UserCertificationComponent = __decorate([ Component({ selector: "ibm-icon-user-certification", template: ` <svg ibmIconUserCertification [size]="size" [ariaLabel]="ariaLabel" [ariaLabelledby]="ariaLabelledby" [ariaHidden]="ariaHidden" [title]="title" [isFocusable]="focusable" [attr.class]="innerClass"> </svg> ` }) ], UserCertificationComponent); let UserCertificationDirective = UserCertificationDirective_1 = class UserCertificationDirective { constructor(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "UserCertification32", "filepath": "user--certification/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": "path", "attrs": { "d": "M25 10L26.593 13 30 13.414 27.5 15.667 28 19 25 17.125 22 19 22.5 15.667 20 13.414 23.5 13 25 10zM22 30H20V25a5.0059 5.0059 0 00-5-5H9a5.0059 5.0059 0 00-5 5v5H2V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM12 4A5 5 0 117 9a5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0012 2z" } }], "name": "user--certification", "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"><path d="M25 10L26.593 13 30 13.414 27.5 15.667 28 19 25 17.125 22 19 22.5 15.667 20 13.414 23.5 13 25 10zM22 30H20V25a5.0059 5.0059 0 00-5-5H9a5.0059 5.0059 0 00-5 5v5H2V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM12 4A5 5 0 117 9a5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0012 2z"></path></svg>` }, "24": { metadata: { "moduleName": "UserCertification24", "filepath": "user--certification/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": "path", "attrs": { "d": "M25 10L26.593 13 30 13.414 27.5 15.667 28 19 25 17.125 22 19 22.5 15.667 20 13.414 23.5 13 25 10zM22 30H20V25a5.0059 5.0059 0 00-5-5H9a5.0059 5.0059 0 00-5 5v5H2V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM12 4A5 5 0 117 9a5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0012 2z" } }], "name": "user--certification", "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"><path d="M25 10L26.593 13 30 13.414 27.5 15.667 28 19 25 17.125 22 19 22.5 15.667 20 13.414 23.5 13 25 10zM22 30H20V25a5.0059 5.0059 0 00-5-5H9a5.0059 5.0059 0 00-5 5v5H2V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM12 4A5 5 0 117 9a5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0012 2z"></path></svg>` }, "20": { metadata: { "moduleName": "UserCertification20", "filepath": "user--certification/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": "path", "attrs": { "d": "M25 10L26.593 13 30 13.414 27.5 15.667 28 19 25 17.125 22 19 22.5 15.667 20 13.414 23.5 13 25 10zM22 30H20V25a5.0059 5.0059 0 00-5-5H9a5.0059 5.0059 0 00-5 5v5H2V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM12 4A5 5 0 117 9a5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0012 2z" } }], "name": "user--certification", "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"><path d="M25 10L26.593 13 30 13.414 27.5 15.667 28 19 25 17.125 22 19 22.5 15.667 20 13.414 23.5 13 25 10zM22 30H20V25a5.0059 5.0059 0 00-5-5H9a5.0059 5.0059 0 00-5 5v5H2V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM12 4A5 5 0 117 9a5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0012 2z"></path></svg>` }, "16": { metadata: { "moduleName": "UserCertification16", "filepath": "user--certification/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": "path", "attrs": { "d": "M25 10L26.593 13 30 13.414 27.5 15.667 28 19 25 17.125 22 19 22.5 15.667 20 13.414 23.5 13 25 10zM22 30H20V25a5.0059 5.0059 0 00-5-5H9a5.0059 5.0059 0 00-5 5v5H2V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM12 4A5 5 0 117 9a5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0012 2z" } }], "name": "user--certification", "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"><path d="M25 10L26.593 13 30 13.414 27.5 15.667 28 19 25 17.125 22 19 22.5 15.667 20 13.414 23.5 13 25 10zM22 30H20V25a5.0059 5.0059 0 00-5-5H9a5.0059 5.0059 0 00-5 5v5H2V25a7.0082 7.0082 0 017-7h6a7.0082 7.0082 0 017 7zM12 4A5 5 0 117 9a5 5 0 015-5m0-2a7 7 0 107 7A7 7 0 0012 2z"></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; UserCertificationDirective_1.titleIdCounter++; title.setAttribute("id", `user-certification-${UserCertificationDirective_1.titleIdCounter}`); svg.appendChild(title); svg.setAttribute("aria-labelledby", `user-certification-${UserCertificationDirective_1.titleIdCounter}`); } } }; UserCertificationDirective.titleIdCounter = 0; UserCertificationDirective.ctorParameters = () => [ { type: ElementRef } ]; __decorate([ Input(), __metadata("design:type", String) ], UserCertificationDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], UserCertificationDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], UserCertificationDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], UserCertificationDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], UserCertificationDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], UserCertificationDirective.prototype, "size", void 0); UserCertificationDirective = UserCertificationDirective_1 = __decorate([ Directive({ selector: "[ibmIconUserCertification]" }), __metadata("design:paramtypes", [ElementRef]) ], UserCertificationDirective); let UserCertificationModule = class UserCertificationModule { }; UserCertificationModule = __decorate([ NgModule({ declarations: [ UserCertificationComponent, UserCertificationDirective, ], exports: [ UserCertificationComponent, UserCertificationDirective, ] }) ], UserCertificationModule); export { UserCertificationComponent, UserCertificationDirective, UserCertificationModule };