'use strict';

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

var vue = require('vue');
require('../../../../utils/index.cjs');
var useValueTexts = require('./useValueTexts.cjs');
var raf = require('../../../../utils/vue/raf.cjs');

function useHoverValue(valueText, { formatList, generateConfig, locale }) {
  const innerValue = vue.ref(null);
  let rafId;
  function setValue(val, immediately = false) {
    raf.raf.cancel(rafId);
    if (immediately) {
      innerValue.value = val;
      return;
    }
    rafId = raf.raf(() => {
      innerValue.value = val;
    });
  }
  const [, firstText] = useValueTexts.default(innerValue, {
    formatList,
    generateConfig,
    locale
  });
  function onEnter(date) {
    setValue(date);
  }
  function onLeave(immediately = false) {
    setValue(null, immediately);
  }
  vue.watch(valueText, () => {
    onLeave(true);
  });
  vue.onBeforeUnmount(() => {
    raf.raf.cancel(rafId);
  });
  return [firstText, onEnter, onLeave];
}

exports.default = useHoverValue;
//# sourceMappingURL=useHoverValue.cjs.map
