UNPKG

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