import { ref } from 'vue';

/**
 * Dialog控制Hook
 * @returns visible（显隐状态）、show（显示）、hide（隐藏）、toggle（切换）
 */
export function useDialog(initialVisible:boolean = false): {
  visible: import('vue').Ref<boolean>,
  show: () => void,
  hide: () => void,
  toggle: () => void
} {
  const visible = ref(initialVisible);

  const show = () => {
    visible.value = true;
  };

  const hide = () => {
    visible.value = false;
  };

  const toggle = () => {
    visible.value = !visible.value;
  };

  return {
    visible,
    show,
    hide,
    toggle
  };
}