'use strict';

exports.__esModule = true;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _Input = require('../Input');

var _Input2 = _interopRequireDefault(_Input);

var _CompoundSlider = require('../CompoundSlider');

var _CompoundSlider2 = _interopRequireDefault(_CompoundSlider);

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

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

var InputSlider = function InputSlider(props) {
  var axis = props.axis,
      max = props.max,
      min = props.min,
      step = props.step,
      ticks = props.ticks,
      onChange = props.onChange,
      onUpdate = props.onUpdate,
      domain = props.domain,
      skipped = props.skipped,
      displayValueFormat = props.displayValueFormat,
      inputProps = _objectWithoutProperties(props, ['axis', 'max', 'min', 'step', 'ticks', 'onChange', 'onUpdate', 'domain', 'skipped', 'displayValueFormat']);

  var sliderProps = {
    axis: axis, max: max, min: min, step: step, defaultValue: props.defaultValue, onChange: onChange, onUpdate: onUpdate, domain: domain, skipped: skipped, displayValueFormat: displayValueFormat
  };
  var id = inputProps.id,
      disabled = inputProps.disabled;

  sliderProps.id = id;
  sliderProps.ticks = new Map(ticks);
  sliderProps.disabled = disabled;
  return _react2.default.createElement(
    _Input2.default,
    inputProps,
    _react2.default.createElement(_CompoundSlider2.default, sliderProps)
  );
};

InputSlider.propTypes = process.env.NODE_ENV !== "production" ? {
  /** Whether the label should be hidden or not */
  hiddenLabel: _propTypes2.default.bool,
  /** The label text for the input field */
  labelText: _propTypes2.default.string.isRequired,
  /** The unique ID for the input field */
  id: _propTypes2.default.string.isRequired,
  /** Custom change function */
  onChange: _propTypes2.default.func,
  /** Custom change function */
  onUpdate: _propTypes2.default.func,
  /** Default input text value */
  defaultValue: _propTypes2.default.string,
  /** Max value for the field. */
  max: _propTypes2.default.number.isRequired,
  /** Min value for the field. */
  min: _propTypes2.default.number.isRequired,
  /** This controls how much sliding the handle increments/decrements the value of the slider. */
  step: _propTypes2.default.number,
  /** An array where each entry is an array of [key,value] pairs. The key (number inclusively between min and max) and value (label to display at the key) are used for displaying tick marks. */
  ticks: _propTypes2.default.arrayOf(_propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.number])),
  /** The direction for the slider, where x is horizontal and y is vertical. */
  axis: _propTypes2.default.oneOf(['x', 'y']),
  /** Disables the slider if true. */
  disabled: _propTypes2.default.bool,
  /** Whether input is required or not */
  required: _propTypes2.default.bool,
  /** The range of numbers, inclusively, for the slider to fall between. First number is the min and second number is the max. */
  domain: _propTypes2.default.arrayOf(_propTypes2.default.number),
  /** Whether to skip the slider with keyboard interaction and hide the slider on screen readers. */
  skipped: _propTypes2.default.bool,
  /** Display the value of the slider based. If null, don't display. If equals percentage, format the value in percentage. */
  displayValueFormat: _propTypes2.default.oneOf(['percentage', 'value', null])
} : {};

InputSlider.defaultProps = {
  defaultValue: 0,
  disabled: false
};

exports.default = InputSlider;
module.exports = exports['default'];