UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 12.3 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var DropPhotoComponent = /** @class */ (function () { function DropPhotoComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], DropPhotoComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], DropPhotoComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DropPhotoComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], DropPhotoComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DropPhotoComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], DropPhotoComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], DropPhotoComponent.prototype, "size", void 0); DropPhotoComponent = __decorate([ Component({ selector: "ibm-icon-drop-photo", template: "\n <svg\n ibmIconDropPhoto\n [size]=\"size\"\n [ariaLabel]=\"ariaLabel\"\n [ariaLabelledby]=\"ariaLabelledby\"\n [ariaHidden]=\"ariaHidden\"\n [title]=\"title\"\n [isFocusable]=\"focusable\"\n [attr.class]=\"innerClass\">\n </svg>\n " }) ], DropPhotoComponent); return DropPhotoComponent; }()); var DropPhotoDirective = /** @class */ (function () { function DropPhotoDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "DropPhoto32", "filepath": "drop-photo/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": "M19,26a4,4,0,1,1,4-4A4.0045,4.0045,0,0,1,19,26Zm0-6a2,2,0,1,0,2,2A2.0021,2.0021,0,0,0,19,20Z" } }, { "elem": "path", "attrs": { "d": "M27 29H11a2 2 0 01-2-2V18a2 2 0 012-2h3.2793l.5441-1.6324A2 2 0 0116.7208 13h4.5584a2 2 0 011.8974 1.3676L23.7207 16H27a2 2 0 012 2v9A2 2 0 0127 29zM11 27H27V18H22.2792l-1-3H16.7207l-1 3H11zM27 11H29V13H27zM27 7H29V9H27zM27 3H29V5H27zM23 3H25V5H23zM19 3H21V5H19zM15 3H17V5H15zM11 3H13V5H11zM7 3H9V5H7zM3 3H5V5H3zM3 7H5V9H3zM3 11H5V13H3zM3 15H5V17H3zM3 19H5V21H3zM3 23H5V25H3zM3 27H5V29H3z" } }], "name": "drop-photo", "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=\"M19,26a4,4,0,1,1,4-4A4.0045,4.0045,0,0,1,19,26Zm0-6a2,2,0,1,0,2,2A2.0021,2.0021,0,0,0,19,20Z\"></path><path d=\"M27 29H11a2 2 0 01-2-2V18a2 2 0 012-2h3.2793l.5441-1.6324A2 2 0 0116.7208 13h4.5584a2 2 0 011.8974 1.3676L23.7207 16H27a2 2 0 012 2v9A2 2 0 0127 29zM11 27H27V18H22.2792l-1-3H16.7207l-1 3H11zM27 11H29V13H27zM27 7H29V9H27zM27 3H29V5H27zM23 3H25V5H23zM19 3H21V5H19zM15 3H17V5H15zM11 3H13V5H11zM7 3H9V5H7zM3 3H5V5H3zM3 7H5V9H3zM3 11H5V13H3zM3 15H5V17H3zM3 19H5V21H3zM3 23H5V25H3zM3 27H5V29H3z\"></path></svg>" }, "24": { metadata: { "moduleName": "DropPhoto24", "filepath": "drop-photo/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": "M19,26a4,4,0,1,1,4-4A4.0045,4.0045,0,0,1,19,26Zm0-6a2,2,0,1,0,2,2A2.0021,2.0021,0,0,0,19,20Z" } }, { "elem": "path", "attrs": { "d": "M27 29H11a2 2 0 01-2-2V18a2 2 0 012-2h3.2793l.5441-1.6324A2 2 0 0116.7208 13h4.5584a2 2 0 011.8974 1.3676L23.7207 16H27a2 2 0 012 2v9A2 2 0 0127 29zM11 27H27V18H22.2792l-1-3H16.7207l-1 3H11zM27 11H29V13H27zM27 7H29V9H27zM27 3H29V5H27zM23 3H25V5H23zM19 3H21V5H19zM15 3H17V5H15zM11 3H13V5H11zM7 3H9V5H7zM3 3H5V5H3zM3 7H5V9H3zM3 11H5V13H3zM3 15H5V17H3zM3 19H5V21H3zM3 23H5V25H3zM3 27H5V29H3z" } }], "name": "drop-photo", "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=\"M19,26a4,4,0,1,1,4-4A4.0045,4.0045,0,0,1,19,26Zm0-6a2,2,0,1,0,2,2A2.0021,2.0021,0,0,0,19,20Z\"></path><path d=\"M27 29H11a2 2 0 01-2-2V18a2 2 0 012-2h3.2793l.5441-1.6324A2 2 0 0116.7208 13h4.5584a2 2 0 011.8974 1.3676L23.7207 16H27a2 2 0 012 2v9A2 2 0 0127 29zM11 27H27V18H22.2792l-1-3H16.7207l-1 3H11zM27 11H29V13H27zM27 7H29V9H27zM27 3H29V5H27zM23 3H25V5H23zM19 3H21V5H19zM15 3H17V5H15zM11 3H13V5H11zM7 3H9V5H7zM3 3H5V5H3zM3 7H5V9H3zM3 11H5V13H3zM3 15H5V17H3zM3 19H5V21H3zM3 23H5V25H3zM3 27H5V29H3z\"></path></svg>" }, "20": { metadata: { "moduleName": "DropPhoto20", "filepath": "drop-photo/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": "M19,26a4,4,0,1,1,4-4A4.0045,4.0045,0,0,1,19,26Zm0-6a2,2,0,1,0,2,2A2.0021,2.0021,0,0,0,19,20Z" } }, { "elem": "path", "attrs": { "d": "M27 29H11a2 2 0 01-2-2V18a2 2 0 012-2h3.2793l.5441-1.6324A2 2 0 0116.7208 13h4.5584a2 2 0 011.8974 1.3676L23.7207 16H27a2 2 0 012 2v9A2 2 0 0127 29zM11 27H27V18H22.2792l-1-3H16.7207l-1 3H11zM27 11H29V13H27zM27 7H29V9H27zM27 3H29V5H27zM23 3H25V5H23zM19 3H21V5H19zM15 3H17V5H15zM11 3H13V5H11zM7 3H9V5H7zM3 3H5V5H3zM3 7H5V9H3zM3 11H5V13H3zM3 15H5V17H3zM3 19H5V21H3zM3 23H5V25H3zM3 27H5V29H3z" } }], "name": "drop-photo", "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=\"M19,26a4,4,0,1,1,4-4A4.0045,4.0045,0,0,1,19,26Zm0-6a2,2,0,1,0,2,2A2.0021,2.0021,0,0,0,19,20Z\"></path><path d=\"M27 29H11a2 2 0 01-2-2V18a2 2 0 012-2h3.2793l.5441-1.6324A2 2 0 0116.7208 13h4.5584a2 2 0 011.8974 1.3676L23.7207 16H27a2 2 0 012 2v9A2 2 0 0127 29zM11 27H27V18H22.2792l-1-3H16.7207l-1 3H11zM27 11H29V13H27zM27 7H29V9H27zM27 3H29V5H27zM23 3H25V5H23zM19 3H21V5H19zM15 3H17V5H15zM11 3H13V5H11zM7 3H9V5H7zM3 3H5V5H3zM3 7H5V9H3zM3 11H5V13H3zM3 15H5V17H3zM3 19H5V21H3zM3 23H5V25H3zM3 27H5V29H3z\"></path></svg>" }, "16": { metadata: { "moduleName": "DropPhoto16", "filepath": "drop-photo/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": "M19,26a4,4,0,1,1,4-4A4.0045,4.0045,0,0,1,19,26Zm0-6a2,2,0,1,0,2,2A2.0021,2.0021,0,0,0,19,20Z" } }, { "elem": "path", "attrs": { "d": "M27 29H11a2 2 0 01-2-2V18a2 2 0 012-2h3.2793l.5441-1.6324A2 2 0 0116.7208 13h4.5584a2 2 0 011.8974 1.3676L23.7207 16H27a2 2 0 012 2v9A2 2 0 0127 29zM11 27H27V18H22.2792l-1-3H16.7207l-1 3H11zM27 11H29V13H27zM27 7H29V9H27zM27 3H29V5H27zM23 3H25V5H23zM19 3H21V5H19zM15 3H17V5H15zM11 3H13V5H11zM7 3H9V5H7zM3 3H5V5H3zM3 7H5V9H3zM3 11H5V13H3zM3 15H5V17H3zM3 19H5V21H3zM3 23H5V25H3zM3 27H5V29H3z" } }], "name": "drop-photo", "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=\"M19,26a4,4,0,1,1,4-4A4.0045,4.0045,0,0,1,19,26Zm0-6a2,2,0,1,0,2,2A2.0021,2.0021,0,0,0,19,20Z\"></path><path d=\"M27 29H11a2 2 0 01-2-2V18a2 2 0 012-2h3.2793l.5441-1.6324A2 2 0 0116.7208 13h4.5584a2 2 0 011.8974 1.3676L23.7207 16H27a2 2 0 012 2v9A2 2 0 0127 29zM11 27H27V18H22.2792l-1-3H16.7207l-1 3H11zM27 11H29V13H27zM27 7H29V9H27zM27 3H29V5H27zM23 3H25V5H23zM19 3H21V5H19zM15 3H17V5H15zM11 3H13V5H11zM7 3H9V5H7zM3 3H5V5H3zM3 7H5V9H3zM3 11H5V13H3zM3 15H5V17H3zM3 19H5V21H3zM3 23H5V25H3zM3 27H5V29H3z\"></path></svg>" }, }; } DropPhotoDirective_1 = DropPhotoDirective; DropPhotoDirective.prototype.ngAfterViewInit = function () { var svg = this.elementRef.nativeElement; svg.setAttribute("xmlns", "http://www.w3.org/2000/svg"); var icon = this.icons[this.size]; var domParser = new DOMParser(); var rawSVG = icon.svg; var svgElement = domParser.parseFromString(rawSVG, "image/svg+xml").documentElement; var 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; } var 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() }); var attrKeys = Object.keys(attributes); for (var i = 0; i < attrKeys.length; i++) { var key = attrKeys[i]; var value = attributes[key]; if (key === "title") { continue; } if (value) { svg.setAttribute(key, value); } } if (attributes.title) { var title = document.createElement("title"); title.textContent = attributes.title; DropPhotoDirective_1.titleIdCounter++; title.setAttribute("id", "drop-photo-" + DropPhotoDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "drop-photo-" + DropPhotoDirective_1.titleIdCounter); } }; var DropPhotoDirective_1; DropPhotoDirective.titleIdCounter = 0; DropPhotoDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], DropPhotoDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], DropPhotoDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DropPhotoDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], DropPhotoDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], DropPhotoDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], DropPhotoDirective.prototype, "size", void 0); DropPhotoDirective = DropPhotoDirective_1 = __decorate([ Directive({ selector: "[ibmIconDropPhoto]" }), __metadata("design:paramtypes", [ElementRef]) ], DropPhotoDirective); return DropPhotoDirective; }()); var DropPhotoModule = /** @class */ (function () { function DropPhotoModule() { } DropPhotoModule = __decorate([ NgModule({ declarations: [ DropPhotoComponent, DropPhotoDirective, ], exports: [ DropPhotoComponent, DropPhotoDirective, ] }) ], DropPhotoModule); return DropPhotoModule; }()); export { DropPhotoComponent, DropPhotoDirective, DropPhotoModule };