UNPKG

@yamada-ui/react

Version:

React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion

29 lines (25 loc) 792 B
"use client"; import { useSafeLayoutEffect } from "../../utils/effect.js"; import { useCallback, useState } from "react"; //#region src/hooks/use-eye-dropper/index.ts /** * `useEyeDropper` is a custom hook that opens the eye dropper tool and returns the color value. * * @see https://yamada-ui.com/docs/hooks/use-eye-dropper */ const useEyeDropper = () => { const [supported, setSupported] = useState(false); useSafeLayoutEffect(() => { setSupported(typeof window !== "undefined" && "EyeDropper" in window); }, []); return { supported, onOpen: useCallback(async (options = {}) => { if (supported) return new window.EyeDropper().open(options); return Promise.resolve(void 0); }, [supported]) }; }; //#endregion export { useEyeDropper }; //# sourceMappingURL=index.js.map