'use strict';

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 _index = require('./index');

var _index2 = _interopRequireDefault(_index);

var _OrgSelector = require('./OrgSelector.md');

var _OrgSelector2 = _interopRequireDefault(_OrgSelector);

var _OrgSelectorKnobs = require('./OrgSelector.knobs.options');

var _OrgSelectorKnobs2 = _interopRequireDefault(_OrgSelectorKnobs);

var _InputTextTypeAheadKnobs = require('../InputTextTypeAhead/InputTextTypeAhead.knobs.options');

var _InputTextTypeAheadKnobs2 = _interopRequireDefault(_InputTextTypeAheadKnobs);

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

(0, _react3.storiesOf)('forms|molecules/OrgSelector', module).addDecorator((0, _addonKnobs.withKnobs)({ escapeHTML: false })).add('OrgSelector with SelectBox', function () {
  var props = {
    organizations: (0, _addonKnobs.object)('organizations', _OrgSelectorKnobs2.default.organizations, 'Organizations'),
    onChangeOrgCallback: (0, _addonActions.action)('OrgSelector onChangeOrgCallback')
  };
  var selected = _InputTextTypeAheadKnobs2.default.options.orgSelector[0].text;
  var selectedList = _InputTextTypeAheadKnobs2.default.options.orgSelector.map(function (option) {
    var opt = {};
    opt[option.text] = option.text;
    return opt;
  });
  props.selectBox = {
    label: (0, _addonKnobs.text)('label', 'State Organization'),
    stackLabel: (0, _addonKnobs.boolean)('stackLabel', true),
    id: (0, _addonKnobs.text)('id', 'state-organization'),
    options: (0, _addonKnobs.object)('options', _InputTextTypeAheadKnobs2.default.options.orgSelector, 'Options'),
    selected: (0, _addonKnobs.optionsKnob)('defaultSelected', Object.assign.apply(Object, [{}].concat(selectedList.values())), selected, { display: 'select' })
  };
  return _react2.default.createElement(_index2.default, props);
}, { info: _OrgSelector2.default }).add('OrgSelector with TypeAhead', function () {
  var props = {
    organizations: (0, _addonKnobs.object)('organizations', _OrgSelectorKnobs2.default.organizations, 'Organizations'),
    onChangeOrgCallback: (0, _addonActions.action)('OrgSelector onChangeOrgCallback')
  };
  var selectedList = _InputTextTypeAheadKnobs2.default.options.orgSelector.map(function (option) {
    var opt = {};
    opt[option.text] = option.text;
    return opt;
  });
  props.typeAhead = {
    label: (0, _addonKnobs.text)('label', 'State Organization'),
    id: (0, _addonKnobs.text)('id', 'state-organization'),
    options: (0, _addonKnobs.object)('options', _InputTextTypeAheadKnobs2.default.options.orgSelector, 'Options'),
    selected: (0, _addonKnobs.optionsKnob)('defaultSelected', Object.assign.apply(Object, [{}].concat(selectedList.values())), '', { display: 'select' }),
    placeholder: (0, _addonKnobs.text)('placeholder', 'All Organizations')
  };

  return _react2.default.createElement(_index2.default, props);
}, { info: _OrgSelector2.default });