UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

38 lines (37 loc) 1.46 kB
"use client"; require("../../../_virtual/_rolldown/runtime.cjs"); const require_MantineThemeProvider = require("../MantineThemeProvider/MantineThemeProvider.cjs"); let _mantine_hooks = require("@mantine/hooks"); //#region packages/@mantine/core/src/core/MantineProvider/use-matches/use-matches.ts const BREAKPOINTS = [ "xs", "sm", "md", "lg", "xl" ]; function getFirstMatchingValue(value, biggestMatch) { if (!biggestMatch) return value.base; let index = BREAKPOINTS.indexOf(biggestMatch); while (index >= 0) { if (BREAKPOINTS[index] in value) return value[BREAKPOINTS[index]]; index -= 1; } return value.base; } function getFirstMatchingBreakpoint(matches) { return matches.findLastIndex((v) => v); } function useMatches(payload, options) { const theme = require_MantineThemeProvider.useMantineTheme(); return getFirstMatchingValue(payload, BREAKPOINTS[getFirstMatchingBreakpoint([ (0, _mantine_hooks.useMediaQuery)(`(min-width: ${theme.breakpoints.xs})`, false, options), (0, _mantine_hooks.useMediaQuery)(`(min-width: ${theme.breakpoints.sm})`, false, options), (0, _mantine_hooks.useMediaQuery)(`(min-width: ${theme.breakpoints.md})`, false, options), (0, _mantine_hooks.useMediaQuery)(`(min-width: ${theme.breakpoints.lg})`, false, options), (0, _mantine_hooks.useMediaQuery)(`(min-width: ${theme.breakpoints.xl})`, false, options) ])]); } //#endregion exports.useMatches = useMatches; //# sourceMappingURL=use-matches.cjs.map