import { text } from '@storybook/addon-knobs';

var list = [{
  text: 'This is a list item in an unordered list'
}, {
  text: 'An unordered list is a list in which the sequence of items is not important. Sometimes, an unordered list is a bulleted list. And this is a long list item in an unordered list that can wrap onto a new line.'
}, {
  text: 'Lists can be nested inside of each other',
  sublist: [{
    text: 'This is a nested list item'
  }, {
    text: 'This is another nested list item in an unordered list'
  }]
}, {
  text: 'This is the last list item'
}];

export default {
  sublist: function sublist(value) {
    var unorderedList = value.length ? value : list;
    var newList = [];
    unorderedList.forEach(function (listItem, idx) {
      var newItem = listItem;
      newItem.text = text('UnorderedList Item' + idx + ': text', listItem.text, 'UnorderedList');
      if (listItem.sublist) {
        listItem.sublist.forEach(function (subItem, subIdx) {
          newItem.sublist[subIdx] = subItem;
          newItem.sublist[subIdx].text = text('UnorderedList SubItem' + subIdx + ': text', subItem.text, 'UnorderedList');
        });
      }
      newList.push(newItem);
    });
    return newList;
  }
};