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

featherweight-lists

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

featherweight-lists

Easily create list items!

  • 0.0.3
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Feather Weight UI - ListForm Component

Easily create list items!

var listForm = require('featherweight-lists');
var mainForm = listForm({
  layout: 'horizontal-left',
  onChange: function(inputValue) {
    console.log('input changed! (' + inputValue + ')');
  },
  onAdd: function(item) {
    console.log('item added! (' + item.value + ')');
  },
  onRemove: function(item) {
    console.log('item removed! (' + item.value + ')');
  },
  onClear: function() {
    console.log('wohoo empty! ', mainForm.data()); // logs empty array
  },
  itemTransitionOut: function(el, done) {
    var transitionClass = 'transition-out';
    el.classList.add(transitionClass);
    setTimeout(function(){
        el.classList.remove(transitionClass);
    }, 200);
  }
});

# Run Demo

You can find the example code in `./example.js`.

If you run a simple webserver in this directory to serve `./index.html` and static assets. 

For example with python's `SimpleHTTPServer`:

        $ python -m SimpleHTTPServer

The main demo displays the events and hooks provided by the list form component API.

Options

Each item in a list has a data represenation as follows:

DataItem = { value: String }
Option NameValueDefaultNotes about values
layoutString'vertical-top'viable options are: 'vertical-top', 'vertical-bottom', 'horizontal-left', 'horizontal-right'. See example for layout renderings.
placeholderString'Item Text'
onChangeFunction(value: String)nullvalue is the current value of the text input. This is attached to the input element's keyup event.
onAddFunction(item: DataItem)nullitem is a DataItem, see the above object for reference. Whenever an item is added, this function is called.
onRemoveFunction(item: DataItem)nullitem is a DataItem, see the above object for reference. Whenever an item is removed, this function is called.
onClearFunction()nullthis method clears the items in the list
itemTransitionOutFunction(itemElement: HtmlNode, done: Function)nullitemElement is the container of the current item being removed. By default this is called when the click event is fired on the dom element's remove button. done must be called when your animation is completed to prevent memory leaks.
inputValidationFunction(value: String)value !== ''This function is called when the

ListForm Instance API

Option NameTypeNotes
elHTMLElementThis is the container dom node
clearFunctionThis function clears all the items in the list
dataFunctionThis function returns an array of all the DataItems
destroyFunctionThis clears the data, unbinds even handlers, and removes the dom element

FAQs

Package last updated on 07 Sep 2016

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