@git-temporal/git-temporal-react
Version:
<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
46 lines (45 loc) • 1.7 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const styles_1 = require("app/styles");
const SearchIcon_1 = require("app/components/SearchIcon");
const SearchInput_1 = require("app/components/SearchInput");
const initialState = {
showSearchInput: false,
};
const iconStyle = {
_extends: ['selectable'],
width: 25,
height: 23,
textAlign: 'center',
paddingTop: 6,
marginRight: 12,
};
class SearchToggle extends react_1.default.Component {
constructor() {
super(...arguments);
this.state = initialState;
this.onIconClick = () => {
this.setState({ showSearchInput: true });
};
this.onClose = () => {
this.setState({ showSearchInput: false });
this.props.onChange('');
};
}
render() {
const { value, onChange } = this.props;
if ((value && value.toString().trim() !== '') ||
this.state.showSearchInput) {
return (react_1.default.createElement(SearchInput_1.SearchInput, { value: value, onChange: onChange, onClear: this.onClose, style: styles_1.style(this.props.style) }));
}
return (react_1.default.createElement("div", { style: styles_1.style(iconStyle, this.props.style, {
width: iconStyle.width,
}), onClick: this.onIconClick },
react_1.default.createElement(SearchIcon_1.SearchIcon, { width: 16, height: 16 })));
}
}
exports.SearchToggle = SearchToggle;