"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.default = 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 _Ellipsis = _interopRequireDefault(require("../common/Ellipsis"));
var _generateDataAttr = require("../utils/generateDataAttr");
var _ButtonSt = require("./Button.st.css.js");
var _WixStyleReactDefaultsOverrideProvider = require("../WixStyleReactDefaultsOverrideProvider");
var _deprecationLog = _interopRequireDefault(require("../utils/deprecationLog"));
var _ButtonCore = _interopRequireDefault(require("./ButtonCore"));
var _excluded = ["skin", "priority", "size", "className", "fullWidth", "children", "dataHook", "ellipsis", "showTooltip", "internalDataHook", "tooltipProps"];
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/Button/Button.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; }
class Button extends _react.PureComponent {
  constructor(props) {
    super(props);
    this.button = /*#__PURE__*/_react.default.createRef();
    /**
     * Sets focus on the element
     */
    this.focus = options => {
      this.button.current && this.button.current.focus(options);
    };
    /**
     * Returns the size and position of the element
     */
    this.getBoundingClientRect = () => {
      var _this$button$current;
      return (_this$button$current = this.button.current) == null ? void 0 : _this$button$current.getBoundingClientRect();
    };
    if (props.skin === 'inverted') {
      (0, _deprecationLog.default)('<Button/> - skin="inverted" is deprecated and will be removed in next major version, please use skin="standard" and priority="secondary" instead');
    }
  }
  render() {
    var {
      button: buttonPropsDefaults
    } = this.context;
    var _this$props = this.props,
      {
        skin = 'standard',
        priority = 'primary',
        size = buttonPropsDefaults.size,
        className,
        fullWidth,
        children,
        dataHook,
        ellipsis,
        showTooltip,
        internalDataHook,
        tooltipProps = {}
      } = _this$props,
      rest = (0, _objectWithoutProperties2.default)(_this$props, _excluded);
    return /*#__PURE__*/_react.default.createElement(_Ellipsis.default, (0, _extends2.default)({
      ellipsis: ellipsis,
      showTooltip: showTooltip
    }, tooltipProps, {
      render: _ref => {
        var {
          ref,
          ellipsisClasses
        } = _ref;
        return /*#__PURE__*/_react.default.createElement(_ButtonCore.default, (0, _extends2.default)({}, rest, (0, _generateDataAttr.generateDataAttr)(_objectSpread(_objectSpread({}, this.props), {}, {
          size
        }), ['skin', 'size', 'priority']), {
          ref: this.button,
          className: (0, _ButtonSt.st)(_ButtonSt.classes.root, {
            fluid: !!fullWidth,
            skin,
            priority,
            size,
            ellipsis: !!ellipsis
          }, className),
          "data-hook": dataHook,
          "data-hook-internal": internalDataHook,
          contentClassName: ellipsisClasses(),
          contentRef: ref,
          __self: this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 68,
            columnNumber: 11
          }
        }), children);
      },
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 63,
        columnNumber: 7
      }
    }));
  }
}
Button.contextType = _WixStyleReactDefaultsOverrideProvider.WixStyleReactDefaultsOverrideContext;
Button.displayName = 'Button';
var _default = exports.default = Button;
//# sourceMappingURL=Button.js.map