UNPKG

@carbon/icons-angular

Version:

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

169 lines (166 loc) 9.86 kB
import { __decorate, __metadata } from 'tslib'; import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core'; import { getAttributes } from '@carbon/icon-helpers'; var ListDropdownComponent = /** @class */ (function () { function ListDropdownComponent() { this.focusable = false; } __decorate([ Input(), __metadata("design:type", String) ], ListDropdownComponent.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ListDropdownComponent.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ListDropdownComponent.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ListDropdownComponent.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ListDropdownComponent.prototype, "focusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ListDropdownComponent.prototype, "innerClass", void 0); __decorate([ Input(), __metadata("design:type", String) ], ListDropdownComponent.prototype, "size", void 0); ListDropdownComponent = __decorate([ Component({ selector: "ibm-icon-list-dropdown", template: "\n <svg\n ibmIconListDropdown\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 " }) ], ListDropdownComponent); return ListDropdownComponent; }()); var ListDropdownDirective = /** @class */ (function () { function ListDropdownDirective(elementRef) { this.elementRef = elementRef; this.isFocusable = false; this.icons = { "32": { metadata: { "moduleName": "ListDropdown32", "filepath": "list--dropdown/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": "M26,6V2H2V12h9V30H30V6ZM4,10V4H24V6H11v4ZM28,28H13V8H28Z" } }, { "elem": "path", "attrs": { "d": "M15 11H17V13H15zM19 11H26V13H19zM15 17H17V19H15zM19 17H26V19H19zM15 23H17V25H15zM19 23H26V25H19z" } }], "name": "list--dropdown", "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=\"M26,6V2H2V12h9V30H30V6ZM4,10V4H24V6H11v4ZM28,28H13V8H28Z\"></path><path d=\"M15 11H17V13H15zM19 11H26V13H19zM15 17H17V19H15zM19 17H26V19H19zM15 23H17V25H15zM19 23H26V25H19z\"></path></svg>" }, "24": { metadata: { "moduleName": "ListDropdown24", "filepath": "list--dropdown/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": "M26,6V2H2V12h9V30H30V6ZM4,10V4H24V6H11v4ZM28,28H13V8H28Z" } }, { "elem": "path", "attrs": { "d": "M15 11H17V13H15zM19 11H26V13H19zM15 17H17V19H15zM19 17H26V19H19zM15 23H17V25H15zM19 23H26V25H19z" } }], "name": "list--dropdown", "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=\"M26,6V2H2V12h9V30H30V6ZM4,10V4H24V6H11v4ZM28,28H13V8H28Z\"></path><path d=\"M15 11H17V13H15zM19 11H26V13H19zM15 17H17V19H15zM19 17H26V19H19zM15 23H17V25H15zM19 23H26V25H19z\"></path></svg>" }, "20": { metadata: { "moduleName": "ListDropdown20", "filepath": "list--dropdown/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": "M26,6V2H2V12h9V30H30V6ZM4,10V4H24V6H11v4ZM28,28H13V8H28Z" } }, { "elem": "path", "attrs": { "d": "M15 11H17V13H15zM19 11H26V13H19zM15 17H17V19H15zM19 17H26V19H19zM15 23H17V25H15zM19 23H26V25H19z" } }], "name": "list--dropdown", "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=\"M26,6V2H2V12h9V30H30V6ZM4,10V4H24V6H11v4ZM28,28H13V8H28Z\"></path><path d=\"M15 11H17V13H15zM19 11H26V13H19zM15 17H17V19H15zM19 17H26V19H19zM15 23H17V25H15zM19 23H26V25H19z\"></path></svg>" }, "16": { metadata: { "moduleName": "ListDropdown16", "filepath": "list--dropdown/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": "M26,6V2H2V12h9V30H30V6ZM4,10V4H24V6H11v4ZM28,28H13V8H28Z" } }, { "elem": "path", "attrs": { "d": "M15 11H17V13H15zM19 11H26V13H19zM15 17H17V19H15zM19 17H26V19H19zM15 23H17V25H15zM19 23H26V25H19z" } }], "name": "list--dropdown", "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=\"M26,6V2H2V12h9V30H30V6ZM4,10V4H24V6H11v4ZM28,28H13V8H28Z\"></path><path d=\"M15 11H17V13H15zM19 11H26V13H19zM15 17H17V19H15zM19 17H26V19H19zM15 23H17V25H15zM19 23H26V25H19z\"></path></svg>" }, }; } ListDropdownDirective_1 = ListDropdownDirective; ListDropdownDirective.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; ListDropdownDirective_1.titleIdCounter++; title.setAttribute("id", "list-dropdown-" + ListDropdownDirective_1.titleIdCounter); svg.appendChild(title); svg.setAttribute("aria-labelledby", "list-dropdown-" + ListDropdownDirective_1.titleIdCounter); } }; var ListDropdownDirective_1; ListDropdownDirective.titleIdCounter = 0; ListDropdownDirective.ctorParameters = function () { return [ { type: ElementRef } ]; }; __decorate([ Input(), __metadata("design:type", String) ], ListDropdownDirective.prototype, "ariaLabel", void 0); __decorate([ Input(), __metadata("design:type", String) ], ListDropdownDirective.prototype, "ariaLabelledby", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ListDropdownDirective.prototype, "ariaHidden", void 0); __decorate([ Input(), __metadata("design:type", String) ], ListDropdownDirective.prototype, "title", void 0); __decorate([ Input(), __metadata("design:type", Boolean) ], ListDropdownDirective.prototype, "isFocusable", void 0); __decorate([ Input(), __metadata("design:type", String) ], ListDropdownDirective.prototype, "size", void 0); ListDropdownDirective = ListDropdownDirective_1 = __decorate([ Directive({ selector: "[ibmIconListDropdown]" }), __metadata("design:paramtypes", [ElementRef]) ], ListDropdownDirective); return ListDropdownDirective; }()); var ListDropdownModule = /** @class */ (function () { function ListDropdownModule() { } ListDropdownModule = __decorate([ NgModule({ declarations: [ ListDropdownComponent, ListDropdownDirective, ], exports: [ ListDropdownComponent, ListDropdownDirective, ] }) ], ListDropdownModule); return ListDropdownModule; }()); export { ListDropdownComponent, ListDropdownDirective, ListDropdownModule };