"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.ScrollButton = exports.default = void 0;

var _kind = _interopRequireDefault(require("@enact/core/kind"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _react = _interopRequireDefault(require("react"));

var _IconButton = _interopRequireDefault(require("../IconButton"));

var _Scrollbar = _interopRequireDefault(require("./Scrollbar.less"));

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

function _extends() { _extends = Object.assign || 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 = {}; 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]; } 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; }

/**
 * An [IconButton]{@link moonstone/IconButton.IconButton} used within
 * a [Scrollbar]{@link moonstone/Scrollable.Scrollbar}.
 *
 * @class ScrollButton
 * @memberof moonstone/Scrollable
 * @extends moonstone/IconButton.IconButton
 * @ui
 * @private
 */
var ScrollButton = (0, _kind.default)({
  name: 'ScrollButton',
  propTypes:
  /** @lends moonstone/Scrollable.ScrollButton.prototype */
  {
    /**
     * Name of icon.
     *
     * @type {String}
     * @required
     * @public
     */
    children: _propTypes.default.string.isRequired,

    /**
    * Sets the hint string read when focusing the scroll bar button.
    *
    * @type {String}
    * @memberof moonstone/Scrollable.ScrollButton.prototype
    * @public
    */
    'aria-label': _propTypes.default.string,

    /**
     * Sets the `aria-label`.
     *
     * @type {Boolean}
     * @default false
     * @public
     */
    active: _propTypes.default.bool,

    /**
     * Disables the button.
     *
     * @type {Boolean}
     * @public
     */
    disabled: _propTypes.default.bool
  },
  styles: {
    css: _Scrollbar.default,
    className: 'scrollButton'
  },
  computed: {
    'aria-label': function ariaLabel(_ref) {
      var active = _ref.active,
          _ariaLabel = _ref['aria-label'];
      return active ? null : _ariaLabel;
    }
  },
  render: function render(_ref2) {
    var children = _ref2.children,
        disabled = _ref2.disabled,
        rest = _objectWithoutProperties(_ref2, ["children", "disabled"]);

    delete rest.active;
    return _react.default.createElement(_IconButton.default, _extends({}, rest, {
      backgroundOpacity: "transparent",
      disabled: disabled,
      small: true
    }), children);
  }
});
exports.ScrollButton = ScrollButton;
var _default = ScrollButton;
exports.default = _default;