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

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var isString = require('lodash/isString');
var utils_dom = require('../utils/dom.js');
require('../_chunks/dep-7f0559c3.js');
require('lodash/isFunction');
require('lodash/isArray');
require('../utils/easing.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);

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__default["default"](value) && {
          "true": true,
          "false": false
        }[value] || value;
        value = isString__default["default"](value) && value[0] === "'" ? value.replace(/'/g, "") : value;
        setInnerValue(value, {
          e: e
        });
      }
    }
  };
  vue.onMounted(function () {
    utils_dom.on(radioGroupRef.value, "keydown", checkRadioInGroup);
  });
  vue.onBeforeMount(function () {
    utils_dom.off(radioGroupRef.value, "keydown", checkRadioInGroup);
  });
}

exports["default"] = useKeyboard;
//# sourceMappingURL=useKeyboard.js.map
