New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@logilab/react-faceted-search

Package Overview
Dependencies
Maintainers
3
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@logilab/react-faceted-search

Faceted search form for React

  • 0.1.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

|badge|

.. |badge| image:: https://jenkins.logilab.org/job/react-faceted-search/badge/icon :target: https://jenkins.logilab.org/job/react-faceted-search

This component relies on 2 elements:

  • a set of React components, to render the HTML markup;
  • a Filters object, that manages the filtering of the Entities.

The main component, FacetedSearchForm, takes several parameters:

  • schema, a definition of the data (see test/data/schema.js for an example);
  • config, a map of the entities and properties to display in the form;
  • filters, a list of default filters;
  • entities, a list of entities implementing the Entities interface.

To be called from the code rendering the form, one has to use the special ref property defined by React:

::

var config = {facets: new Map()}
config.facets.set('Pipe', ['pipe_usage', 'location_type', 'real_length'])
config.facets.set('SubStation', ['name'])
config.facets.set('Junction', ['name'])

render(
    <FacetedSearchForm
       schema={schema}
       config={config}
       entities={entities}
       ref={(ref) => this._form = ref}
    />,
    document.getElementById('entity-search-form')
)

The form will then be available using this._form.

Some methods are accessible through that ref:

  • addFilter(filter);
  • removeFilter(filter);
  • clearFilters();
  • getFilteredEntities().

The filter parameter passed to those methods is an object representing the filter. It can have one of the following shapes:

::

{
    entityType: 'Pipe',
    propertyName: 'name',
    value: 'my name'
}
{
    type: 'string_contains',
    entityType: 'Pipe',
    propertyName: 'identifier',
    value: 'P_'
}
{
    type: 'string_in_list',
    entityType: 'Pipe',
    propertyName: '__eid__',
    value: ['123', '345', '678']
}
{
    type: 'number_between',
    entityType: 'Pipe',
    propertyName: 'real_length',
    value: ['1', '10']
}

Keywords

FAQs

Package last updated on 12 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc