UNPKG

2.82 kBJavaScriptView Raw
1/*
2 * Copyright 2017 Palantir Technologies, Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { __assign, __extends, __rest } from "tslib";
17import classNames from "classnames";
18import * as React from "react";
19import { AbstractPureComponent2, Classes, DISPLAYNAME_PREFIX, Intent, } from "../../common";
20import { H4 } from "../html/html";
21import { Icon, IconSize } from "../icon/icon";
22/**
23 * Callout component.
24 *
25 * @see https://blueprintjs.com/docs/#core/components/callout
26 */
27var Callout = /** @class */ (function (_super) {
28 __extends(Callout, _super);
29 function Callout() {
30 return _super !== null && _super.apply(this, arguments) || this;
31 }
32 Callout.prototype.render = function () {
33 var _a;
34 var _b = this.props, className = _b.className, children = _b.children, icon = _b.icon, intent = _b.intent, title = _b.title, htmlProps = __rest(_b, ["className", "children", "icon", "intent", "title"]);
35 var iconName = this.getIconName(icon, intent);
36 var classes = classNames(Classes.CALLOUT, Classes.intentClass(intent), (_a = {}, _a[Classes.CALLOUT_ICON] = iconName != null, _a), className);
37 return (React.createElement("div", __assign({ className: classes }, htmlProps),
38 iconName && React.createElement(Icon, { icon: iconName, size: IconSize.LARGE, "aria-hidden": true, tabIndex: -1 }),
39 title && React.createElement(H4, null, title),
40 children));
41 };
42 Callout.prototype.getIconName = function (icon, intent) {
43 // 1. no icon
44 if (icon === null) {
45 return undefined;
46 }
47 // 2. defined iconName prop
48 if (icon !== undefined) {
49 return icon;
50 }
51 // 3. default intent icon
52 switch (intent) {
53 case Intent.DANGER:
54 return "error";
55 case Intent.PRIMARY:
56 return "info-sign";
57 case Intent.WARNING:
58 return "warning-sign";
59 case Intent.SUCCESS:
60 return "tick";
61 default:
62 return undefined;
63 }
64 };
65 Callout.displayName = "".concat(DISPLAYNAME_PREFIX, ".Callout");
66 return Callout;
67}(AbstractPureComponent2));
68export { Callout };
69//# sourceMappingURL=callout.js.map
\No newline at end of file