Skip to content

Commit

Permalink
Build updates (WIP) (#532)
Browse files Browse the repository at this point in the history
* make view switcher more universal friendly

* Transfer global to searchkitManager guid scope

Guid scoped to searchkit manager instance,

mainly for serverside where multiple instances may live

* pull up more universal code

* ensure search request methods return promise of completion

* add clear to EventEmitter

- helps stop propogating changes (SSR)

* Initial react 16 compat

- update rc-slider
-workaround for bem-cn

* replace react-addons-update with immutability-helper

* initial updates

* fix types, update enzyme, update test-utils

* Merge branch 'develop' of github.com:searchkit/searchkit into build-updates

* fix tsc generation + entry

* regen yarn.lock

* generate package-lock.json
  • Loading branch information
ssetem committed Oct 6, 2017
1 parent 689737c commit 7c967d0
Show file tree
Hide file tree
Showing 28 changed files with 9,380 additions and 1,535 deletions.
8,342 changes: 8,342 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

44 changes: 21 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,23 +52,13 @@
],
"license": "Apache-2.0",
"dependencies": {
"@types/classnames": "0.0.32",
"@types/enzyme": "^2.7.1",
"@types/es6-promise": "0.0.32",
"@types/history": "4.5.0",
"@types/lodash": "^4.14.50",
"@types/react": "0.0.0",
"@types/react-addons-create-fragment": "^0.14.15",
"@types/react-dom": "^0.14.20",
"@types/react-router": "^2.0.41",
"@types/selenium-webdriver": "^2.53.39",
"@types/sinon": "^1.16.34",
"@types/source-map": "^0.5.0",
"axios": "^0.15.3",
"es6-promise": "^3.1.2",
"history": "4.6.1",
"@types/axios": "^0.14.0",
"@types/history": "^4.6.0",
"@types/lodash": "4.14.77",
"axios": "^0.16.2",
"history": "4.7.2",
"immutability-helper": "^2.4.0",
"lodash": "4.14.2",
"lodash": "4.17.4",
"prop-types": "^15.5.8",
"qs": "6.4.0",
"rc-slider": "^8.3.1"
Expand All @@ -78,13 +68,21 @@
"react-dom": "^0.14.0 || ^15.0.0-0 || ^16.0.0-0"
},
"devDependencies": {
"@types/enzyme": "^2.8.11",
"@types/jasmine": "^2.5.40",
"@types/jasmine-ajax": "^3.1.32",
"@types/jasminewd2": "^2.0.3",
"@types/react": "^15.0.0",
"@types/react-dom": "^15.0.0",
"@types/react-router": "^2.0.51",
"@types/selenium-webdriver": "^2.53.39",
"@types/sinon": "^1.16.34",
"@types/source-map": "^0.5.0",
"autoprefixer": "^6.3.3",
"chalk": "^1.1.1",
"css-loader": "^0.23.1",
"ejs": "^2.4.1",
"enzyme": "^2.0.0",
"enzyme": "2.9.1",
"es6-promise": "^4.1.1",
"express": "^4.13.4",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.5",
Expand Down Expand Up @@ -113,17 +111,17 @@
"phantomjs-prebuilt": "^2.1.4",
"postcss-loader": "^0.8.2",
"protractor": "^4.0.0",
"react": "^15.4.0",
"react-addons-test-utils": "^15.6.0",
"react-dom": "15.4.0",
"react": "^15.6.0",
"react-dom": "15.6.0",
"react-router": "^2.4.0",
"react-test-renderer": "^15.6.2",
"sass-loader": "^3.1.2",
"serve-favicon": "^2.3.0",
"sinon": "^1.17.2",
"style-loader": "^0.13.0",
"ts-loader": "^1.3.3",
"ts-loader": "^2.3.7",
"ts-node": "^0.5.5",
"typescript": "^2.1.4",
"typescript": "^2.5.3",
"webpack": "^1.12.14",
"webpack-config": "^4.0.0",
"webpack-hot-middleware": "^2.9.1",
Expand Down
39 changes: 19 additions & 20 deletions release/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion release/theme.css

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/__test__/core/react/FastClickSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import {
} from "../../../"

import {mount} from "enzyme";
FastClick.component = FastClickComponent

describe("FastClick - fast", ()=> {

beforeEach(()=> {
FastClick.component = FastClickComponent

this.handler = jasmine.createSpy("fastclick handler")
this.wrapper = mount(
<FastClick handler={this.handler}>
Expand All @@ -21,6 +22,10 @@ describe("FastClick - fast", ()=> {
)
})

afterEach(()=> {
FastClick.component = NormalClickComponent
})

it("should render children", ()=> {
expect(this.wrapper.html())
.toEqual("<button>click me</button>")
Expand Down
11 changes: 7 additions & 4 deletions src/__test__/core/react/RenderComponentSpec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ describe("RenderComponent", ()=> {
}
this.SubPanel.defaultProps.title = "SubPanel"
this.SubPanelElement = <Panel title="PanelElement"/>
this.PanelReactClass = React.createClass({
contextTypes:{

this.PanelReactClass = class PanelReactClass extends React.Component {
static contextTypes = {
color:PropTypes.string
},
}
render(){
return (<Panel title={"PanelReactClass " + this.context.color} {...this.props}>
{this.props.children}
</Panel>)
}
})
}



this.PanelFunction = (props, context)=> {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ describe("PureRenderComponent", ()=> {

}
let comp = new MyComponent()
expect(comp.shouldComponentUpdate).toBe(shouldPureComponentUpdate)

comp.props = {p:1}
comp.state= {s:1}
expect(comp.shouldComponentUpdate({p:1}, {s:1})).toBe(false)
Expand Down
2 changes: 1 addition & 1 deletion src/__test__/core/transport/AxiosESTransportSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe("AxiosESTransport", ()=> {
from:0
}).then((result)=> {
expect(result.hits).toEqual([1,2,3])
let request = jasmine.Ajax.requests.mostRecent()
let request:any = jasmine.Ajax.requests.mostRecent()
expect(request.method).toBe("POST")
expect(request["data"]()).toEqual(
{size:10, from:0})
Expand Down
2 changes: 1 addition & 1 deletion src/components/__test__/TestHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ReactTestUtils = require('react-addons-test-utils')
import ReactTestUtils = require('react-dom/test-utils')
import {html as beautifyHtml} from 'js-beautify'
import { renderToStaticMarkup, renderToString } from 'react-dom/server'
import * as ReactDOM from "react-dom"
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/filters/facet-filter/FacetFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {CheckboxItemList, Panel} from "../../../ui"
import {defaults} from "lodash"
import {identity} from "lodash"

export class FacetFilter<T extends FacetFilterProps> extends SearchkitComponent<T, any> {
export class FacetFilter extends SearchkitComponent<FacetFilterProps, any> {
accessor: FacetAccessor

static propTypes = FacetFilterPropTypes
Expand Down
2 changes: 1 addition & 1 deletion src/components/search/filters/facet-filter/MenuFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const allItem = {
key:"$all", label: "All"
}

export class MenuFilter extends FacetFilter<FacetFilterProps> {
export class MenuFilter extends FacetFilter {

static propTypes = defaults({
}, FacetFilterPropTypes.propTypes)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {FacetFilter} from "./FacetFilter"
import {FacetFilterProps, FacetFilterPropTypes} from "./FacetFilterProps"

export class RefinementListFilter extends FacetFilter<FacetFilterProps> {
export class RefinementListFilter extends FacetFilter {

}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe("Range Filter tests", () => {
<div role="slider" tabIndex={0} aria-valuemin="0" aria-valuemax="100" aria-valuenow="0" aria-disabled="false"
className="rc-slider-handle rc-slider-handle-1" style={{left:" 0%"}}></div>
<div role="slider" tabIndex={0} aria-valuemin="0" aria-valuemax="100" aria-valuenow="100" aria-disabled="false" className="rc-slider-handle rc-slider-handle-2" style={{left:" 100%"}}></div>
<div className="rc-slider-mark"><span className="rc-slider-mark-text rc-slider-mark-text-active" style={{width:" 90%", " margin-left":" -45%", " left":" 0%"}}>0 score</span><span className="rc-slider-mark-text rc-slider-mark-text-active" style={{width:" 90%", " margin-left":" -45%", " left":" 100%"}}>100 score</span></div>
<div className="rc-slider-mark"><span className="rc-slider-mark-text rc-slider-mark-text-active" style={{width:" 90%", " marginLeft":" -45%", " left":" 0%"}}>0 score</span><span className="rc-slider-mark-text rc-slider-mark-text-active" style={{width:" 90%", " marginLeft":" -45%", " left":" 100%"}}>100 score</span></div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
SearchkitComponentProps,
ReactComponentType,
PureRender,
renderComponent
renderComponent,
SelectedFilter
} from "../../../../core"

import {
Expand Down Expand Up @@ -51,7 +52,7 @@ export class GroupedSelectedFilters extends SearchkitComponent<GroupedSelectedFi
}
}

getFilters(): Array<any> {
getFilters() {
return this.getQuery().getSelectedFilters()
}

Expand All @@ -70,7 +71,7 @@ export class GroupedSelectedFilters extends SearchkitComponent<GroupedSelectedFi
this.searchkit.performSearch()
}

removeFilters(filters) {
removeFilters(filters:Array<SelectedFilter>) {
forEach(filters, filter => filter.remove())
this.searchkit.performSearch()
}
Expand Down
7 changes: 3 additions & 4 deletions src/components/search/filters/tag-filter/TagFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ FastClick,
export interface TagFilterProps extends SearchkitComponentProps {
field: string
value: string
children?: React.ReactChildren
}


Expand All @@ -21,7 +20,7 @@ export class TagFilter extends SearchkitComponent<TagFilterProps, any> {
super()
this.handleClick = this.handleClick.bind(this)
}

isActive(){
const { field, value } = this.props
const accessor = this.searchkit.accessors.statefulAccessors[field]
Expand All @@ -45,10 +44,10 @@ export class TagFilter extends SearchkitComponent<TagFilterProps, any> {

render() {
const { value, children } = this.props

var className = "sk-tag-filter"
if (this.isActive()) className += " is-active"

if (children){
return (
<FastClick handler={this.handleClick}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ui/range/RangeSlider.unit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("RangeSlider", () => {
<div role="slider" tabIndex={0} aria-valuemin="0" aria-valuemax="10" aria-valuenow="2" aria-disabled="false" className="rc-slider-handle rc-slider-handle-1"
style={{left:" 20%"}}></div>
<div role="slider" tabIndex={0} aria-valuemin="0" aria-valuemax="10" aria-valuenow="5" aria-disabled="false" className="rc-slider-handle rc-slider-handle-2" style={{left:" 50%"}}></div>
<div className="rc-slider-mark"><span className="rc-slider-mark-text" style={{width:" 90%", " margin-left":" -45%", " left":" 0%"}}>0</span><span className="rc-slider-mark-text" style={{width:" 90%", " margin-left":" -45%", " left":" 100%"}}>10</span></div>
<div className="rc-slider-mark"><span className="rc-slider-mark-text" style={{width:" 90%", " marginLeft":" -45%", " left":" 0%"}}>0</span><span className="rc-slider-mark-text" style={{width:" 90%", " marginLeft":" -45%", " left":" 100%"}}>10</span></div>
</div>
</div>
))
Expand Down
2 changes: 0 additions & 2 deletions src/core/SearchkitManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ import {isEqual} from "lodash"
import {get} from "lodash"
import qs from "qs"

require('es6-promise').polyfill()

import {after} from "lodash"

export interface SearchkitOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/core/query/ImmutableQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class ImmutableQuery {
})
}

getSelectedFilters(){
getSelectedFilters() : Array<SelectedFilter> {
return this.index.selectedFilters
}
addAnonymousFilter(bool){
Expand Down
2 changes: 1 addition & 1 deletion src/core/query/query_dsl/aggregations/AggsContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {assign} from "lodash"
import {reduce} from "lodash"
import {compact} from "lodash"

export function AggsContainer(key, inner, aggsArray:Array<any>=[]){
export function AggsContainer(key:string, inner, aggsArray:Array<any>=[]){
aggsArray = compact(aggsArray)
if(aggsArray.length > 0){
inner.aggs = reduce(aggsArray, assign, {})
Expand Down
2 changes: 1 addition & 1 deletion src/core/query/query_dsl/compound/BoolQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function isBoolOp(operator, val) {
return (keys(val).length == 1) && (keys(val.bool).length == 1)
}

function flattenBool(operator, arr) {
function flattenBool(operator, arr:Array<any>) {
// Flatten bool.must
var newArr = []
forEach(arr, node => {
Expand Down
4 changes: 3 additions & 1 deletion src/core/react/pure-render/PureRenderComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ import {shouldPureComponentUpdate} from "./shouldPureComponentUpdate"
import {PureRender} from "./PureRender"

export class PureRenderComponent<T> extends React.Component<T, any> {
shouldComponentUpdate:Function= shouldPureComponentUpdate
shouldComponentUpdate(nextProps, nextState) {
return shouldPureComponentUpdate.call(this, nextProps, nextState)
}
}
2 changes: 1 addition & 1 deletion src/core/react/pure-render/shouldPureComponentUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {shallowEqualWithoutFunctions} from './shallowEqualWithoutFunctions';

export function shouldPureComponentUpdate(nextProps, nextState) {
export function shouldPureComponentUpdate(nextProps, nextState, nextContext?) {
return !shallowEqualWithoutFunctions(this.props, nextProps) ||
!shallowEqualWithoutFunctions(this.state, nextState);
}
2 changes: 1 addition & 1 deletion src/core/transport/AxiosESTransport.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import axios, { AxiosInstance, Promise, AxiosResponse } from "axios"
import axios, { AxiosInstance, AxiosResponse } from "axios"
import {ImmutableQuery} from "../query"
import {ESTransport} from "./ESTransport"
import {defaults} from "lodash"
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/server/apps/playground/TogglePanel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from "react";
import * as PropTypes from "prop-types";

let bemBlock = require("bem-cn")
import {block} from "../../../../../src"

export interface TogglePanelProps extends React.Props<TogglePanel> {
key?: any
Expand Down Expand Up @@ -55,7 +54,7 @@ export class TogglePanel extends React.Component<TogglePanelProps, {collapsed: b
const { collapsed } = this.state

const bemBlocks = {
container: bemBlock(mod)
container: block(mod)
}

var block = bemBlocks.container
Expand Down

0 comments on commit 7c967d0

Please sign in to comment.