"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

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

var _element = require("@wordpress/element");

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _classnames = _interopRequireDefault(require("classnames"));

var _compose = require("@wordpress/compose");

var _baseControl = _interopRequireDefault(require("../base-control"));

var _flex = require("../flex");

var _numberControl = _interopRequireDefault(require("../number-control"));

var _angleCircle = _interopRequireDefault(require("./angle-circle"));

var _anglePickerControlStyles = require("./styles/angle-picker-control-styles");

/**
 * External dependencies
 */

/**
 * WordPress dependencies
 */

/**
 * Internal dependencies
 */
function AnglePickerControl(_ref) {
  var className = _ref.className,
      idProp = _ref.id,
      value = _ref.value,
      onChange = _ref.onChange,
      label = _ref.label,
      props = (0, _objectWithoutProperties2.default)(_ref, ["className", "id", "value", "onChange", "label"]);
  var instanceId = (0, _compose.useInstanceId)(AnglePickerControl, 'components-angle-picker-control__input');
  var id = idProp || instanceId;

  var handleOnNumberChange = function handleOnNumberChange(unprocessedValue) {
    var inputValue = unprocessedValue !== '' ? parseInt(unprocessedValue, 10) : 0;
    onChange(inputValue);
  };

  var classes = (0, _classnames.default)('components-angle-picker-control', className);
  return (0, _element.createElement)(_baseControl.default, (0, _extends2.default)({
    className: classes,
    id: id,
    label: label
  }, props), (0, _element.createElement)(_anglePickerControlStyles.Root, {
    gap: 3
  }, (0, _element.createElement)(_anglePickerControlStyles.NumberControlWrapper, null, (0, _element.createElement)(_numberControl.default, {
    className: "components-angle-picker-control__input-field",
    id: id,
    max: 360,
    min: 0,
    onChange: handleOnNumberChange,
    step: "1",
    value: value
  })), (0, _element.createElement)(_flex.FlexBlock, null, (0, _element.createElement)(_angleCircle.default, {
    "aria-hidden": "true",
    value: value,
    onChange: onChange
  }))));
}
//# sourceMappingURL=index.js.map