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