import { ref, watch, onBeforeUnmount } from 'vue';
import '../../../../utils/index.mjs';
import useValueTexts from './useValueTexts.mjs';
import { raf } from '../../../../utils/vue/raf.mjs';

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

export { useHoverValue as default };
//# sourceMappingURL=useHoverValue.mjs.map
