2.3.1 • Published 5 years ago

mag-component-radio-list v2.3.1

Weekly downloads
3
License
MIT
Repository
github
Last release
5 years ago

Radio list component

build status npm version dependencies status devDependencies status Gitter

Radio 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-radio-list

Usage

Add the constructor to the scope:

var RadioList = require('mag-component-radio-list');

Create radio list instance:

var radioList = new RadioList({
    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: 'string'},
        {state: true, title: 'Some title 2', value: 'number'},
        {state: false, title: 'Some title 3', value: 'object'}
    ]
});

To change data after creation:

radioList.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:

radioList.checkIndex(index);

To reset to init state (data and focusIndex):

radioList.resetData();

To uncheck all items:

radioList.clearChecked(newFocusPosition);

To get checked item data:

console.log(radioList.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-radio-list is released under the MIT License.