-
Notifications
You must be signed in to change notification settings - Fork 72
/
OutlineFilter.js
65 lines (55 loc) · 2.1 KB
/
OutlineFilter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _react = require("devtools/client/shared/vendor/react");
var _react2 = _interopRequireDefault(_react);
var _classnames = require("devtools/client/debugger/dist/vendors").vendored["classnames"];
var _classnames2 = _interopRequireDefault(_classnames);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
class OutlineFilter extends _react.Component {
constructor(...args) {
var _temp;
return _temp = super(...args), this.state = { focused: false }, this.setFocus = shouldFocus => {
this.setState({ focused: shouldFocus });
}, this.onChange = e => {
this.props.updateFilter(e.target.value);
}, this.onKeyDown = e => {
if (e.key === "Escape" && this.props.filter !== "") {
// use preventDefault to override toggling the split-console which is
// also bound to the ESC key
e.preventDefault();
this.props.updateFilter("");
} else if (e.key === "Enter") {
// We must prevent the form submission from taking any action
// https://github.com/firefox-devtools/debugger/pull/7308
e.preventDefault();
}
}, _temp;
}
render() {
const { focused } = this.state;
return _react2.default.createElement(
"div",
{ className: "outline-filter" },
_react2.default.createElement(
"form",
null,
_react2.default.createElement("input", {
className: (0, _classnames2.default)("outline-filter-input", { focused }),
onFocus: () => this.setFocus(true),
onBlur: () => this.setFocus(false),
placeholder: L10N.getStr("outline.placeholder"),
value: this.props.filter,
type: "text",
onChange: this.onChange,
onKeyDown: this.onKeyDown
})
)
);
}
}
exports.default = OutlineFilter;