UNPKG

solrkit

Version:

![Build Status](https://travis-ci.org/garysieling/solrkit.svg?branch=master) ![Dependencies](https://david-dm.org/garysieling/solrkit/status.svg) UI Components for Solr, using TypeScript + React

55 lines 2.48 kB
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 DropdownFacet = (function (_super) { __extends(DropdownFacet, _super); function DropdownFacet() { return _super !== null && _super.apply(this, arguments) || this; } DropdownFacet.prototype.onClick = function (value) { var selections = [value]; var thisFacet = {}; thisFacet[this.props.facet] = selections; this.context.transition({ start: 0, facets: thisFacet }); }; DropdownFacet.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 + '[0]', undefined); return (React.createElement("div", { className: "ui", style: { marginBottom: '1em', display: 'block' } }, React.createElement(Menu, { compact: true }, React.createElement(Dropdown, { text: initialValue || title, options: options, selection: true, closeOnBlur: true, simple: true, item: true, value: initialValue, onChange: function (e, _a) { var value = _a.value; return _this.onClick(value + ''); } })))); }; DropdownFacet.contextTypes = { searchState: React.PropTypes.object, transition: React.PropTypes.func }; return DropdownFacet; }(React.Component)); export { DropdownFacet }; //# sourceMappingURL=DropdownFacet.js.map