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

import { onMounted, onBeforeMount } from 'vue';
import { i as isString_1 } from '../_chunks/dep-876fb3ec.mjs';
import { on, off } from '../utils/dom.mjs';
import '../_chunks/dep-eba0ea6e.mjs';
import '../_chunks/dep-469b4ae0.mjs';
import '../_chunks/dep-255303ba.mjs';
import '../_chunks/dep-b57180d0.mjs';
import '../_chunks/dep-c8d7b6b4.mjs';
import '../_chunks/dep-3da99438.mjs';
import '../_chunks/dep-5717e263.mjs';
import '../_chunks/dep-a8bcacea.mjs';
import '../utils/easing.mjs';

function useKeyboard(radioGroupRef, setInnerValue) {
  var checkRadioInGroup = function checkRadioInGroup(e) {
    if (/enter/i.test(e.key) || /enter/i.test(e.code)) {
      var inputNode = e.target.querySelector("input");
      var data = inputNode.dataset;
      if (inputNode.checked && data.allowUncheck) {
        setInnerValue(void 0, {
          e: e
        });
      } else {
        var value = !isNaN(Number(data.value)) ? Number(data.value) : data.value;
        value = isString_1(value) && {
          "true": true,
          "false": false
        }[value] || value;
        value = isString_1(value) && value[0] === "'" ? value.replace(/'/g, "") : value;
        setInnerValue(value, {
          e: e
        });
      }
    }
  };
  onMounted(function () {
    on(radioGroupRef.value, "keydown", checkRadioInGroup);
  });
  onBeforeMount(function () {
    off(radioGroupRef.value, "keydown", checkRadioInGroup);
  });
}

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