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

import { onMounted, onBeforeMount } from 'vue';
import isString from 'lodash/isString';
import { on, off } from '../utils/dom.js';
import '../_chunks/dep-512eb181.js';
import 'lodash/isFunction';
import 'lodash/isArray';
import '../utils/easing.js';

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(value) && {
          "true": true,
          "false": false
        }[value] || value;
        value = isString(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.js.map
