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; };

import React from 'react';
import { storiesOf } from '@storybook/react';
import { withKnobs, boolean } from '@storybook/addon-knobs';
import { action } from '@storybook/addon-actions';

import TabContainer from '../../..';
import Tab from './tab';
import TabContainerData from './TabContainer.knobs.options';

var tabProps = {
  handleClick: action('Tab click')
};

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

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