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 { AbstractPureComponent2, Classes, DISPLAYNAME_PREFIX, Utils, } from "../../common";
|
21 | import { isReactNodeEmpty } from "../../common/utils";
|
22 | import { Icon, IconSize } from "../icon/icon";
|
23 | import { Text } from "../text/text";
|
24 | var Tag = (function (_super) {
|
25 | __extends(Tag, _super);
|
26 | function Tag() {
|
27 | var _this = _super !== null && _super.apply(this, arguments) || this;
|
28 | _this.onRemoveClick = function (e) {
|
29 | var _a, _b;
|
30 | (_b = (_a = _this.props).onRemove) === null || _b === void 0 ? void 0 : _b.call(_a, e, _this.props);
|
31 | };
|
32 | return _this;
|
33 | }
|
34 | Tag.prototype.render = function () {
|
35 | var _a;
|
36 | var _b = this.props, active = _b.active, children = _b.children, className = _b.className, fill = _b.fill, icon = _b.icon, intent = _b.intent, interactive = _b.interactive, large = _b.large, minimal = _b.minimal, multiline = _b.multiline, onRemove = _b.onRemove, rightIcon = _b.rightIcon, round = _b.round, _c = _b.tabIndex, tabIndex = _c === void 0 ? 0 : _c, htmlTitle = _b.htmlTitle, elementRef = _b.elementRef, htmlProps = __rest(_b, ["active", "children", "className", "fill", "icon", "intent", "interactive", "large", "minimal", "multiline", "onRemove", "rightIcon", "round", "tabIndex", "htmlTitle", "elementRef"]);
|
37 | var isRemovable = Utils.isFunction(onRemove);
|
38 | var tagClasses = classNames(Classes.TAG, Classes.intentClass(intent), (_a = {},
|
39 | _a[Classes.ACTIVE] = active,
|
40 | _a[Classes.FILL] = fill,
|
41 | _a[Classes.INTERACTIVE] = interactive,
|
42 | _a[Classes.LARGE] = large,
|
43 | _a[Classes.MINIMAL] = minimal,
|
44 | _a[Classes.ROUND] = round,
|
45 | _a), className);
|
46 | var isLarge = large || tagClasses.indexOf(Classes.LARGE) >= 0;
|
47 | var removeButton = isRemovable ? (React.createElement("button", { "aria-label": "Remove", type: "button", className: Classes.TAG_REMOVE, onClick: this.onRemoveClick, tabIndex: interactive ? tabIndex : undefined },
|
48 | React.createElement(Icon, { icon: "small-cross", size: isLarge ? IconSize.LARGE : IconSize.STANDARD }))) : null;
|
49 | return (React.createElement("span", __assign({}, htmlProps, { className: tagClasses, tabIndex: interactive ? tabIndex : undefined, ref: elementRef }),
|
50 | React.createElement(Icon, { icon: icon }),
|
51 | !isReactNodeEmpty(children) && (React.createElement(Text, { className: Classes.FILL, ellipsize: !multiline, tagName: "span", title: htmlTitle }, children)),
|
52 | React.createElement(Icon, { icon: rightIcon }),
|
53 | removeButton));
|
54 | };
|
55 | Tag.displayName = DISPLAYNAME_PREFIX + ".Tag";
|
56 | Tag = __decorate([
|
57 | polyfill
|
58 | ], Tag);
|
59 | return Tag;
|
60 | }(AbstractPureComponent2));
|
61 | export { Tag };
|
62 |
|
\ | No newline at end of file |