@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
169 lines (166 loc) • 11.6 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var NotificationNewComponent = /** @class */ (function () {
function NotificationNewComponent() {
this.focusable = false;
}
__decorate([
Input(),
__metadata("design:type", String)
], NotificationNewComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], NotificationNewComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], NotificationNewComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], NotificationNewComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], NotificationNewComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], NotificationNewComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], NotificationNewComponent.prototype, "size", void 0);
NotificationNewComponent = __decorate([
Component({
selector: "ibm-icon-notification-new",
template: "\n <svg\n ibmIconNotificationNew\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 "
})
], NotificationNewComponent);
return NotificationNewComponent;
}());
var NotificationNewDirective = /** @class */ (function () {
function NotificationNewDirective(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "NotificationNew32", "filepath": "notification--new/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,17.6V15H24v3a.91.91,0,0,0,.3.7L27,21.4V23H5V21.4l2.7-2.7A.91.91,0,0,0,8,18V13a8,8,0,0,1,8-8,7.89,7.89,0,0,1,4,1.09V3.8A9.71,9.71,0,0,0,17,3V1H15V3A10.15,10.15,0,0,0,6,13v4.6L3.3,20.3A.91.91,0,0,0,3,21v3a.94.94,0,0,0,1,1h7a5,5,0,0,0,10,0h7a.94.94,0,0,0,1-1V21a.91.91,0,0,0-.3-.7ZM16,28a3,3,0,0,1-3-3h6A3,3,0,0,1,16,28Z" } }, { "elem": "circle", "attrs": { "cx": "26", "cy": "8", "r": "4" } }], "name": "notification--new", "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,17.6V15H24v3a.91.91,0,0,0,.3.7L27,21.4V23H5V21.4l2.7-2.7A.91.91,0,0,0,8,18V13a8,8,0,0,1,8-8,7.89,7.89,0,0,1,4,1.09V3.8A9.71,9.71,0,0,0,17,3V1H15V3A10.15,10.15,0,0,0,6,13v4.6L3.3,20.3A.91.91,0,0,0,3,21v3a.94.94,0,0,0,1,1h7a5,5,0,0,0,10,0h7a.94.94,0,0,0,1-1V21a.91.91,0,0,0-.3-.7ZM16,28a3,3,0,0,1-3-3h6A3,3,0,0,1,16,28Z\"></path><circle cx=\"26\" cy=\"8\" r=\"4\"></circle></svg>"
},
"24": {
metadata: { "moduleName": "NotificationNew24", "filepath": "notification--new/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,17.6V15H24v3a.91.91,0,0,0,.3.7L27,21.4V23H5V21.4l2.7-2.7A.91.91,0,0,0,8,18V13a8,8,0,0,1,8-8,7.89,7.89,0,0,1,4,1.09V3.8A9.71,9.71,0,0,0,17,3V1H15V3A10.15,10.15,0,0,0,6,13v4.6L3.3,20.3A.91.91,0,0,0,3,21v3a.94.94,0,0,0,1,1h7a5,5,0,0,0,10,0h7a.94.94,0,0,0,1-1V21a.91.91,0,0,0-.3-.7ZM16,28a3,3,0,0,1-3-3h6A3,3,0,0,1,16,28Z" } }, { "elem": "circle", "attrs": { "cx": "26", "cy": "8", "r": "4" } }], "name": "notification--new", "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,17.6V15H24v3a.91.91,0,0,0,.3.7L27,21.4V23H5V21.4l2.7-2.7A.91.91,0,0,0,8,18V13a8,8,0,0,1,8-8,7.89,7.89,0,0,1,4,1.09V3.8A9.71,9.71,0,0,0,17,3V1H15V3A10.15,10.15,0,0,0,6,13v4.6L3.3,20.3A.91.91,0,0,0,3,21v3a.94.94,0,0,0,1,1h7a5,5,0,0,0,10,0h7a.94.94,0,0,0,1-1V21a.91.91,0,0,0-.3-.7ZM16,28a3,3,0,0,1-3-3h6A3,3,0,0,1,16,28Z\"></path><circle cx=\"26\" cy=\"8\" r=\"4\"></circle></svg>"
},
"20": {
metadata: { "moduleName": "NotificationNew20", "filepath": "notification--new/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,17.6V15H24v3a.91.91,0,0,0,.3.7L27,21.4V23H5V21.4l2.7-2.7A.91.91,0,0,0,8,18V13a8,8,0,0,1,8-8,7.89,7.89,0,0,1,4,1.09V3.8A9.71,9.71,0,0,0,17,3V1H15V3A10.15,10.15,0,0,0,6,13v4.6L3.3,20.3A.91.91,0,0,0,3,21v3a.94.94,0,0,0,1,1h7a5,5,0,0,0,10,0h7a.94.94,0,0,0,1-1V21a.91.91,0,0,0-.3-.7ZM16,28a3,3,0,0,1-3-3h6A3,3,0,0,1,16,28Z" } }, { "elem": "circle", "attrs": { "cx": "26", "cy": "8", "r": "4" } }], "name": "notification--new", "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,17.6V15H24v3a.91.91,0,0,0,.3.7L27,21.4V23H5V21.4l2.7-2.7A.91.91,0,0,0,8,18V13a8,8,0,0,1,8-8,7.89,7.89,0,0,1,4,1.09V3.8A9.71,9.71,0,0,0,17,3V1H15V3A10.15,10.15,0,0,0,6,13v4.6L3.3,20.3A.91.91,0,0,0,3,21v3a.94.94,0,0,0,1,1h7a5,5,0,0,0,10,0h7a.94.94,0,0,0,1-1V21a.91.91,0,0,0-.3-.7ZM16,28a3,3,0,0,1-3-3h6A3,3,0,0,1,16,28Z\"></path><circle cx=\"26\" cy=\"8\" r=\"4\"></circle></svg>"
},
"16": {
metadata: { "moduleName": "NotificationNew16", "filepath": "notification--new/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,17.6V15H24v3a.91.91,0,0,0,.3.7L27,21.4V23H5V21.4l2.7-2.7A.91.91,0,0,0,8,18V13a8,8,0,0,1,8-8,7.89,7.89,0,0,1,4,1.09V3.8A9.71,9.71,0,0,0,17,3V1H15V3A10.15,10.15,0,0,0,6,13v4.6L3.3,20.3A.91.91,0,0,0,3,21v3a.94.94,0,0,0,1,1h7a5,5,0,0,0,10,0h7a.94.94,0,0,0,1-1V21a.91.91,0,0,0-.3-.7ZM16,28a3,3,0,0,1-3-3h6A3,3,0,0,1,16,28Z" } }, { "elem": "circle", "attrs": { "cx": "26", "cy": "8", "r": "4" } }], "name": "notification--new", "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,17.6V15H24v3a.91.91,0,0,0,.3.7L27,21.4V23H5V21.4l2.7-2.7A.91.91,0,0,0,8,18V13a8,8,0,0,1,8-8,7.89,7.89,0,0,1,4,1.09V3.8A9.71,9.71,0,0,0,17,3V1H15V3A10.15,10.15,0,0,0,6,13v4.6L3.3,20.3A.91.91,0,0,0,3,21v3a.94.94,0,0,0,1,1h7a5,5,0,0,0,10,0h7a.94.94,0,0,0,1-1V21a.91.91,0,0,0-.3-.7ZM16,28a3,3,0,0,1-3-3h6A3,3,0,0,1,16,28Z\"></path><circle cx=\"26\" cy=\"8\" r=\"4\"></circle></svg>"
},
};
}
NotificationNewDirective_1 = NotificationNewDirective;
NotificationNewDirective.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;
NotificationNewDirective_1.titleIdCounter++;
title.setAttribute("id", "notification-new-" + NotificationNewDirective_1.titleIdCounter);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", "notification-new-" + NotificationNewDirective_1.titleIdCounter);
}
};
var NotificationNewDirective_1;
NotificationNewDirective.titleIdCounter = 0;
NotificationNewDirective.ctorParameters = function () { return [
{ type: ElementRef }
]; };
__decorate([
Input(),
__metadata("design:type", String)
], NotificationNewDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], NotificationNewDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], NotificationNewDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], NotificationNewDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], NotificationNewDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], NotificationNewDirective.prototype, "size", void 0);
NotificationNewDirective = NotificationNewDirective_1 = __decorate([
Directive({
selector: "[ibmIconNotificationNew]"
}),
__metadata("design:paramtypes", [ElementRef])
], NotificationNewDirective);
return NotificationNewDirective;
}());
var NotificationNewModule = /** @class */ (function () {
function NotificationNewModule() {
}
NotificationNewModule = __decorate([
NgModule({
declarations: [
NotificationNewComponent,
NotificationNewDirective,
],
exports: [
NotificationNewComponent,
NotificationNewDirective,
]
})
], NotificationNewModule);
return NotificationNewModule;
}());
export { NotificationNewComponent, NotificationNewDirective, NotificationNewModule };