React component – an input with dropdown suggestion to build SQL-like queries. Uses PEG.js to parse and get expectations and errors. You can fork and import your own grammar. This is an initial version more flexibility and features are comming.
You have to download it manually or install from GitHub. NPM release is comming soon.
import SmartInput from 'react-smart-input'
then
<SmartInput applyKey="Tab" suggestions={{ identifier: ['id', 'name', 'age'] }} placeholder="SQL-like query" errors={true}/>
You can see usage example at /example
.
name | type | default | description |
---|---|---|---|
suggestions | Object | – | Object to describe suggestions that are not in PEG. `{ identifier: ['id', 'name', 'age'] }` |
applyKey | String | Tab | Button to apply selected suggestion from dropdown |
placeholder | String | Placeholder for input | |
errors | Boolen | false | Toggles errors block |
Install dependencies:
$ npm install
Run the example app at http://localhost:8080:
$ npm run example
No tests yet, but to run tests in Chrome using karma:
$ npm test
Run tests and watch for code changes:
$ npm test -- --watch
Lint src
and test
files:
$ npm run lint
Generate UMD output in the lib
folder:
$ npm run build