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

@springernature/global-autocomplete

Package Overview
Dependencies
Maintainers
10
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@springernature/global-autocomplete - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

demo/index.hbs

3

HISTORY.md
# History
## 1.0.1 (2019-10-16)
* Adds demo/ folder to configure a demo for the Elements site
## 1.0.0 (2018-06-28)

@@ -4,0 +7,0 @@ * Update to allow consumer to pass in data object rather than have it retrieved from an endpoint

7

package.json
{
"name": "@springernature/global-autocomplete",
"version": "1.0.0",
"version": "1.0.1",
"license": "MIT",
"description": "Autocomplete/suggest component",
"keywords": [],
"author": "Jon Stevens"
"author": "Jon Stevens",
"peerDependencies": {
"@springernature/global-context": "^5.0.1"
}
}

@@ -5,58 +5,9 @@ # Autocomplete component

## Example usage
# Example usage
Please see contents of `demo/` folder for sample client JS.
# JS
A full handlebars demo is also in the demo folder, but following is the only HTML the
component actually requires:
```
import autoComplete from 'global-autocomplete';
const onResults = data => {
// Update UI with results returned from server, e.g.
const resultsContainer = document.createElement('div');
resultsContainer.className = 'c-results-container';
data.forEach(datum => {
const result = document.createElement('div');
result.textContent = datum;
result.tabIndex = "0"; // So you can focus/tab through the results
result.className = 'c-results-container__result';
resultsContainer.appendChild(result);
});
document.querySelector('[data-component-autocomplete]').insertAdjacentElement('afterend', resultsContainer);
};
const onSelect = result => {
// Update UI with selected result
}
const onError = error => {
// Update UI with error state
// Optionally call myAutoComplete.disable();
}
const args = {
selector: '[data-component-autocomplete]',
onSelect: onSelect, // OPTIONAL
searchError: onError, // OPTIONAL
endpoint: 'autocomplete?q=', // OPTIONAL: Provide an endpoint if you want the component to request data
staticResultsData: // OPTIONAL: Provide JSON if you want to fetch data and transform it yourself. If both endpoint and data are supplied, data will be used.
timeout: 2000, // OPTIONAL: Set a timeout for the fetch request, onError will be called if fetch request timeouts, default is 2000.
minCars: 1, // OPTIONAL: Minimum characters to be typed before request is sent, default is 0.
inputDelay: 300, // OPTIONAL: Delay between keypress and request being sent, default is 300.
headers: { // OPTIONAL
Accept: 'application/json; version=2'
},
resultsContainerSelector: '.c-results-container',
resultSelector: '.c-results-container__result',
resultsCallBack: onResults
};
const myAutoComplete = autoComplete(args);
myAutoComplete.enable();
```
# HTML
<input type="text" autocomplete="off" class="c-autocomplete" data-component-autocomplete>
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