import { ref , onMounted , onUnmounted , Ref } from '@src/api' ; export function useMedia ( query , defaultState = false ) { let mql ; const matches = ref ( defaultState ) ; const updateMatchValue = ( ) => ( matches . value = mql . matches ) ; onMounted ( ( ) => { mql = window . matchMedia ( query ) ; mql . addListener ( updateMatchValue ) ; updateMatchValue ( ) ; } ) ; onUnmounted ( ( ) => { mql . removeListener ( updateMatchValue ) ; } ) ; return matches ; }