@attivio/suit
Version:
Attivio SUIT, the Search UI Toolkit, is a library for creating search clients for searching the Attivio platform.
86 lines (73 loc) • 3.48 kB
JavaScript
var _class, _temp;
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
import React from 'react';
import PropTypes from 'prop-types';
import NavbarSearch from '../components/NavbarSearch';
import SearchResults from '../components/SearchResults';
import Scrollable from '../components/Scrollable';
import SearchResultsCount from '../components/SearchResultsCount';
/**
* A miniature, self-contained component that presents super simple search UI including a text field for the
* query, an indication of the number or results or error from the query, and a small, scrollable results area
* showing the resulting documents. It must be nested inside a Searcher component and will use that parent
* Searcher to manage its state.
*/
var MiniSearchUI = (_temp = _class = function (_React$Component) {
_inherits(MiniSearchUI, _React$Component);
function MiniSearchUI(props) {
_classCallCheck(this, MiniSearchUI);
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props));
_this.doSearch = _this.doSearch.bind(_this);
_this.updateSearchQuery = _this.updateSearchQuery.bind(_this);
return _this;
}
MiniSearchUI.prototype.doSearch = function doSearch() {
var searcher = this.context.searcher;
searcher.doSearch();
};
MiniSearchUI.prototype.updateSearchQuery = function updateSearchQuery(query) {
var searcher = this.context.searcher;
searcher.updateQuery(query);
};
MiniSearchUI.prototype.render = function render() {
return React.createElement(
'div',
{ style: { minHeight: '50vh' } },
React.createElement(NavbarSearch, {
onSearch: this.doSearch,
updateSearchString: this.updateSearchQuery,
value: this.context.searcher.state.query,
style: {
marginLeft: '8px'
}
}),
React.createElement(SearchResultsCount, { style: { marginLeft: '20px', paddingBottom: '8px' } }),
React.createElement(
Scrollable,
{
style: {
height: '428px',
width: '100%',
borderTop: '1px solid #ccc',
borderRight: '1px solid #ccc',
borderLeft: '1px solid #ccc'
}
},
React.createElement(SearchResults, {
format: 'simple',
style: {
transform: 'scale(' + this.props.scale + ', ' + this.props.scale + ')'
}
})
)
);
};
return MiniSearchUI;
}(React.Component), _class.defaultProps = {
scale: 1.0
}, _class.contextTypes = {
searcher: PropTypes.any
}, _class.displayName = 'MiniSearchUI', _temp);
export { MiniSearchUI as default };