UNPKG

@mantine/hooks

Version:

A collection of 50+ hooks for state and UI management

24 lines (23 loc) 766 B
"use client"; import { useIsomorphicEffect } from "../use-isomorphic-effect/use-isomorphic-effect.mjs"; import { useCallback, useState } from "react"; //#region packages/@mantine/hooks/src/use-eye-dropper/use-eye-dropper.ts function useEyeDropper() { const [supported, setSupported] = useState(false); useIsomorphicEffect(() => { setSupported(typeof window !== "undefined" && !isOpera() && "EyeDropper" in window); }, []); return { supported, open: useCallback((options = {}) => { if (supported) return new window.EyeDropper().open(options); return Promise.resolve(void 0); }, [supported]) }; } function isOpera() { return navigator.userAgent.includes("OPR"); } //#endregion export { useEyeDropper }; //# sourceMappingURL=use-eye-dropper.mjs.map