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

ember-cli-auto-complete

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-cli-auto-complete - npm Package Compare versions

Comparing version 0.2.1 to 1.0.0-beta.1

35

addon/components/auto-complete.js

@@ -62,9 +62,5 @@ import Ember from "ember";

self.set("visibility", HIDDEN);
if (!self.get("selectedFromList")) {
var value = this.get("selectedValue");
var optionsToMatch = this.get("optionsToMatch");
if (optionsToMatch.indexOf(value) === -1) {
self.set("inputVal", "");
self.set("selectedValue", "");
}
if (!self.get("selectedFromList") && !self.hasInputMatchingSuggestion()) {
self.set("inputVal", "");
self.set("selectedValue", "");
}

@@ -84,9 +80,5 @@ };

this.set("visibility", HIDDEN);
} else {
var value = this.get("selectedValue");
var optionsToMatch = this.get("optionsToMatch");
if (optionsToMatch.indexOf(value) >= 0) {
this.set("selectedFromList", true);
this.set("visibility", HIDDEN);
}
} else if (this.hasInputMatchingSuggestion()) {
this.set("selectedFromList", true);
this.set("visibility", HIDDEN);
}

@@ -99,2 +91,9 @@ }

onInput: Ember.observer('selectedValue', function() {
var options = this.get("options");
var input = this.getWithDefault("selectedValue", "");
this.set("suggestions", this.determineSuggestions(options, input));
}),
highlight: function (direction) {

@@ -114,2 +113,10 @@ var length = this.get("suggestions").length;

},
hasInputMatchingSuggestion: function() {
var suggestions = this.get('suggestions');
var input = this.getWithDefault('selectedValue', '').toLowerCase();
if (suggestions.length !== 1) { return false; }
return input === suggestions[0].get(this.get('valueProperty')).toLowerCase();
},
actions: {

@@ -116,0 +123,0 @@ selectItem: function (item) {

2

package.json
{
"name": "ember-cli-auto-complete",
"version": "0.2.1",
"version": "1.0.0-beta.1",
"description": "ember-cli addon that provides type-ahead selection for text inputs",

@@ -5,0 +5,0 @@ "directories": {

@@ -21,8 +21,7 @@ # ember-cli-auto-complete

First add a custom component that extends AutoComplete. In this component you need to add 2 computed properties and 1 string variable.
First add a custom component that extends AutoComplete. In this component you need to add 1 function and 1 string variable.
```
1) suggestions: this computed will determine how the list of options is filtered as the user enters text
2) optionsToMatch: this computed will determine if the value entered is valid (when the user omits to click/enter/tab the selection)
3) valueProperty: this string should be the value property for the options passed in (think selectbox value/label)
1) determineSuggestions: this function will determine how the list of options is filtered as the user enters text (it gets passed the available options and the users input)
2) valueProperty: this string should be the value property for the options passed in (think selectbox value/label)
```

@@ -35,17 +34,9 @@

valueProperty: "code",
suggestions: function() {
var inputVal = this.get("inputVal") || "";
return this.get("options").filter(function(item) {
return item.get("code").toLowerCase().indexOf(inputVal.toLowerCase()) > -1;
determineSuggestions: function(options, input) {
var list = options.filter(function(item) {
return item.get("code").toLowerCase().indexOf(input.toLowerCase()) > -1;
});
}.property("inputVal", "options.@each"),
optionsToMatch: function() {
var caseInsensitiveOptions = [];
this.get("options").forEach(function(item) {
var value = item.get("code");
caseInsensitiveOptions.push(value);
caseInsensitiveOptions.push(value.toLowerCase());
});
return caseInsensitiveOptions;
}.property("options.@each")
return Ember.A(list);
}
});

@@ -52,0 +43,0 @@ ```

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