1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 | import { __assign, __extends, __rest } from "tslib";
|
17 | import classNames from "classnames";
|
18 | import * as React from "react";
|
19 | import { iconNameToPathsRecordKey, IconSvgPaths16, IconSvgPaths20 } from "@blueprintjs/icons";
|
20 | import { AbstractPureComponent2, Classes, DISPLAYNAME_PREFIX } from "../../common";
|
21 | import { uniqueId } from "../../common/utils";
|
22 | export var IconSize;
|
23 | (function (IconSize) {
|
24 | IconSize[IconSize["STANDARD"] = 16] = "STANDARD";
|
25 | IconSize[IconSize["LARGE"] = 20] = "LARGE";
|
26 | })(IconSize || (IconSize = {}));
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | var Icon = (function (_super) {
|
33 | __extends(Icon, _super);
|
34 | function Icon() {
|
35 | return _super !== null && _super.apply(this, arguments) || this;
|
36 | }
|
37 | Icon.prototype.render = function () {
|
38 | var icon = this.props.icon;
|
39 | if (icon == null || typeof icon === "boolean") {
|
40 | return null;
|
41 | }
|
42 | else if (typeof icon !== "string") {
|
43 | return icon;
|
44 | }
|
45 | var _a = this.props, className = _a.className, color = _a.color, htmlTitle = _a.htmlTitle,
|
46 |
|
47 | iconSize = _a.iconSize, intent = _a.intent, _b = _a.size, size = _b === void 0 ? iconSize !== null && iconSize !== void 0 ? iconSize : IconSize.STANDARD : _b, title = _a.title, _c = _a.tagName, tagName = _c === void 0 ? "span" : _c, htmlprops = __rest(_a, ["className", "color", "htmlTitle", "iconSize", "intent", "size", "title", "tagName"]);
|
48 |
|
49 | var pixelGridSize = size >= IconSize.LARGE ? IconSize.LARGE : IconSize.STANDARD;
|
50 |
|
51 | var paths = this.renderSvgPaths(pixelGridSize, icon);
|
52 | var classes = classNames(Classes.ICON, Classes.iconClass(icon), Classes.intentClass(intent), className);
|
53 | var viewBox = "0 0 ".concat(pixelGridSize, " ").concat(pixelGridSize);
|
54 | var titleId = uniqueId("iconTitle");
|
55 | return React.createElement(tagName, __assign(__assign({}, htmlprops), { "aria-hidden": title ? undefined : true, className: classes, title: htmlTitle }), React.createElement("svg", { fill: color, "data-icon": icon, width: size, height: size, viewBox: viewBox, "aria-labelledby": title ? titleId : undefined, role: "img" },
|
56 | title && React.createElement("title", { id: titleId }, title),
|
57 | paths));
|
58 | };
|
59 |
|
60 | Icon.prototype.renderSvgPaths = function (pathsSize, iconName) {
|
61 | var svgPathsRecord = pathsSize === IconSize.STANDARD ? IconSvgPaths16 : IconSvgPaths20;
|
62 | var paths = svgPathsRecord[iconNameToPathsRecordKey(iconName)];
|
63 | if (paths == null) {
|
64 | return null;
|
65 | }
|
66 | return paths.map(function (path, i) { return React.createElement("path", { key: i, d: path, fillRule: "evenodd" }); });
|
67 | };
|
68 | Icon.displayName = "".concat(DISPLAYNAME_PREFIX, ".Icon");
|
69 | return Icon;
|
70 | }(AbstractPureComponent2));
|
71 | export { Icon };
|
72 |
|
\ | No newline at end of file |