npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bit-autocomplete

v0.0.1

Published

[![Build Status](https://travis-ci.org/bitovi-components/bit-autocomplete.svg?branch=master)](https://travis-ci.org/bitovi-components/bit-autocomplete)

Downloads

5

Readme

bit-autocomplete

Build Status

An auto-suggest/auto-complete widget for CanJS that can be loaded by:

  • StealJS + ES6
  • npm / Browserify / CJS
  • RequireJS / AMD
  • Standalone

It searches a model on a specified key and renders the results as a list below the search field. The search itself is debounced and delayed. By default, it will wait for 3 characters before doing a search and will then wait 250 milliseconds between keystrokes before doing another search.

Install

npm install bit-autocomplete --save

Usage

bit-autocomplete only requires a search model object passed to it. It assumes that it will need to search the label property of objects, so it will pass something like { label: "apple"} to the findAll method of the model. This can be changed during instantiation of the component by specifying the search-key attribute.

If a selection needs to be monitored, live-bind to the validated property.

Once the user selects an item from the results list, it will be available as the selectedItem property of the viewModel and the search field is updated with the selected item's value.

##Install

ES6

With StealJS, you can import this module directly in a template that is autorendered:

<script type="text/stache" id="demo" can-autorender>
	<can-import from="bit-autocomplete"/>
	<bit-autocomplete model="{model}"></bit-autocomplete>
</script>

<script src="./node_modules/steal/steal.js"
	main="can/view/autorender/">

	import can from "can";
	import MyModel from "models/myModel/";

	can.$("#demo").viewModel().attr({
		model: MyModel
	});
</script>

Alternatively, you can import this module like:

import "bit-tabs";
import MyModel from "models/myModel/";
import can from "can";
import $ from "jquery";
import stache from "can/view/stache/stache";

var template = stache('<bit-autocomplete model="{model}"></bit-autocomplete>');

$("body").append(template({
	model: MyModel
}));

CJS

Use require to load bit-autocomplete and everything else needed to create a template that uses bit-autocomplete:

var can = require("canjs");
var $ = require("jquery");
var MyModel = require("models/myModel");

// Add's bit-autocomplete tag
require("bit-autocomplete");
// Use stache
require("canjs/view/stache/stache");

var template = stache('<bit-autocomplete model="{model}"></bit-autocomplete>');

$("body").append(template({
	model: MyModel
}));

AMD use

Configure the can and jquery paths and the bit-autocomplete package:

<script src="require.js"></script>
<script>
	require.config({
	    paths: {
	        "jquery": "node_modules/jquery/dist/jquery",
	        "can": "node_modules/canjs/dist/amd/can"
	    },
	    packages: [{
	    	name: 'bit-autocomplete',
	    	location: 'node_modules/bit-autocomplete/dist/amd',
	    	main: 'autocomplete'
	    }]
	});
	require(["main-amd"], function(){});
</script>

Make sure you have the css plugin configured also!

Use bit-autocomplete like:

define(["can", "jquery", "models/myModel", "can/view/stache", "bit-tabs"], function(can, $, MyModel){
	var template = stache('<bit-autocomplete model="{model}"></bit-autocomplete>');

	$("body").append(template({
		model: MyModel
	}));
});

Standalone use

Load the global css and js files:

<link rel="stylesheet" type="text/css"
      href="./node_modules/bit-autocomplete/dist/global/bit-autocomplete.css">

<script src='./node_modules/jquery/dist/jquery.js'></script>
<script src='./node_modules/canjs/dist/can.jquery.js'></script>
<script src='./node_modules/canjs/dist/can.stache.js'></script>
<script src='./node_modules/bit-autocomplete/dist/global/bit-autocomplete.js'></script>
<script src='./models/myModel.js'></script>
<script id='main-stache' text='text/stache'>
  <bit-autocomplete model="{model}"></bit-autocomplete>
</script>
<script>
  $("body").append( can.view("main-stache",{
  	model: app.MyModel
  }) );
</script>