'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _babelHelperVueJsxMergeProps = require('babel-helper-vue-jsx-merge-props');

var _babelHelperVueJsxMergeProps2 = _interopRequireDefault(_babelHelperVueJsxMergeProps);

var _lib = require('../../lib');

var _PropTypes = require('../../lib/PropTypes');

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

exports.default = {
  name: 'SuiButton',
  props: {
    active: {
      type: Boolean,
      description: 'A button can show it is currently the active user selection.'
    },
    animated: (0, _PropTypes.Enum)(['fade', 'vertical'], {
      type: Boolean,
      description: 'A button can animate to show hidden content.'
    }),
    attached: (0, _PropTypes.Enum)(['left', 'right', 'top', 'bottom'], {
      description: 'A button can be attached to the top or bottom of other content.'
    }),
    basic: {
      type: Boolean,
      description: 'A basic button is less pronounced.'
    },
    circular: {
      type: Boolean,
      description: 'A button can be circular.'
    },
    className: {
      type: String,
      description: 'Additional classes.'
    },
    color: _PropTypes.Enum.Color,
    compact: {
      type: Boolean,
      description: 'A button can reduce its padding to fit into tighter spaces.'
    },
    content: {
      type: String,
      description: 'Shorthand for primary content.'
    },
    disabled: {
      type: Boolean,
      description: 'A button can show it is currently unable to be interacted with.'
    },
    floated: {
      type: String,
      description: 'A button can be aligned to the left or right of its container.'
    },
    fluid: {
      type: Boolean,
      description: 'A button can take the width of its container.'
    },
    icon: String,
    inverted: {
      type: Boolean,
      description: 'A button can be formatted to appear on dark backgrounds.'
    },
    // label: {
    //   type: String,
    //   description: 'Add a Label by text, props object, or pass a <Label />.',
    // },
    labelPosition: (0, _PropTypes.Enum)(['left', 'right'], {
      description: 'A labeled button can format a Label or Icon to appear on the left or right.'
    }),
    loading: {
      type: Boolean,
      description: 'A button can show a loading indicator.'
    },
    negative: {
      type: Boolean,
      description: 'A button can hint towards a negative consequence.'
    },
    positive: {
      type: Boolean,
      description: 'A button can hint towards a positive consequence.'
    },
    primary: {
      type: Boolean,
      description: 'A button can be formatted to show different levels of emphasis.'
    },
    secondary: {
      type: Boolean,
      description: 'A button can be formatted to show different levels of emphasis.'
    },
    size: _PropTypes.Enum.Size,
    tabIndex: {
      type: [Number, String],
      description: 'A button can receive focus.'
    },
    toggle: {
      type: Boolean,
      description: 'A button can be formatted to toggle on and off.'
    }
  },
  render: function render() {
    var h = arguments[0];

    var ElementType = (0, _lib.getElementType)(this, 'button');

    var label = this.$slots.label;

    var classList = (0, _lib.classes)('ui', this.inverted && 'inverted', !label && this.labelPosition && this.labelPosition, !label && this.labelPosition && 'labeled', this.attached, this.attached && 'attached', this.color, this.size, this.primary && 'primary', this.disabled && 'disabled', this.loading && 'loading', this.compact && 'compact', this.secondary && 'secondary', this.positive && 'positive', this.negative && 'negative', this.basic && 'basic', this.icon && !(this.content || this.$slots.default) && 'icon', !label && this.icon && this.labelPosition && 'icon', 'button');

    var button = h(
      ElementType,
      (0, _babelHelperVueJsxMergeProps2.default)([(0, _lib.getChildProps)(this), {
        'class': classList,
        attrs: { role: 'button'
        }
      }]),
      [this.icon && h(
        'suiIcon',
        {
          attrs: { name: this.icon }
        },
        []
      ), this.content || this.$slots.default]
    );

    if (label) {
      return h(
        'div',
        { 'class': (0, _lib.classes)('ui', this.labelPosition, 'labeled', 'button') },
        [this.labelPosition === 'left' && label, button, this.labelPosition !== 'left' && label]
      );
    }

    return button;
  }
};