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

var _2 = _interopRequireDefault(_);

var _FilterBox = require('./FilterBox.props');

var _FilterBox2 = _interopRequireDefault(_FilterBox);

var _ButtonKnobs = require('../../atoms/buttons/Button/Button.knobs.options');

var _ButtonKnobs2 = _interopRequireDefault(_ButtonKnobs);

var _SelectBoxKnobs = require('../../forms/SelectBox/SelectBox.knobs.options');

var _SelectBoxKnobs2 = _interopRequireDefault(_SelectBoxKnobs);

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

var _InputTextTypeAheadKnobs2 = _interopRequireDefault(_InputTextTypeAheadKnobs);

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

(0, _react3.storiesOf)('organisms', module).addDecorator((0, _addonKnobs.withKnobs)({ escapeHTML: false })).add('FilterBox', function () {
  var organization = {
    label: (0, _addonKnobs.text)('Filterbox organization: label', 'State organization', 'Organization'),
    id: (0, _addonKnobs.text)('Filterbox organization: id', 'state-organization', 'Organization'),
    options: (0, _addonKnobs.object)('Filterbox organization: options', _InputTextTypeAheadKnobs2.default.options.orgSelector, 'Organization'),
    selected: (0, _addonKnobs.optionsKnob)('Filterbox organization: selected', Object.assign.apply(Object, [{}].concat(_InputTextTypeAheadKnobs2.default.options.orgSelector.map(function (option) {
      var _ref;

      return _ref = {}, _ref[option.text] = option.text, _ref;
    }).values())), _InputTextTypeAheadKnobs2.default.options.orgSelector[0].text, { display: 'select' }, 'Organization'),
    placeholder: (0, _addonKnobs.text)('Filterbox organization: placeholder', 'All Organizations', 'Organization'),
    onChange: (0, _addonActions.action)('Filterbox organization typeahead onChange')
  };
  var topic = {
    label: (0, _addonKnobs.text)('Filterbox topic: label', 'Filter by Topic', 'Topic'),
    stackLabel: (0, _addonKnobs.boolean)('Filterbox topic: stackLabel', true, 'Topic'),
    id: 'topic',
    options: (0, _addonKnobs.object)('Filterbox topic: options', _SelectBoxKnobs2.default.options.topics, 'Topic'),
    selected: (0, _addonKnobs.optionsKnob)('Filterbox topic: selected', Object.assign.apply(Object, [{}].concat(_SelectBoxKnobs2.default.options.topics.map(function (option) {
      var _ref2;

      return _ref2 = {}, _ref2[option.text] = option.text, _ref2;
    }).values())), _SelectBoxKnobs2.default.options.topics[0].text, { display: 'select' }, 'Topic'),
    required: (0, _addonKnobs.boolean)('Filterbox topic: required', true, 'Topic')
  };
  var dateRange = {
    label: (0, _addonKnobs.text)('Filterbox dateRange: label', 'Date range', 'Date Range'),
    startDate: (0, _addonKnobs.object)('Filterbox dateRange: startDate', _FilterBox2.default.startDate, 'Date Range'),
    endDate: (0, _addonKnobs.object)('Filterbox dateRange: endDate', _FilterBox2.default.endDate, 'Date Range')
  };
  var type = {
    label: (0, _addonKnobs.text)('Filterbox pressType: label', 'Filter by Type', 'Press Type'),
    id: (0, _addonKnobs.text)('Filterbox pressType: id', 'press-type', 'Press Type'),
    options: (0, _addonKnobs.object)('Filterbox pressType: options', _InputTextTypeAheadKnobs2.default.options.pressTypes, 'Press Type'),
    selected: (0, _addonKnobs.select)('Filterbox pressType: selected', [''].concat(_InputTextTypeAheadKnobs2.default.options.pressTypes.map(function (option) {
      return option.text;
    })), '', 'Press Type'),
    placeholder: (0, _addonKnobs.text)('Filterbox pressType: placeholder', 'All Types', 'Press Type'),
    onChange: (0, _addonActions.action)('Filterbox pressType typeahead onChange')
  };
  var props = {
    active: (0, _addonKnobs.boolean)('Filterbox active', true),
    action: (0, _addonKnobs.text)('Filterbox action', '#'),
    filterLabel: (0, _addonKnobs.text)('Filterbox label', 'Mass.gov search results filter'),
    filterNote: (0, _addonKnobs.text)('Filterbox note', 'This is an additional note for the SR users'),
    pressType: {},
    submitButton: {
      text: (0, _addonKnobs.text)('Filterbox submitButton: text', 'Submit', 'Submit Button'),
      type: (0, _addonKnobs.select)('Filterbox submitButton: type', _ButtonKnobs2.default.type, 'submit', 'Submit Button'),
      size: (0, _addonKnobs.select)('Filterbox submitButton: size', _ButtonKnobs2.default.size, null, 'Submit Button'),
      theme: (0, _addonKnobs.select)('Filterbox submitButton: theme', _ButtonKnobs2.default.theme, '', 'Submit Button'),
      usage: (0, _addonKnobs.select)('Filterbox submitButton: usage', _ButtonKnobs2.default.usage, '', 'Submit Button'),
      outline: (0, _addonKnobs.boolean)('Filterbox submitButton: outline', false, 'Submit Button'),
      onClick: (0, _addonActions.action)('FilterBox submitButton: onClick')
    },
    clearButton: {
      text: (0, _addonKnobs.text)('Filterbox clearButton: text', 'Clear all filters', 'Clear Button'),
      info: (0, _addonKnobs.text)('Filterbox clearButton: aria-label', 'Clear all filters', 'Clear Button'),
      onClearCallback: (0, _addonActions.action)('FilterBox clearButton onClearCallback')
    },
    fields: [{
      class: 'ma__filter-box__organizations ma__filter-box--desktop-hidden',
      component: _react2.default.createElement(_index.InputTextTypeAhead, organization)
    }, {
      class: 'ma__filter-box__topic',
      component: _react2.default.createElement(_index.SelectBox, topic)
    }, {
      class: 'ma__filter-box__type',
      component: _react2.default.createElement(_index.InputTextTypeAhead, type)
    }, {
      class: 'ma__filter-box__date',
      component: _react2.default.createElement(_index.DateRange, dateRange)
    }]
  };
  return _react2.default.createElement(_2.default, props);
});
// import knob options for child patterns