Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-structured-query-search

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-structured-query-search

react-structured-query-search

  • 1.0.0-alpha.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
10
increased by25%
Maintainers
1
Weekly downloads
 
Created
Source

react-structured-query-search 🎉

NPM JavaScript Style Guide

react-structured-query-search is a javascript library that provides autocomplete search queries.
This was inspired by visualsearch and react-structured-filter

This plugin is written on top of react-structured-filter, which has been revamped to add React 16 support and the existing code has been overriden to support New features.

You can use all the react-typeahead, react-structured-filter API(options) as they are.

🎉🎊 New Features 🎊🎉

  • Ajax support to retrieve values.
  • Allows user to send values for Category in Array<String> or Array<Object>
  • Allows user to pass custom loader component.
  • Allows user to customize the header of dropdown (categories, operators, values).
  • Allows user to enable/disable operators in search.
  • Allows user to perform category-value search without operator (if isAllowOperator is false).
  • Switch between unique/duplicate categories (key).
  • Switch between unique/duplicate values
  • Allows user to send custom operators list.
  • Allows user to render custom tag(token) Component or the tag(token) Item.
  • Allows user to update Options(props) on runtime.

Install

npm install --save react-structured-query-search

Usage (Example Code) (Demo)

If you want to use Tokenizer then you either import as follows:

import ReactStructuredQuerySearch from "react-structured-query-search";
import "react-structured-query-search/dist/index.css";
or
import {Tokenizer} from "react-structured-query-search";
import "react-structured-query-search/dist/index.css";

If you want to use Typeahead then you have to import as follows:

import {Typeahead} from "react-structured-query-search";
import "react-structured-query-search/dist/index.css";

API

New flexible modification/existing options

ParameterTypeDefaultDescription
optionsArray[]An array supplied to the filter function.
maxVisibleNumberLimit the number of options rendered in the results list.
customClassesObjectAllowed Keys:
  • input
  • results
  • listItem
  • listAnchor
  • hover
  • typeahead
  • resultsTruncated
  • token
An object containing custom class names for child elements. Useful for integrating with 3rd party UI kits.
placeholderStringPlaceholder text for the typeahead input.
:new: disabledBooleanfalseSet to true for disabling the StructureQuerySearch
:new: defaultSelectedfunction, Array[]Allows user to initialize the search with selected values
:new: categoryHeaderString, Component"Category"Allows user the change the header title of Category
:new: operatorHeaderString, Component"Operator"Allows user the change the header title of Operator
:new: valueHeaderString, Component"Value"Allows user the change the header title of Value
:new: isAllowSearchDropDownHeaderBoolean"true"Allows user to enable/disable search drop-down header
:new: isAllowOperatorBooleanfalseAllows user to enable/disable operators in search
:new: isAllowClearAllBooleantrueAllows user to clear all selected data
onTokenRemoveFunctionEvent handler triggered whenever a token is removed.
onTokenAddFunctionEvent handler triggered whenever a token is added.
Params: (addedToken)
:new: onClearAllfunctionEvent handler triggered whenever clear all button clicked
onOptionSelectedFunctionEvent handler triggered whenever a user picks an option.
:new: updateOptionsfunctionAllows user to update the Options(props) at runtime, this function is called before onTokenRemove and onTokenAdd
:new: fuzzySearchEmptyMessageString"No result found"This message is shown when dropdown doesn't have search value
:new: renderLoadingfunction, Component"Loading...."Show custom loader when values are retrieved using Ajax
:new: renderTokensfunctionAllows user to render custome Token Component
:new: renderTokenItemfunctionAllows user to render custome Token Item
:new: renderSearchItemfunctionAllows user to render custome value
onKeyDownFunctionEvent handler for the keyDown event on the typeahead input.
onKeyPressFunctionEvent handler for the keyPress event on the typeahead input.
onKeyUpFunctionEvent handler for the keyUp event on the typeahead input.
onBlurFunctionEvent handler for the blur event on the typeahead input.
onFocusFunctionEvent handler for the focus event on the typeahead input.

props.options (Data attributes)

ParameterTypeDefaultRequiredDescription
categoryStringrequiredName of the first thing the user types.
typeStringtextThis can be one of the following:
  • text: Arbitrary text for the value. No autocomplete options.
    • Operator choices will be: "==", "!=", "contains", "!contains".
  • textoptions: You must additionally pass an options value.
    • Operator choices will be: "==", "!=".
  • number: Arbitrary text for the value. No autocomplete options.
    • Operator choices will be: "==", "!=", "<", "<=", ">", ">=".
  • date: Shows a calendar and the input must be of the form "YYYY-MM-DD".
    • Operator choices will be: "==", "!=", "<", "<=", ">", ">=".
:new: operatorArray, functionrequired, if isAllowOperator prop is set to trueIf this attribute is added then it would ignore the type check as described in type parameter and it would accept what you have passed
optionsArray, function, Promiserequired, if type="textoptions"Get the value according to selected category
:new: isAllowCustomValueBooleanfalse
When this parameter is set to true, it allows you to send multiple custom values for type=textoptions
:new: isAllowDuplicateCategoriesBooleantrueSwitch between unique/duplicate categories (key)
:new: isAllowDuplicateOptionsBooleanfalseSwitch between unique/duplicate values
:new: fuzzySearchKeyAttributeStringnameIf Category (options)values are Array<Object> then By default fuzzy search look for name attribute inside options(values) but you can change that attribut lookup key using fuzzySearchKeyAttribute

How to Contribute

Setting Up

Please run npm install in the root and example folders. then do the following:

  • Go to root folder and run npm start after this
  • Go to example folder and run npm run link (only for first time)
  • Go to example folder and run npm start it would run the plugin from link which we have created.

Now, anytime you make a change to your library in src/ or to the example app's example/src create-react-app will live-reload your local dev server so you can iterate on your component in real-time.

License

MIT © kevalbhatt

FAQs

Package last updated on 03 Jun 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