1.0.0 • Published 7 years ago
uc-form v1.0.0
Unchained UI
Form
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:
#/namefor linksvalue="name"for buttons
- Document
keydown:- If the class has the method with keyCode as its name, it will be executed
- If
enterorspaceis pressed and the active element is an anchor or button it theclickwill be executed. - When
tabis pressed, the focus follows[tabindex]. Works for custom UI elements as well.
removeForm()
Removes all the events listeners.
License MIT
© velocityzen
1.0.0
7 years ago