'use strict';

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

var vue = require('vue');
var raf = require('../../_util/raf.js');
var useValueTexts = require('./useValueTexts.js');

function useHoverValue(valueText, { formatList, generateConfig, locale }) {
  const innerValue = vue.ref(null);
  let rafId;
  function setValue(val, immediately = false) {
    raf.default.cancel(rafId);
    if (immediately) {
      innerValue.value = val;
      return;
    }
    rafId = raf.default(() => {
      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.default.cancel(rafId);
  });
  return [firstText, onEnter, onLeave];
}

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