koval-ui
Version:
React components collection with minimalistic design. Supports theming, layout, and input validation.
1 lines • 1.15 kB
Source Map (JSON)
{"version":3,"file":"useResponsiveWidth.cjs","sources":["../../../../src/lib/Carousel/useResponsiveWidth.ts"],"sourcesContent":["import type {MutableRefObject} from 'react';\nimport {useState, useEffect} from 'react';\n\nimport {useResizeObserver} from '@/internal/hooks/useResizeObserverNew.ts';\n\nexport type Props = {\n width: number;\n ref: MutableRefObject<HTMLElement | null>;\n};\n\nexport const useResponsiveWidth = ({width, ref}: Props) => {\n const [responsiveWidth, setResponsiveWidth] = useState(width);\n const rect = useResizeObserver(ref);\n useEffect(() => {\n typeof rect?.width === 'number' && setResponsiveWidth(rect?.width);\n }, [rect?.width]);\n return responsiveWidth;\n};\n"],"names":["useResponsiveWidth","width","ref","responsiveWidth","setResponsiveWidth","useState","rect","useResizeObserver","useEffect"],"mappings":"iLAUaA,EAAqB,CAAC,CAAC,MAAAC,EAAO,IAAAC,KAAgB,CACvD,KAAM,CAACC,EAAiBC,CAAkB,EAAIC,EAAAA,SAASJ,CAAK,EACtDK,EAAOC,oBAAkBL,CAAG,EAClCM,OAAAA,EAAAA,UAAU,IAAM,CACZ,OAAOF,GAAA,YAAAA,EAAM,QAAU,UAAYF,EAAmBE,GAAA,YAAAA,EAAM,KAAK,CAAA,EAClE,CAACA,GAAA,YAAAA,EAAM,KAAK,CAAC,EACTH,CACX"}