solrkit
Version:
 
60 lines • 2.74 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 __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var semantic_ui_react_1 = require("semantic-ui-react");
var _ = require("lodash");
var FacetTypes_1 = require("./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 || FacetTypes_1.defaultRenderer;
var options = _.sortBy(this.props.values, function (v) { return v[0]; }).map(function (_a, i) {
var value = _a.value, count = _a.count, checked = _a.checked;
return {
key: i,
text: render(value, count),
value: value
};
}).filter(!this.props.initialValues ? _.stubTrue : (function (row) {
return _.includes(_this.props.initialValues, row.value);
}));
var initialValue = _.get(this.context.searchState, 'facets.' + this.props.facet, undefined);
return (React.createElement("div", { className: "ui", style: { marginBottom: '1em', display: 'block' } },
React.createElement(semantic_ui_react_1.Menu, { compact: true },
React.createElement(semantic_ui_react_1.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));
exports.TagFacet = TagFacet;
//# sourceMappingURL=TagFacet.js.map