react-input-pin-code
Version:
Pin input built with React component and styled-components
1 lines • 1.15 kB
Source Map (JSON)
{"version":3,"file":"index.d.ts","sources":["../../../src/hooks/use-css-variable/types.ts","../../../src/hooks/use-css-variable/hook.ts"],"sourcesContent":["import type { RefObject } from 'react';\r\n\r\nexport type SetCssVariable = (name: string, value: string) => void;\r\n\r\nexport type Props = {\r\n targetElRef: RefObject<HTMLElement | null>;\r\n};\r\n\r\nexport type Result = {\r\n setCssVariable: SetCssVariable;\r\n};\r\n\r\nexport type Hook = (props: Props) => Result;\r\n","import { useCallback } from 'react';\r\n\r\nimport { setElementCssVariable } from '../../utils/css';\r\nimport type { Hook, SetCssVariable } from './types';\r\n\r\nexport const useCssVariable: Hook = ({ targetElRef }) => {\r\n const setCssVariable: SetCssVariable = useCallback((name, value) => {\r\n const { current: targetEl } = targetElRef;\r\n\r\n if (!targetEl) {\r\n return;\r\n }\r\n\r\n setElementCssVariable({\r\n element: targetEl,\r\n name,\r\n value,\r\n });\r\n }, [targetElRef]);\r\n\r\n return {\r\n setCssVariable,\r\n };\r\n};\r\n"],"names":[],"mappings":";;AACO;AACA;AACP;AACA;AACO;AACP;AACA;AACO;;ACPA;;;"}