"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.InputHours = void 0;
var _react = _interopRequireWildcard(require("react"));
var _Input = require("./Input");
var _useInputHours2 = require("../../hooks/useInputHours");
var _utils = require("../../utils");
var _useForkRef = _interopRequireDefault(require("../../utils/useForkRef"));
var _excluded = ["value", "onCancel", "onSave", "onEnterKeyPress", "allowEmptyValue", "withLeadingZero", "validation", "incrementOnlySelected", "minuteIncrement", "className", "onChange", "onClick", "align"];
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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 InputHours = exports.InputHours = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
  var defaultValue = _ref.value,
    onCancel = _ref.onCancel,
    onSave = _ref.onSave,
    externalEnterKeyPress = _ref.onEnterKeyPress,
    allowEmptyValue = _ref.allowEmptyValue,
    _ref$withLeadingZero = _ref.withLeadingZero,
    withLeadingZero = _ref$withLeadingZero === void 0 ? true : _ref$withLeadingZero,
    _ref$validation = _ref.validation,
    validation = _ref$validation === void 0 ? _utils.validateTimeInput : _ref$validation,
    _ref$incrementOnlySel = _ref.incrementOnlySelected,
    incrementOnlySelected = _ref$incrementOnlySel === void 0 ? false : _ref$incrementOnlySel,
    _ref$minuteIncrement = _ref.minuteIncrement,
    minuteIncrement = _ref$minuteIncrement === void 0 ? 1 : _ref$minuteIncrement,
    className = _ref.className,
    externalOnChange = _ref.onChange,
    externalOnClick = _ref.onClick,
    _ref$align = _ref.align,
    align = _ref$align === void 0 ? "center" : _ref$align,
    rest = _objectWithoutProperties(_ref, _excluded);
  var inputRef = (0, _react.useRef)(null);
  var handleRef = (0, _useForkRef.default)(ref, inputRef);
  var _useInputHours = (0, _useInputHours2.useInputHours)({
      value: defaultValue,
      withLeadingZero,
      onSave,
      validation,
      allowEmptyValue,
      onCancel,
      minuteIncrement,
      incrementOnlySelected,
      onEnterKeyPress: externalEnterKeyPress,
      onChange: externalOnChange,
      onClick: externalOnClick
    }, inputRef),
    inputProps = _useInputHours.inputProps;
  var value = inputProps.value,
    onBlur = inputProps.onBlur,
    onKeyDown = inputProps.onKeyDown,
    onChange = inputProps.onChange,
    onClick = inputProps.onClick,
    onDoubleClick = inputProps.onDoubleClick;
  return /*#__PURE__*/_react.default.createElement(_Input.Input, _extends({}, rest, {
    align: align,
    className: className,
    placeholder: withLeadingZero ? "00:00" : "0:00",
    value: value,
    onBlur: onBlur,
    onKeyDown: onKeyDown,
    onChange: onChange,
    onClick: onClick,
    onDoubleClick: onDoubleClick,
    ref: handleRef,
    autoComplete: "off"
  }));
});
InputHours.displayName = "InputHours";
//# sourceMappingURL=InputHours.js.map