solrkit
Version:
  UI Components for Solr, using TypeScript + React
55 lines • 2.39 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import * as React from 'react';
import { Menu, Dropdown } from 'semantic-ui-react';
import * as _ from 'lodash';
import { defaultRenderer } from './FacetTypes';
var TagFacet = (function (_super) {
__extends(TagFacet, _super);
function TagFacet() {
return _super !== null && _super.apply(this, arguments) || this;
}
TagFacet.prototype.onClick = function (value) {
var selections = value;
var thisFacet = {};
thisFacet[this.props.facet] = selections;
this.context.transition({
start: 0,
facets: thisFacet
});
};
TagFacet.prototype.render = function () {
var _this = this;
var title = this.props.title;
var render = this.props.render || defaultRenderer;
var options = _.sortBy(this.props.values, function (v) { return v[0]; }).map(function (value, i) {
return {
key: i,
text: render(value[0], value[1]),
value: value[0]
};
});
var initialValue = _.get(this.context.searchState, 'facets.' + this.props.facet, undefined);
return (React.createElement("div", { className: "ui", style: { marginBottom: '1em', display: 'block' } },
React.createElement(Menu, { compact: true },
React.createElement(Dropdown, { text: title, multiple: true, options: options, simple: true, item: true, fluid: true, value: initialValue, onChange: function (e, _a) {
var value = _a.value;
return _this.onClick(value);
} }))));
};
TagFacet.contextTypes = {
searchState: React.PropTypes.object,
transition: React.PropTypes.func
};
return TagFacet;
}(React.Component));
export { TagFacet };
//# sourceMappingURL=TagFacet.js.map