var _excluded = ["componentName", "iconName", "iconPlacement"];
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }; return _extends.apply(this, arguments); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
import React from 'react';
import { action } from '@storybook/addon-actions';
import { Button, Icon } from '../..';
var getIcon = function getIcon(IconName) {
  var IconComponent = Icon[IconName];
  IconComponent.displayName = "Icon.".concat(IconName);
  return React.createElement(IconComponent, {
    color: "currentColor"
  });
};
var include = ['componentName', 'size', 'variant', 'iconName', 'iconPlacement'];
var argTypes = {
  componentName: {
    options: [undefined, 'Pill', 'Icon'],
    control: {
      type: 'inline-radio'
    }
  },
  size: {
    options: ['s', 'm', 'l'],
    control: {
      type: 'inline-radio'
    }
  },
  variant: {
    options: ['primary', 'secondary', 'neutral', 'negative', 'tertiary'],
    control: {
      type: 'inline-radio'
    }
  },
  iconName: {
    options: Object.keys(Icon),
    control: {
      type: 'select'
    }
  },
  iconPlacement: {
    options: ['left', 'right'],
    control: {
      type: 'inline-radio'
    }
  }
};
var Template = function Template(_ref) {
  var componentName = _ref.componentName,
    iconName = _ref.iconName,
    iconPlacement = _ref.iconPlacement,
    rest = _objectWithoutProperties(_ref, _excluded);
  var ButtonComponent = componentName ? Button[componentName] : Button;
  var icon = iconName ? getIcon(iconName) : undefined;
  var commonProps = {
    onClick: action('clicked')
  };
  return componentName === 'Icon' ? React.createElement(ButtonComponent, _extends({}, commonProps, rest), icon || '-') : React.createElement(ButtonComponent, _extends({}, commonProps, {
    icon: icon,
    iconPlacement: iconPlacement
  }, rest), componentName === 'Pill' ? 'Button.Pill' : 'Button');
};
var meta = {
  component: Button,
  title: 'Molecules / Button',
  parameters: {
    controls: {
      sort: 'alpha',
      include: include
    },
    docs: {
      description: {
        component: 'Configure a button here'
      }
    },
    viewMode: 'docs'
  },
  argTypes: argTypes
};
export default meta;
export var ConfigureAButton = {
  render: Template
};