UNPKG

vuestic-ui

Version:
36 lines (35 loc) 1.34 kB
import { inject, computed } from "vue"; import { w as warn } from "../utils/console.mjs"; import { v as vaBreakpointSymbol } from "../services/breakpoint/index.mjs"; import { u as useReactiveComputed } from "./useReactiveComputed.mjs"; import { u as useGlobalConfig } from "./useGlobalConfig.mjs"; import { u as useIsMounted } from "./useIsMounted.mjs"; const helpersKeys = ["xs", "sm", "md", "lg", "xl", "smUp", "mdUp", "lgUp", "smDown", "mdDown", "lgDown"]; const defaultHelpers = helpersKeys.reduce((acc, key) => { acc[key] = false; return acc; }, {}); const useBreakpoint = () => { const injected = inject(vaBreakpointSymbol, {}); const isMounted = useIsMounted(); const { globalConfig } = useGlobalConfig(); const breakpointConfig = computed(() => { const breakpoint = globalConfig.value.breakpoint; if (!breakpoint) { warn("useBreakpoint: breakpointConfig is not defined!"); } return breakpoint ?? {}; }); const defaultBreakpoint = computed(() => breakpointConfig.value.enabled ? { width: void 0, height: void 0, current: void 0, thresholds: breakpointConfig.value.thresholds, ...defaultHelpers } : {}); return useReactiveComputed(() => isMounted.value ? injected : defaultBreakpoint.value); }; export { useBreakpoint as u }; //# sourceMappingURL=useBreakpoint.mjs.map