'use strict';

var _extends = require('@babel/runtime/helpers/extends');
var React = require('react');
var PropTypes = require('prop-types');
var Button = require('../Button/Button.js');
var Settings = require('../../constants/Settings.js');
var iconsReact = require('@carbon/icons-react');

function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }

var _extends__default = /*#__PURE__*/_interopDefault(_extends);
var React__default = /*#__PURE__*/_interopDefault(React);
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);

var iotPrefix = Settings.settings.iotPrefix;
var propTypes = {
  i18n: PropTypes__default.default.shape({
    zoomIn: PropTypes__default.default.string,
    zoomOut: PropTypes__default.default.string
  }),
  /** callback to handle zoom in */
  onZoomIn: PropTypes__default.default.func.isRequired,
  /** callback to handle zoom out */
  onZoomOut: PropTypes__default.default.func.isRequired,
  /** set true to use button size 'small' instead of size 'field' */
  smallButtons: PropTypes__default.default.bool,
  testId: PropTypes__default.default.string,
  /** position of the control buttons tooltip */
  tooltipPosition: PropTypes__default.default.oneOf(['left', 'top', 'bottom', 'right']).isRequired
};
var defaultProps = {
  i18n: {
    zoomIn: 'Zoom In',
    zoomOut: 'Zoom out'
  },
  smallButtons: false,
  testId: 'map-zoom-control'
};
var Zoom = function Zoom(_ref) {
  var onZoomIn = _ref.onZoomIn,
    onZoomOut = _ref.onZoomOut,
    i18n = _ref.i18n,
    testId = _ref.testId,
    tooltipPosition = _ref.tooltipPosition,
    smallButtons = _ref.smallButtons;
  var buttonSize = smallButtons ? 'sm' : 'md';
  return /*#__PURE__*/React__default.default.createElement("div", {
    className: "".concat(iotPrefix, "--map-zoom"),
    "data-testid": testId
  }, /*#__PURE__*/React__default.default.createElement(Button, {
    renderIcon: function renderIcon(props) {
      return /*#__PURE__*/React__default.default.createElement(iconsReact.ZoomIn, _extends__default.default({
        size: 16
      }, props));
    },
    hasIconOnly: true,
    kind: "ghost",
    size: buttonSize,
    onClick: onZoomIn,
    tooltipPosition: tooltipPosition,
    iconDescription: i18n.zoomIn,
    testId: "".concat(testId, "-zoom-in")
  }), /*#__PURE__*/React__default.default.createElement(Button, {
    renderIcon: function renderIcon(props) {
      return /*#__PURE__*/React__default.default.createElement(iconsReact.ZoomOut, _extends__default.default({
        size: 16
      }, props));
    },
    hasIconOnly: true,
    kind: "ghost",
    size: buttonSize,
    onClick: onZoomOut,
    tooltipPosition: tooltipPosition,
    iconDescription: i18n.zoomOut,
    testId: "".concat(testId, "-zoom-out")
  }));
};
Zoom.defaultProps = defaultProps;
Zoom.propTypes = propTypes;
Zoom.__docgenInfo = {
  "description": "",
  "methods": [],
  "displayName": "Zoom",
  "props": {
    "i18n": {
      "defaultValue": {
        "value": "{\n  zoomIn: 'Zoom In',\n  zoomOut: 'Zoom out',\n}",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "shape",
        "value": {
          "zoomIn": {
            "name": "string",
            "required": false
          },
          "zoomOut": {
            "name": "string",
            "required": false
          }
        }
      },
      "required": false
    },
    "smallButtons": {
      "defaultValue": {
        "value": "false",
        "computed": false
      },
      "description": "set true to use button size 'small' instead of size 'field'",
      "type": {
        "name": "bool"
      },
      "required": false
    },
    "testId": {
      "defaultValue": {
        "value": "'map-zoom-control'",
        "computed": false
      },
      "description": "",
      "type": {
        "name": "string"
      },
      "required": false
    },
    "onZoomIn": {
      "description": "callback to handle zoom in",
      "type": {
        "name": "func"
      },
      "required": true
    },
    "onZoomOut": {
      "description": "callback to handle zoom out",
      "type": {
        "name": "func"
      },
      "required": true
    },
    "tooltipPosition": {
      "description": "position of the control buttons tooltip",
      "type": {
        "name": "enum",
        "value": [{
          "value": "'left'",
          "computed": false
        }, {
          "value": "'top'",
          "computed": false
        }, {
          "value": "'bottom'",
          "computed": false
        }, {
          "value": "'right'",
          "computed": false
        }]
      },
      "required": true
    }
  }
};
var ZoomControl = Zoom;

module.exports = ZoomControl;
