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

import { onMounted, onBeforeMount } from 'vue';
import { i as isString_1 } from '../_chunks/dep-1cf2b129.mjs';
import { on, off } from '../utils/dom.mjs';
import '../_chunks/dep-a0b4a044.mjs';
import '../_chunks/dep-c959a6fb.mjs';
import '../_chunks/dep-b4041200.mjs';
import '../_chunks/dep-e3b14d70.mjs';
import '../_chunks/dep-66d6733b.mjs';
import '../_chunks/dep-c31e1d9e.mjs';
import '../_chunks/dep-6b22dd27.mjs';
import '../_chunks/dep-0f0c89ff.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
