UNPKG

framer-motion

Version:

A simple and powerful JavaScript animation library

1 lines 1.35 kB
{"version":3,"file":"use-props.mjs","sources":["../../../../src/render/svg/use-props.ts"],"sourcesContent":["\"use client\"\n\nimport { buildSVGAttrs, isSVGTag } from \"motion-dom\"\nimport { useMemo } from \"react\"\nimport { MotionProps } from \"../../motion/types\"\nimport { copyRawValuesOnly } from \"../html/use-props\"\nimport { ResolvedValues } from \"../types\"\nimport { createSvgRenderState } from \"./utils/create-render-state\"\n\nexport function useSVGProps(\n props: MotionProps,\n visualState: ResolvedValues,\n _isStatic: boolean,\n Component: string | React.ComponentType<React.PropsWithChildren<unknown>>\n) {\n const visualProps = useMemo(() => {\n const state = createSvgRenderState()\n\n buildSVGAttrs(\n state,\n visualState,\n isSVGTag(Component),\n props.transformTemplate,\n props.style\n )\n\n return {\n ...state.attrs,\n style: { ...state.style },\n }\n }, [visualState])\n\n if (props.style) {\n const rawStyles = {}\n copyRawValuesOnly(rawStyles, props.style as any, props)\n visualProps.style = { ...rawStyles, ...visualProps.style }\n }\n\n return visualProps\n}\n"],"names":[],"mappings":";;;;;;AASM;AAMF;AACI;AAEA;;;AAUI;;AAER;AAEA;;;AAGI;;AAGJ;AACJ;;"}