"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = exports.IconButton = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _react = _interopRequireWildcard(require("react"));
var _IconButton = require("./IconButton.constants");
var _generateDataAttr = require("../utils/generateDataAttr");
var _IconButtonSt = require("./IconButton.st.css.js");
var _WixStyleReactDefaultsOverrideProvider = require("../WixStyleReactDefaultsOverrideProvider");
var _deprecationLog = _interopRequireDefault(require("../utils/deprecationLog"));
var _ButtonCore = _interopRequireDefault(require("../Button/ButtonCore"));
var _excluded = ["skin", "className", "priority", "size", "children", "disabled", "dataHook", "ariaLabel", "ariaLabelledBy"];
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/IconButton/IconButton.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var IconButton = exports.IconButton = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
  if (props.skin === 'inverted') {
    (0, _deprecationLog.default)('<IconButton/> - skin="inverted" is deprecated and will be removed in next major version, please use skin="standard" and priority="secondary" instead');
  }
  var defaultOverrides = _react.default.useContext(_WixStyleReactDefaultsOverrideProvider.WixStyleReactDefaultsOverrideContext);
  var buttonRef = _react.default.useRef(null);
  (0, _react.useImperativeHandle)(ref, () => {
    return {
      focus() {
        buttonRef.current && buttonRef.current.focus();
      }
    };
  }, [buttonRef]);
  var {
    button: buttonPropsDefaults
  } = defaultOverrides;
  var {
      skin = 'standard',
      className,
      priority = 'primary',
      size = buttonPropsDefaults.size,
      children,
      disabled = false,
      dataHook,
      ariaLabel,
      ariaLabelledBy
    } = props,
    rest = (0, _objectWithoutProperties2.default)(props, _excluded);
  var childSize = _IconButton.ICON_CHILD_SIZE[size];
  return /*#__PURE__*/_react.default.createElement(_ButtonCore.default, (0, _extends2.default)({}, rest, {
    disabled: disabled,
    ref: buttonRef,
    className: (0, _IconButtonSt.st)(_IconButtonSt.classes.root, {
      skin,
      priority,
      size
    }, className)
  }, (0, _generateDataAttr.generateDataAttr)(_objectSpread(_objectSpread({}, props), {}, {
    size
  }), ['skin', 'size', 'priority']), {
    "data-hook": dataHook,
    "aria-label": ariaLabel,
    "aria-labelledby": ariaLabelledBy,
    __self: void 0,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 51,
      columnNumber: 7
    }
  }), children && /*#__PURE__*/_react.default.cloneElement(children, {
    size: childSize,
    width: childSize,
    height: childSize,
    'aria-hidden': true
  }));
});
IconButton.displayName = 'IconButton';
var _default = exports.default = IconButton;
//# sourceMappingURL=IconButton.js.map