Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/informatix8/search-bios
https://github.com/informatix8/search-bios
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/informatix8/search-bios
- Owner: informatix8
- Created: 2020-01-13T18:02:01.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-27T13:36:57.000Z (over 4 years ago)
- Last Synced: 2024-03-25T12:08:51.221Z (11 months ago)
- Language: JavaScript
- Size: 30.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Search BIOS
Search Model and ServicesA model handling search state, fetching
## Features
- Result fetching
- Customizable services which can be overridden
- Fetches suggestions as user types query
- Shows suggestions
- Dismiss suggestions on keyboard esc or click outside
- LocalStorage history save
- Suggestions from LocalStorage for short phrases
- HTML tags stripping## Usage
### Install
```shell
npm install @informatix8/search-bios --save-dev
```### CDN
```html
```
### Vanilla Javascript
```javascript
import SearchBIOS from './search-bios';
import SearchResultDataServiceTheta from './search-result-data-service-theta';
import SearchHistoryDataServiceLocalStorage from './search-history-data-service-local-storage';
import SearchSuggestDataServiceEpsilon from './search-suggest-data-service-epsilon';const model = new SearchBIOS({
id: 'theta',
request: {
limit: 25,
sort: 'relevancy'
},
config: {
limitOptions: [10, 25, 100],
sortOptions: [
{ text: 'Most Relevant', value: 'relevancy' },
{ text: 'Most Recent', value: 'chronological' },
{ text: 'Most Popular', value: 'popularity' }
],
historyEnabled: true,
suggestionsEnabled: true
},
resultDataService: new SearchResultDataServiceTheta(),
historyDataService: new SearchHistoryDataServiceLocalStorage(),
suggestionsDataService: new SearchSuggestDataServiceEpsilon(),
stateService: {
searchPending: false,
historyPending: false,
historyVisible: false,
suggestionsPending: false,
suggestionsVisible: false,
mobileZoomed: false
},
callbacks: {
postPresentHistory: function () {
console.log(this.id + ' history presented');
},
postPresentSuggestions: function () {
console.log(this.id + ' suggestions presented');
}
}
});model.editIntent('movies'); //user types 'movies'
model.clickSuggestionsItem(2); //user clicks suggestion item #2
model.editIntent('movies 2018'); //user amends query to ' 2018'
model.enter('movies 2018'); //user presses the `enter` key
model.editIntent('movies online 2019'); //user edits search field to be 'movies online 2019'
model.esc(); //user presses the `esc` key
model.search('movies online 2019'); //user clicks the search icon to run the search
```## Development
```shell
npm run dev
```## Build
```shell
npm run build
```## Release
```shell
npm run build
git tag -a vX.Y.Z
git push origin master
git push origin --tags
npm publish --access=public .