"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useCustomEvents = void 0;
var _react = require("react");
// NOTE: do we want to use the controlInput or  the hiddenInput here?
// We were previously using the hidden one, but I see no reasons.
// 'change' events would make sense on the hidden input, but focus
// control seems to be more on the control input.
// Anyway, this is not decided here, but when calling useCustomEvents()

var useCustomEvents = (inputRef, onBlur, onFocus) => {
  var customOnBlur = (0, _react.useCallback)(() => {
    if (onBlur) {
      var event = document.createEvent('CustomEvent');
      event.initEvent('Change Date', true, false);
      inputRef.current.dispatchEvent(event);
      onBlur(event);
    }
  }, [inputRef, onBlur]);
  var customOnFocus = (0, _react.useCallback)(() => {
    if (onFocus) {
      var event = document.createEvent('CustomEvent');
      event.initEvent('Change Date', true, false);
      inputRef.current.dispatchEvent(event);
      onFocus(event);
    }
  }, [inputRef, onFocus]);
  return [customOnBlur, customOnFocus];
};
exports.useCustomEvents = useCustomEvents;