react-facet-filter

Smart input based facet filter for react, supports autocomplete.

Usage no npm install needed!

<script type="module">
  import reactFacetFilter from 'https://cdn.skypack.dev/react-facet-filter';
</script>

README

build status bitHound Score Dependency Status

Synopsis

An advanced input filter that gets out of your way while still providing powerful autocomplete functionality.

Code Example

 <Filter
    filters={this.state.filters}
    categories={this.state.categories}
    operators={this.state.operators}
    options={this.state.options}
    conditions={this.state.conditions}
    onAddFilter={this.onAddFilter}
    onRemoveFilter={this.onRemoveFilter}
    onFiltersChange={this.onFiltersChange}
    fetchOptions={this.fetchOptions}
    loading={this.state.loading}
    threshold={2}
    noRepeat={false}
  />

Motivation

Most filtering solutions hijack your ability to just type in your preferred format, this makes no assumptions but provides sane defaults.

Installation

npm install react-facet-filter

Tests

npm test

Contributors

https://github.com/zsherman

License

MIT.

Common Tasks

  • Developing - npm start - Runs the development server at localhost:8080 and use Hot Module Replacement. You can override the default host and port through env (HOST, PORT).
  • Creating a version - npm version <x.y.z> - Updates /dist and package.json with the new version and create a version tag to Git.
  • Publishing a version - npm publish - Pushes a new version to npm and updates the project site.

Testing

The test setup is based on Karma/Mocha/Chai/Phantom. Code coverage report is generated through istanbul/isparta to build/.

  • Running tests once - npm test
  • Running tests continuously - npm run test:tdd
  • Running individual tests - npm test -- - Works with test:tdd too.
  • Linting - npm run test:lint - Runs ESLint.

Documentation Site

The boilerplate includes a GitHub Pages specific portion for setting up a documentation site for the component. The main commands handle with the details for you. Sometimes you might want to generate and deploy it by hand, or just investigate the generated bundle.

  • Building - npm run gh-pages - Builds the documentation into ./gh-pages directory.
  • Deploying - npm run deploy-gh-pages - Deploys the contents of ./gh-pages to the gh-pages branch. GitHub will pick this up automatically. Your site will be available through *.github.io/`.
  • Generating stats - npm run stats - Generates stats that can be passed to webpack analyse tool. This is useful for investigating what the build consists of.

Highlighting Demo for the Site

var a = 5;
var b = 10;

// just trying out code highlighting feature here
console.log(a + b);

License

Available under MIT.