'use strict';

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _react3 = require('@storybook/react');

var _addonKnobs = require('@storybook/addon-knobs');

var _addonActions = require('@storybook/addon-actions');

var _ = require('../../..');

var _2 = _interopRequireDefault(_);

var _tab = require('./tab');

var _tab2 = _interopRequireDefault(_tab);

var _TabContainerKnobs = require('./TabContainer.knobs.options');

var _TabContainerKnobs2 = _interopRequireDefault(_TabContainerKnobs);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var tabProps = {
  handleClick: (0, _addonActions.action)('Tab click')
};

(0, _react3.storiesOf)('organisms/TabContainer', module).addDecorator((0, _addonKnobs.withKnobs)({ escapeHTML: false })).add('TabContainer', function () {
  var props = {
    nested: (0, _addonKnobs.boolean)('nested', true)
  };

  return _react2.default.createElement(
    _2.default,
    { onTabChange: (0, _addonActions.action)('Tab change') },
    _react2.default.createElement(
      _tab2.default,
      _extends({ title: 'Tab 1' }, tabProps),
      _react2.default.createElement(
        _2.default,
        _extends({}, props, { onTabChange: (0, _addonActions.action)('Tab change') }),
        _react2.default.createElement(
          _tab2.default,
          _extends({ title: 'Nested Tab Here' }, tabProps),
          'This should support nesting like this.'
        ),
        _react2.default.createElement(
          _tab2.default,
          _extends({ title: 'Another Nested Tab' }, tabProps),
          'Tabs have unique ids that are tracked locally without state.'
        )
      )
    ),
    _react2.default.createElement(
      _tab2.default,
      _extends({ title: 'Tab 2' }, tabProps),
      'And this is my second tab.'
    ),
    _react2.default.createElement(
      _tab2.default,
      _extends({ title: 'Tab 3' }, tabProps),
      'Last Tab!'
    ),
    _react2.default.createElement(
      _tab2.default,
      _extends({ title: 'Tab' }, tabProps),
      'Tab Content'
    ),
    _react2.default.createElement(
      _tab2.default,
      _extends({ title: 'Tab' }, tabProps),
      'Tab Content'
    ),
    _react2.default.createElement(
      _tab2.default,
      _extends({ title: 'Tab' }, tabProps),
      'Tab Content'
    ),
    _react2.default.createElement(
      _tab2.default,
      _extends({ title: 'Tab' }, tabProps),
      'Tab Content'
    ),
    _react2.default.createElement(
      _tab2.default,
      _extends({ title: 'Tab' }, tabProps),
      'Tab Content'
    ),
    _react2.default.createElement(
      _tab2.default,
      _extends({ title: 'Tab' }, tabProps),
      'Tab Content'
    )
  );
}).add('TabContainer with real data', function () {
  var props = {
    nested: (0, _addonKnobs.boolean)('nested', true)
  };
  if (_TabContainerKnobs2.default.budgetTabs) {
    return _react2.default.createElement(
      _2.default,
      { onTabChange: (0, _addonActions.action)('Tab change') },
      _TabContainerKnobs2.default.budgetTabs.map(function (tab, index) {
        return (
          /* eslint-disable-next-line react/no-array-index-key */
          _react2.default.createElement(
            _tab2.default,
            _extends({ key: 'tab' + index, title: tab.tab }, tabProps),
            tab.subTabs && _react2.default.createElement(
              _2.default,
              _extends({}, props, { onTabChange: (0, _addonActions.action)('Tab change') }),
              tab.subTabs.map(function (item, i) {
                return (
                  /* eslint-disable-next-line react/no-array-index-key */
                  _react2.default.createElement(
                    _tab2.default,
                    _extends({ key: 'subTab' + i, title: item.tab }, tabProps),
                    item.content
                  )
                );
              })
            ),
            tab.content
          )
        );
      })
    );
  }
  return null;
});