UNPKG

3.36 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 { DISPLAYNAME_PREFIX, InputGroup, Overlay } from "@blueprintjs/core";
20import { Classes } from "../../common";
21import { QueryList } from "../query-list/queryList";
22var Omnibar = /** @class */ (function (_super) {
23 __extends(Omnibar, _super);
24 function Omnibar() {
25 var _this = _super !== null && _super.apply(this, arguments) || this;
26 _this.TypedQueryList = QueryList.ofType();
27 _this.renderQueryList = function (listProps) {
28 var _a = _this.props, _b = _a.inputProps, inputProps = _b === void 0 ? {} : _b, isOpen = _a.isOpen, _c = _a.overlayProps, overlayProps = _c === void 0 ? {} : _c;
29 var handleKeyDown = listProps.handleKeyDown, handleKeyUp = listProps.handleKeyUp;
30 var handlers = isOpen ? { onKeyDown: handleKeyDown, onKeyUp: handleKeyUp } : {};
31 return (React.createElement(Overlay, __assign({ hasBackdrop: true }, overlayProps, { isOpen: isOpen, className: classNames(Classes.OMNIBAR_OVERLAY, overlayProps.className), onClose: _this.handleOverlayClose }),
32 React.createElement("div", __assign({ className: classNames(Classes.OMNIBAR, listProps.className) }, handlers),
33 React.createElement(InputGroup, __assign({ autoFocus: true, large: true, leftIcon: "search", placeholder: "Search..." }, inputProps, { onChange: listProps.handleQueryChange, value: listProps.query })),
34 listProps.itemList)));
35 };
36 _this.handleOverlayClose = function (event) {
37 var _a, _b, _c, _d;
38 (_b = (_a = _this.props.overlayProps) === null || _a === void 0 ? void 0 : _a.onClose) === null || _b === void 0 ? void 0 : _b.call(_a, event);
39 (_d = (_c = _this.props).onClose) === null || _d === void 0 ? void 0 : _d.call(_c, event);
40 };
41 return _this;
42 }
43 Omnibar.ofType = function () {
44 return Omnibar;
45 };
46 Omnibar.prototype.render = function () {
47 // omit props specific to this component, spread the rest.
48 var _a = this.props, isOpen = _a.isOpen, inputProps = _a.inputProps, overlayProps = _a.overlayProps, restProps = __rest(_a, ["isOpen", "inputProps", "overlayProps"]);
49 var initialContent = "initialContent" in this.props ? this.props.initialContent : null;
50 return React.createElement(this.TypedQueryList, __assign({}, restProps, { initialContent: initialContent, renderer: this.renderQueryList }));
51 };
52 Omnibar.displayName = "".concat(DISPLAYNAME_PREFIX, ".Omnibar");
53 return Omnibar;
54}(React.PureComponent));
55export { Omnibar };
56//# sourceMappingURL=omnibar.js.map
\No newline at end of file