/**
 * ldesign v0.3.13
 * (c) 2023 ldesign
 * @license MIT
 */

function useInputEventHandler(props, isHover) {
  var handleKeydown = function handleKeydown(e) {
    if (props.disabled) return;
    var code = e.code;
    if (/enter/i.test(code) || /enter/i.test(e.key)) {
      var _props$onEnter;
      e.stopPropagation();
      (_props$onEnter = props.onEnter) === null || _props$onEnter === void 0 ? void 0 : _props$onEnter.call(props, e.currentTarget.value, {
        e: e
      });
    } else {
      var _props$onKeydown;
      (_props$onKeydown = props.onKeydown) === null || _props$onKeydown === void 0 ? void 0 : _props$onKeydown.call(props, e.currentTarget.value, {
        e: e
      });
    }
  };
  var handleKeyUp = function handleKeyUp(e) {
    var _props$onKeyup;
    if (props.disabled) return;
    (_props$onKeyup = props.onKeyup) === null || _props$onKeyup === void 0 ? void 0 : _props$onKeyup.call(props, e.currentTarget.value, {
      e: e
    });
  };
  var handleKeypress = function handleKeypress(e) {
    var _props$onKeypress;
    if (props.disabled) return;
    (_props$onKeypress = props.onKeypress) === null || _props$onKeypress === void 0 ? void 0 : _props$onKeypress.call(props, e.currentTarget.value, {
      e: e
    });
  };
  var onHandlePaste = function onHandlePaste(e) {
    var _props$onPaste;
    if (props.disabled) return;
    var clipData = e.clipboardData || window.clipboardData;
    (_props$onPaste = props.onPaste) === null || _props$onPaste === void 0 ? void 0 : _props$onPaste.call(props, {
      e: e,
      pasteValue: clipData === null || clipData === void 0 ? void 0 : clipData.getData("text/plain")
    });
  };
  var mouseEvent = function mouseEvent(v) {
    return isHover.value = v;
  };
  var onHandleMousewheel = function onHandleMousewheel(e) {
    var _props$onWheel;
    return (_props$onWheel = props.onWheel) === null || _props$onWheel === void 0 ? void 0 : _props$onWheel.call(props, {
      e: e
    });
  };
  var onInputMouseenter = function onInputMouseenter(e) {
    var _props$onMouseenter;
    mouseEvent(true);
    (_props$onMouseenter = props.onMouseenter) === null || _props$onMouseenter === void 0 ? void 0 : _props$onMouseenter.call(props, {
      e: e
    });
  };
  var onInputMouseleave = function onInputMouseleave(e) {
    var _props$onMouseleave;
    mouseEvent(false);
    (_props$onMouseleave = props.onMouseleave) === null || _props$onMouseleave === void 0 ? void 0 : _props$onMouseleave.call(props, {
      e: e
    });
  };
  return {
    handleKeydown: handleKeydown,
    handleKeyUp: handleKeyUp,
    handleKeypress: handleKeypress,
    onHandlePaste: onHandlePaste,
    onHandleMousewheel: onHandleMousewheel,
    onInputMouseenter: onInputMouseenter,
    onInputMouseleave: onInputMouseleave
  };
}

export { useInputEventHandler as default };
//# sourceMappingURL=useInputEventHandler.mjs.map
