Socket
Socket
Sign inDemoInstall

uc-form

Package Overview
Dependencies
3
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    uc-form

Form mixin for custom forms with tab key navigation support


Version published
Maintainers
1
Install size
33.8 kB
Created

Readme

Source

Unchained UI

Form

NPM Version NPM Downloads

Form mixin for custom forms with tab key navigation support

Usage

import compose from 'uc-compose'
import form from 'uc-form'

const MyClass = function(el) {
  this.el = el;
  this.addForm();
}
MyClass.prototype = compose(
  form,
  {
    done: function() {
      // clicked on the anchor element with #/done hash
      // or button with done value
      console.log('Done!');
    },

    '13': function() {
      console.log('Enter is pressed');
    },

    remove: function() {
      this.removeForm();
    }
  }
)

Methods

addForm()

Adds all the events listeners:

  • Prevents default behavior for all the links with hash.
  • Executes method with the name as:
    • #/name for links
    • value="name" for buttons
  • Document keydown:
    • If the class has the method with keyCode as its name, it will be executed
    • If enter or space is pressed and the active element is an anchor or button it the click will be executed.
    • When tab is pressed, the focus follows [tabindex]. Works for custom UI elements as well.
removeForm()

Removes all the events listeners.

License MIT

© velocityzen

Keywords

FAQs

Last updated on 09 Sep 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc