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

eck-autocomplete

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eck-autocomplete

Autocomplete web component. Suggests options for an input.

  • 0.1.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

eck-autocomplete

Autocomplete web component. Suggests options for an input.

npm

Get started

Install

CDN
<script
  type="module"
  src="https://unpkg.com/eck-autocomplete@0.1.2/min/eck-autocomplete.js"
></script>
Package and import
npm i --save-exact eck-autocomplete

Importing the entry point will automatically register the custom elements.

import 'eck-autocomplete';

The styles of a custom element can only take effect after the JavaScript has been parsed. This leads to initially unstyled components. This is especially bad in a case like this autocomplete where the content is hidden by default. To prevent this so called FOUC (Flash of unstyled content) you can predefine the default styling globally like this:

/**
  * Global FOUC (Flash of unstyled content) fix specific for autocomplete
  */
eck-autocomplete:not(:defined) {
  display: none;
}

Example HTML

<input id="input1" type="text" />
<eck-autocomplete connected-to-id="input1">
  <eck-autocomplete-option>One</eck-autocomplete-option>
  <eck-autocomplete-option>Two</eck-autocomplete-option>
  <eck-autocomplete-option>Three</eck-autocomplete-option>
</eck-autocomplete>

API

eck-autocomplete

Attributes
NameType (coerced)DescriptionDefault
connected-to-idstringID of the HTML input that the autocomplete panel should be attached to. In case you can't provide an ID you can use the method setInputRef documented in the methods section of these docs.
highlight-first-optionbooleanWhether the first option in the panel should be highlighted when it is opened.false
select-highlighted-optionbooleanWhether an options value should be transfered to the input when highlighted. When pressing ESC the value won't be saved and the input resets to the original value.true
Methods
SignatureDescription
setInputRef(element: HTMLInputElement): voidCan be used to programmatically set the reference to an HTML input element to which the autocomplete panel will attach to.
injectCSS(css: string): voidThe component is encapsulated in a Shadow DOM. To style it you should use the provided custom properties. In case you absolutely have to override some CSS that can't be reached from the outside you can inject it with this method.
Custom Properties

TBD

eck-autocomplete-option

Attributes
NameType (coerced)DescriptionDefault
labelstringOptional string that is used to display the option in contexts that only allow strings (e.g. inputs). If not provided the innerHtml is used.undefined
Properties
NameType (coerced)DescriptionDefault
valueunknownOptional data that is attached to an option.
Methods
SignatureDescription
injectCSS(css: string): voidThe component is encapsulated in a Shadow DOM. To style it you should use the provided custom properties. In case you absolutely have to override some CSS that can't be reached from the outside you can inject it with this method.
Custom Properties

TBD

Events
TypeBubblesInterface for detail value
eck-autocomplete-option-selectedtrueEckAutocompleteOptionSelectEvent
Interfaces
EckAutocompleteOptionSelectEvent
export interface EckAutocompleteOptionSelectEvent {
  /**
   * Optionally provided by the user via the `value` property.
   */
  value: unknown;
  /**
   * Either the label that the user optionally provided via the `label` attribute
   * or otherwise the `innerHTML` of this option.
   */
  label: string;
}

FAQs

Package last updated on 26 May 2022

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