// composables/useToggle.js import { ref } from 'vue'; /** * A composable function to manage a boolean state (toggle). * @param {boolean} initialValue - The initial boolean value. * @returns {[Ref, Function, Function, Function]} * - A ref to the boolean state. * - A function to toggle the state. * - A function to set the state to true. * - A function to set the state to false. */ export function useToggle(initialValue = false) { const state = ref(initialValue); const toggle = () => { state.value = !state.value; }; const setTrue = () => { state.value = true; }; const setFalse = () => { state.value = false; }; return [state, toggle, setTrue, setFalse]; }