"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.InputNumber = void 0;
var _react = _interopRequireWildcard(require("react"));
var _Input = require("./Input");
var _hooks = require("../../hooks");
var _utils = require("../../utils");
var _excluded = ["decimalLength", "decimalSeparator", "disableAbbreviation", "disabled", "disableMacros", "invalid", "step", "thousandSeparator", "value", "onCancel", "onSave", "onEnterKeyPress", "allowEmptyValue", "onChange", "onClick", "limit", "placeholder", "trimDecimals", "min", "max", "onBlur", "update", "shortenThreshold"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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 = _objectWithoutPropertiesLoose(source, excluded); var key, i; 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; }
function _objectWithoutPropertiesLoose(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]; } return target; }
var InputNumber = exports.InputNumber = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
  var _ref$decimalLength = _ref.decimalLength,
    decimalLength = _ref$decimalLength === void 0 ? 2 : _ref$decimalLength,
    _ref$decimalSeparator = _ref.decimalSeparator,
    decimalSeparator = _ref$decimalSeparator === void 0 ? "." : _ref$decimalSeparator,
    _ref$disableAbbreviat = _ref.disableAbbreviation,
    disableAbbreviation = _ref$disableAbbreviat === void 0 ? false : _ref$disableAbbreviat,
    disabled = _ref.disabled,
    _ref$disableMacros = _ref.disableMacros,
    disableMacros = _ref$disableMacros === void 0 ? false : _ref$disableMacros,
    invalid = _ref.invalid,
    _ref$step = _ref.step,
    step = _ref$step === void 0 ? 1 : _ref$step,
    _ref$thousandSeparato = _ref.thousandSeparator,
    thousandSeparator = _ref$thousandSeparato === void 0 ? "," : _ref$thousandSeparato,
    defaultValue = _ref.value,
    onCancel = _ref.onCancel,
    onSave = _ref.onSave,
    externalEnterKeyPress = _ref.onEnterKeyPress,
    allowEmptyValue = _ref.allowEmptyValue,
    externalOnChange = _ref.onChange,
    externalOnClick = _ref.onClick,
    limit = _ref.limit,
    placeholder = _ref.placeholder,
    _ref$trimDecimals = _ref.trimDecimals,
    trimDecimals = _ref$trimDecimals === void 0 ? true : _ref$trimDecimals,
    min = _ref.min,
    max = _ref.max,
    externalOnBlur = _ref.onBlur,
    _ref$update = _ref.update,
    update = _ref$update === void 0 ? false : _ref$update,
    _ref$shortenThreshold = _ref.shortenThreshold,
    shortenThreshold = _ref$shortenThreshold === void 0 ? 1000 : _ref$shortenThreshold,
    rest = _objectWithoutProperties(_ref, _excluded);
  var inputRef = (0, _react.useRef)(null);
  var handleRef = (0, _utils.useForkRef)(ref, inputRef);
  var _useInputNumber = (0, _hooks.useInputNumber)({
      decimalLength,
      decimalSeparator,
      disableAbbreviation,
      disableMacros,
      step,
      thousandSeparator,
      onEnterKeyPress: externalEnterKeyPress,
      onChange: externalOnChange,
      onClick: externalOnClick,
      value: defaultValue,
      onCancel,
      onSave,
      allowEmptyValue,
      limit,
      trimDecimals,
      min,
      max,
      onBlur: externalOnBlur,
      update,
      shortenThreshold
    }, inputRef),
    value = _useInputNumber.value,
    onBlur = _useInputNumber.onBlur,
    onKeyDown = _useInputNumber.onKeyDown,
    onChange = _useInputNumber.onChange,
    onClick = _useInputNumber.onClick,
    onFocus = _useInputNumber.onFocus,
    onDoubleClick = _useInputNumber.onDoubleClick;
  return /*#__PURE__*/_react.default.createElement(_Input.Input, _extends({}, rest, {
    ref: handleRef,
    placeholder: placeholder,
    value: value,
    type: "text",
    disabled: disabled,
    invalid: invalid,
    onChange: onChange,
    onBlur: onBlur,
    onKeyDown: onKeyDown,
    onClick: onClick,
    onDoubleClick: onDoubleClick,
    onFocus: onFocus,
    "aria-placeholder": placeholder,
    "aria-disabled": disabled,
    "aria-invalid": invalid
  }));
});
InputNumber.displayName = "InputNumber";
//# sourceMappingURL=InputNumber.js.map