Check list is a component to build user interface, an instance of Component module. It is based on mag-component-list.
npm install mag-component-check-listAdd 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);There is a global var
DEVELOPwhich activates additional consistency checks and protection logic not available in release mode.
If you have any problems or suggestions please open an issue according to the contribution rules.
mag-component-check-list is released under the MIT License.