mag-component-check-list

1.3.1 • Public • Published

Check list component

build status npm version dependencies status devDependencies status Gitter

Check list is a component to build user interface, an instance of Component module. It is based on mag-component-list.

Installation

npm install mag-component-check-list

Usage

Add the constructor to the scope:

var CheckList = require('mag-component-check-list');

Create check list instance:

var checkList = new CheckList({
    focusIndex: 0,
    classIcon: 'theme-icon theme-icon-checkbox',
    classIconActive: 'theme-icon theme-icon-checkbox-active',
    classChecked: 'checked',
    data: [
        {state: false, title: 'Some title 1', value: 'value 1'},
        {state: true, title: 'Some title 2', value: 'value 2'},
        {state: false, title: 'Some title 3', value: 'value 3'}
    ]
});

To change data after creation:

checkList.setData({
    focusIndex: 0,
    data: [
        {state: false, title: 'Some title 1', value: 'value 1'},
        {state: true, title: 'Some title 2', value: 'value 2'},
        {state: false, title: 'Some title 3', value: 'value 3'}
    ]
});

To change item state:

checkList.changeState($domItem);

To reset to init state (data and focusIndex):

checkList.resetData();

To uncheck all items:

checkList.clearChecked(newFocusPosition);

To get all checked items data:

console.log(checkList.checkedData);

Development mode

There is a global var DEVELOP which activates additional consistency checks and protection logic not available in release mode.

Contribution

If you have any problems or suggestions please open an issue according to the contribution rules.

License

mag-component-check-list is released under the MIT License.

Package Sidebar

Install

npm i mag-component-check-list

Weekly Downloads

3

Version

1.3.1

License

MIT

Unpacked Size

21.4 kB

Total Files

22

Last publish

Collaborators

  • magsdk