UNPKG

2.86 kBJavaScriptView Raw
1"use strict";
2/*
3 * Copyright 2018 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.PanelView = void 0;
19var tslib_1 = require("tslib");
20var React = tslib_1.__importStar(require("react"));
21var common_1 = require("../../common");
22var buttons_1 = require("../button/buttons");
23var text_1 = require("../text/text");
24var PanelView = /** @class */ (function (_super) {
25 tslib_1.__extends(PanelView, _super);
26 function PanelView() {
27 var _this = _super !== null && _super.apply(this, arguments) || this;
28 _this.handleClose = function () { return _this.props.onClose(_this.props.panel); };
29 return _this;
30 }
31 PanelView.prototype.render = function () {
32 var _a = this.props, panel = _a.panel, onOpen = _a.onOpen;
33 // two <span> tags in header ensure title is centered as long as
34 // possible, due to `flex: 1` magic.
35 return (React.createElement("div", { className: common_1.Classes.PANEL_STACK_VIEW },
36 this.maybeRenderHeader(),
37 React.createElement(panel.component, tslib_1.__assign({ openPanel: onOpen, closePanel: this.handleClose }, panel.props))));
38 };
39 PanelView.prototype.maybeRenderHeader = function () {
40 if (!this.props.showHeader) {
41 return null;
42 }
43 return (React.createElement("div", { className: common_1.Classes.PANEL_STACK_HEADER },
44 React.createElement("span", null, this.maybeRenderBack()),
45 React.createElement(text_1.Text, { className: common_1.Classes.HEADING, ellipsize: true, title: this.props.panel.htmlTitle }, this.props.panel.title),
46 React.createElement("span", null)));
47 };
48 PanelView.prototype.maybeRenderBack = function () {
49 if (this.props.previousPanel === undefined) {
50 return null;
51 }
52 return (React.createElement(buttons_1.Button, { "aria-label": "Back", className: common_1.Classes.PANEL_STACK_HEADER_BACK, icon: "chevron-left", minimal: true, onClick: this.handleClose, small: true, text: this.props.previousPanel.title, title: this.props.previousPanel.htmlTitle }));
53 };
54 return PanelView;
55}(common_1.AbstractPureComponent2));
56exports.PanelView = PanelView;
57//# sourceMappingURL=panelView.js.map
\No newline at end of file