const {
SearchkitManager,SearchkitProvider,
SearchBox, Hits, RefinementListFilter, Pagination,
CheckboxFilter,
HierarchicalMenuFilter, HitsStats, SortingSelector, NoHits,
GroupedSelectedFilters, SelectedFilters, ResetFilters,
RangeFilter, NumericRefinementListFilter,
ViewSwitcherHits, ViewSwitcherToggle, Select, Toggle,
ItemList, CheckboxItemList, ItemHistogramList, Tabs, TagCloud, MenuFilter,
renderComponent, PageSizeSelector, RangeSliderHistogramInput, Panel, PaginationSelect,
InputFilter, TagFilter, TagFilterList, TagFilterConfig,
TermQuery, RangeQuery, BoolMust,
Layout, LayoutBody, LayoutResults, SideBar, TopBar, ActionBar, ActionBarRow
} = require("../../../../../src")
const host = "http://demo.searchkit.co/api/movies"
import * as ReactDOM from "react-dom";
import * as React from "react";
const searchkit = new SearchkitManager(host)
const _ = require("lodash")
const map = require("lodash/map")
const isUndefined = require("lodash/isUndefined")
import { TogglePanel } from './TogglePanel'
require("../../../../../theming/theme.scss")
require("./customisations.scss")
const MovieHitsGridItem = (props)=> {
const {bemBlocks, result} = props
let url = "http://www.imdb.com/title/" + result._source.imdbId
const source:any = _.extend({}, result._source, result.highlight)
return (
)
}
const MovieHitsListItem = (props)=> {
const {bemBlocks, result} = props
let url = "http://www.imdb.com/title/" + result._source.imdbId
const source:any = _.extend({}, result._source, result.highlight)
const { title, poster, writers = [], actors = [], genres = [], plot, released, rated } = source;
return (
Released in {source.year}, rated {source.imdbRating}/10
)
}
export class MovieHitsCell extends React.Component {
render(){
const { hit, columnKey, columnIdx } = this.props
if (columnKey === "poster"){
return (
|
)
} else {
return {hit._source[columnKey]} |
}
}
}
export class HitsTable extends React.Component{
constructor(props){
super(props)
this.renderHeader = this.renderHeader.bind(this)
this.renderCell = this.renderCell.bind(this)
}
renderHeader(column, idx){
if ((typeof column) === "string"){
return {column} |
} else {
const label = isUndefined(column.label) ? column.key : column.label
return {label} |
}
}
renderCell(hit, column, idx){
const { cellComponent } = this.props
const key = ((typeof column) === "string") ? column : column.key
var element;
if (cellComponent){
return renderComponent(cellComponent, {hit, columnKey: key, key, column, columnIdx: idx})
} else {
return {hit._source[key]} |
}
}
render(){
const { columns, hits } = this.props
return (
{map(columns, this.renderHeader)}
{map(hits, hit => (
{map(columns, (col, idx) => this.renderCell(hit, col, idx))}
))}
)
}
}
class MovieHitsTable extends React.Component {
render(){
const { hits } = this.props
return (
|
Title |
Year |
Rating |
{map(hits, hit => (
|
{hit._source.title} |
{hit._source.year} |
{hit._source.imdbRating} |
))}
)
}
}
const listComponents = {
list: ItemList,
checkbox: CheckboxItemList,
histogram: ItemHistogramList,
select: Select,
tabs: (props) => ,
tags: (props) => ,
toggle: (props) =>
}
class App extends React.Component {
constructor(props){
super(props)
this.state = {
viewMode: "list"
}
}
handleViewModeChange(e){
this.setState({viewMode: e.target.value})
}
render(){
return (
(
)} />
)
}/>
"#"+count} listComponent={Select} id="runtimeMinutes" title="Length" field="runtimeMinutes" options={[
{title:"All"},
{title:"up to 20", from:0, to:20},
{title:"21 to 60", from:21, to:60},
{title:"60 or more", from:61, to:1000}
]}/>
{/**/}
{/**/}
}
]}
scrollTo="body"
/>
)
}
}
ReactDOM.render(, document.getElementById("root"))