@carbon/icons-angular
Version:
Angular components for icons in digital and software products using the Carbon Design System
169 lines (166 loc) • 14.8 kB
JavaScript
import { __decorate, __metadata } from 'tslib';
import { Input, Component, ElementRef, Directive, NgModule } from '@angular/core';
import { getAttributes } from '@carbon/icon-helpers';
var IbmCloudComponent = /** @class */ (function () {
function IbmCloudComponent() {
this.focusable = false;
}
__decorate([
Input(),
__metadata("design:type", String)
], IbmCloudComponent.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], IbmCloudComponent.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], IbmCloudComponent.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], IbmCloudComponent.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], IbmCloudComponent.prototype, "focusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], IbmCloudComponent.prototype, "innerClass", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], IbmCloudComponent.prototype, "size", void 0);
IbmCloudComponent = __decorate([
Component({
selector: "ibm-icon-ibm-cloud",
template: "\n <svg\n ibmIconIbmCloud\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 "
})
], IbmCloudComponent);
return IbmCloudComponent;
}());
var IbmCloudDirective = /** @class */ (function () {
function IbmCloudDirective(elementRef) {
this.elementRef = elementRef;
this.isFocusable = false;
this.icons = {
"32": {
metadata: { "moduleName": "IbmCloud32", "filepath": "ibm-cloud/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": "M24.5805 13.65A9.7327 9.7327 0 006.286 17.5387 6.75 6.75 0 007 31H23a8.7465 8.7465 0 001.5805-17.35zM23 29.5H7a5.2373 5.2373 0 01-.6993-10.4293 9.7265 9.7265 0 001.1036 3.7838.75.75 0 101.3213-.709A8.25 8.25 0 0122.752 13.5133a8.754 8.754 0 00-6.315 2.95.75.75 0 101.1245.9922A7.25 7.25 0 1123 29.5zM31.8983 10.2548a.7582.7582 0 00-1.0364-.2776l-3.02 1.7438A.7587.7587 0 1028.6 13.035l3.02-1.7438A.7589.7589 0 0031.8983 10.2548zM22.6764 7.87a.7583.7583 0 001.0364-.2776l1.7438-3.02a.7587.7587 0 00-1.314-.7588l-1.7438 3.02A.7588.7588 0 0022.6764 7.87zM16 6.0811a.759.759 0 00.7588-.7588V1.8347a.7588.7588 0 10-1.5175 0V5.3223A.7589.7589 0 0016 6.0811zM8.2873 7.5922a.7587.7587 0 001.314-.7588l-1.7438-3.02a.7587.7587 0 10-1.314.7588zM4.1585 11.721l-3.02-1.7438a.7587.7587 0 10-.7588 1.314L3.4 13.035a.7587.7587 0 10.7588-1.314z" } }], "name": "ibm-cloud", "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=\"M24.5805 13.65A9.7327 9.7327 0 006.286 17.5387 6.75 6.75 0 007 31H23a8.7465 8.7465 0 001.5805-17.35zM23 29.5H7a5.2373 5.2373 0 01-.6993-10.4293 9.7265 9.7265 0 001.1036 3.7838.75.75 0 101.3213-.709A8.25 8.25 0 0122.752 13.5133a8.754 8.754 0 00-6.315 2.95.75.75 0 101.1245.9922A7.25 7.25 0 1123 29.5zM31.8983 10.2548a.7582.7582 0 00-1.0364-.2776l-3.02 1.7438A.7587.7587 0 1028.6 13.035l3.02-1.7438A.7589.7589 0 0031.8983 10.2548zM22.6764 7.87a.7583.7583 0 001.0364-.2776l1.7438-3.02a.7587.7587 0 00-1.314-.7588l-1.7438 3.02A.7588.7588 0 0022.6764 7.87zM16 6.0811a.759.759 0 00.7588-.7588V1.8347a.7588.7588 0 10-1.5175 0V5.3223A.7589.7589 0 0016 6.0811zM8.2873 7.5922a.7587.7587 0 001.314-.7588l-1.7438-3.02a.7587.7587 0 10-1.314.7588zM4.1585 11.721l-3.02-1.7438a.7587.7587 0 10-.7588 1.314L3.4 13.035a.7587.7587 0 10.7588-1.314z\"></path></svg>"
},
"24": {
metadata: { "moduleName": "IbmCloud24", "filepath": "ibm-cloud/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": "M24.5805 13.65A9.7327 9.7327 0 006.286 17.5387 6.75 6.75 0 007 31H23a8.7465 8.7465 0 001.5805-17.35zM23 29.5H7a5.2373 5.2373 0 01-.6993-10.4293 9.7265 9.7265 0 001.1036 3.7838.75.75 0 101.3213-.709A8.25 8.25 0 0122.752 13.5133a8.754 8.754 0 00-6.315 2.95.75.75 0 101.1245.9922A7.25 7.25 0 1123 29.5zM31.8983 10.2548a.7582.7582 0 00-1.0364-.2776l-3.02 1.7438A.7587.7587 0 1028.6 13.035l3.02-1.7438A.7589.7589 0 0031.8983 10.2548zM22.6764 7.87a.7583.7583 0 001.0364-.2776l1.7438-3.02a.7587.7587 0 00-1.314-.7588l-1.7438 3.02A.7588.7588 0 0022.6764 7.87zM16 6.0811a.759.759 0 00.7588-.7588V1.8347a.7588.7588 0 10-1.5175 0V5.3223A.7589.7589 0 0016 6.0811zM8.2873 7.5922a.7587.7587 0 001.314-.7588l-1.7438-3.02a.7587.7587 0 10-1.314.7588zM4.1585 11.721l-3.02-1.7438a.7587.7587 0 10-.7588 1.314L3.4 13.035a.7587.7587 0 10.7588-1.314z" } }], "name": "ibm-cloud", "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=\"M24.5805 13.65A9.7327 9.7327 0 006.286 17.5387 6.75 6.75 0 007 31H23a8.7465 8.7465 0 001.5805-17.35zM23 29.5H7a5.2373 5.2373 0 01-.6993-10.4293 9.7265 9.7265 0 001.1036 3.7838.75.75 0 101.3213-.709A8.25 8.25 0 0122.752 13.5133a8.754 8.754 0 00-6.315 2.95.75.75 0 101.1245.9922A7.25 7.25 0 1123 29.5zM31.8983 10.2548a.7582.7582 0 00-1.0364-.2776l-3.02 1.7438A.7587.7587 0 1028.6 13.035l3.02-1.7438A.7589.7589 0 0031.8983 10.2548zM22.6764 7.87a.7583.7583 0 001.0364-.2776l1.7438-3.02a.7587.7587 0 00-1.314-.7588l-1.7438 3.02A.7588.7588 0 0022.6764 7.87zM16 6.0811a.759.759 0 00.7588-.7588V1.8347a.7588.7588 0 10-1.5175 0V5.3223A.7589.7589 0 0016 6.0811zM8.2873 7.5922a.7587.7587 0 001.314-.7588l-1.7438-3.02a.7587.7587 0 10-1.314.7588zM4.1585 11.721l-3.02-1.7438a.7587.7587 0 10-.7588 1.314L3.4 13.035a.7587.7587 0 10.7588-1.314z\"></path></svg>"
},
"20": {
metadata: { "moduleName": "IbmCloud20", "filepath": "ibm-cloud/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": "M24.5805 13.65A9.7327 9.7327 0 006.286 17.5387 6.75 6.75 0 007 31H23a8.7465 8.7465 0 001.5805-17.35zM23 29.5H7a5.2373 5.2373 0 01-.6993-10.4293 9.7265 9.7265 0 001.1036 3.7838.75.75 0 101.3213-.709A8.25 8.25 0 0122.752 13.5133a8.754 8.754 0 00-6.315 2.95.75.75 0 101.1245.9922A7.25 7.25 0 1123 29.5zM31.8983 10.2548a.7582.7582 0 00-1.0364-.2776l-3.02 1.7438A.7587.7587 0 1028.6 13.035l3.02-1.7438A.7589.7589 0 0031.8983 10.2548zM22.6764 7.87a.7583.7583 0 001.0364-.2776l1.7438-3.02a.7587.7587 0 00-1.314-.7588l-1.7438 3.02A.7588.7588 0 0022.6764 7.87zM16 6.0811a.759.759 0 00.7588-.7588V1.8347a.7588.7588 0 10-1.5175 0V5.3223A.7589.7589 0 0016 6.0811zM8.2873 7.5922a.7587.7587 0 001.314-.7588l-1.7438-3.02a.7587.7587 0 10-1.314.7588zM4.1585 11.721l-3.02-1.7438a.7587.7587 0 10-.7588 1.314L3.4 13.035a.7587.7587 0 10.7588-1.314z" } }], "name": "ibm-cloud", "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=\"M24.5805 13.65A9.7327 9.7327 0 006.286 17.5387 6.75 6.75 0 007 31H23a8.7465 8.7465 0 001.5805-17.35zM23 29.5H7a5.2373 5.2373 0 01-.6993-10.4293 9.7265 9.7265 0 001.1036 3.7838.75.75 0 101.3213-.709A8.25 8.25 0 0122.752 13.5133a8.754 8.754 0 00-6.315 2.95.75.75 0 101.1245.9922A7.25 7.25 0 1123 29.5zM31.8983 10.2548a.7582.7582 0 00-1.0364-.2776l-3.02 1.7438A.7587.7587 0 1028.6 13.035l3.02-1.7438A.7589.7589 0 0031.8983 10.2548zM22.6764 7.87a.7583.7583 0 001.0364-.2776l1.7438-3.02a.7587.7587 0 00-1.314-.7588l-1.7438 3.02A.7588.7588 0 0022.6764 7.87zM16 6.0811a.759.759 0 00.7588-.7588V1.8347a.7588.7588 0 10-1.5175 0V5.3223A.7589.7589 0 0016 6.0811zM8.2873 7.5922a.7587.7587 0 001.314-.7588l-1.7438-3.02a.7587.7587 0 10-1.314.7588zM4.1585 11.721l-3.02-1.7438a.7587.7587 0 10-.7588 1.314L3.4 13.035a.7587.7587 0 10.7588-1.314z\"></path></svg>"
},
"16": {
metadata: { "moduleName": "IbmCloud16", "filepath": "ibm-cloud/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": "M24.5805 13.65A9.7327 9.7327 0 006.286 17.5387 6.75 6.75 0 007 31H23a8.7465 8.7465 0 001.5805-17.35zM23 29.5H7a5.2373 5.2373 0 01-.6993-10.4293 9.7265 9.7265 0 001.1036 3.7838.75.75 0 101.3213-.709A8.25 8.25 0 0122.752 13.5133a8.754 8.754 0 00-6.315 2.95.75.75 0 101.1245.9922A7.25 7.25 0 1123 29.5zM31.8983 10.2548a.7582.7582 0 00-1.0364-.2776l-3.02 1.7438A.7587.7587 0 1028.6 13.035l3.02-1.7438A.7589.7589 0 0031.8983 10.2548zM22.6764 7.87a.7583.7583 0 001.0364-.2776l1.7438-3.02a.7587.7587 0 00-1.314-.7588l-1.7438 3.02A.7588.7588 0 0022.6764 7.87zM16 6.0811a.759.759 0 00.7588-.7588V1.8347a.7588.7588 0 10-1.5175 0V5.3223A.7589.7589 0 0016 6.0811zM8.2873 7.5922a.7587.7587 0 001.314-.7588l-1.7438-3.02a.7587.7587 0 10-1.314.7588zM4.1585 11.721l-3.02-1.7438a.7587.7587 0 10-.7588 1.314L3.4 13.035a.7587.7587 0 10.7588-1.314z" } }], "name": "ibm-cloud", "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=\"M24.5805 13.65A9.7327 9.7327 0 006.286 17.5387 6.75 6.75 0 007 31H23a8.7465 8.7465 0 001.5805-17.35zM23 29.5H7a5.2373 5.2373 0 01-.6993-10.4293 9.7265 9.7265 0 001.1036 3.7838.75.75 0 101.3213-.709A8.25 8.25 0 0122.752 13.5133a8.754 8.754 0 00-6.315 2.95.75.75 0 101.1245.9922A7.25 7.25 0 1123 29.5zM31.8983 10.2548a.7582.7582 0 00-1.0364-.2776l-3.02 1.7438A.7587.7587 0 1028.6 13.035l3.02-1.7438A.7589.7589 0 0031.8983 10.2548zM22.6764 7.87a.7583.7583 0 001.0364-.2776l1.7438-3.02a.7587.7587 0 00-1.314-.7588l-1.7438 3.02A.7588.7588 0 0022.6764 7.87zM16 6.0811a.759.759 0 00.7588-.7588V1.8347a.7588.7588 0 10-1.5175 0V5.3223A.7589.7589 0 0016 6.0811zM8.2873 7.5922a.7587.7587 0 001.314-.7588l-1.7438-3.02a.7587.7587 0 10-1.314.7588zM4.1585 11.721l-3.02-1.7438a.7587.7587 0 10-.7588 1.314L3.4 13.035a.7587.7587 0 10.7588-1.314z\"></path></svg>"
},
};
}
IbmCloudDirective_1 = IbmCloudDirective;
IbmCloudDirective.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;
IbmCloudDirective_1.titleIdCounter++;
title.setAttribute("id", "ibm-cloud-" + IbmCloudDirective_1.titleIdCounter);
svg.appendChild(title);
svg.setAttribute("aria-labelledby", "ibm-cloud-" + IbmCloudDirective_1.titleIdCounter);
}
};
var IbmCloudDirective_1;
IbmCloudDirective.titleIdCounter = 0;
IbmCloudDirective.ctorParameters = function () { return [
{ type: ElementRef }
]; };
__decorate([
Input(),
__metadata("design:type", String)
], IbmCloudDirective.prototype, "ariaLabel", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], IbmCloudDirective.prototype, "ariaLabelledby", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], IbmCloudDirective.prototype, "ariaHidden", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], IbmCloudDirective.prototype, "title", void 0);
__decorate([
Input(),
__metadata("design:type", Boolean)
], IbmCloudDirective.prototype, "isFocusable", void 0);
__decorate([
Input(),
__metadata("design:type", String)
], IbmCloudDirective.prototype, "size", void 0);
IbmCloudDirective = IbmCloudDirective_1 = __decorate([
Directive({
selector: "[ibmIconIbmCloud]"
}),
__metadata("design:paramtypes", [ElementRef])
], IbmCloudDirective);
return IbmCloudDirective;
}());
var IbmCloudModule = /** @class */ (function () {
function IbmCloudModule() {
}
IbmCloudModule = __decorate([
NgModule({
declarations: [
IbmCloudComponent,
IbmCloudDirective,
],
exports: [
IbmCloudComponent,
IbmCloudDirective,
]
})
], IbmCloudModule);
return IbmCloudModule;
}());
export { IbmCloudComponent, IbmCloudDirective, IbmCloudModule };