framer-motion
Version:
A simple and powerful JavaScript animation library
1 lines • 2.62 kB
Source Map (JSON)
{"version":3,"file":"filter-props.mjs","sources":["../../../../../src/render/dom/utils/filter-props.ts"],"sourcesContent":["import { isMotionValue } from \"motion-dom\"\nimport type { IsValidProp } from \"../../../context/MotionConfigContext\"\nimport type { MotionProps } from \"../../../motion/types\"\nimport { isValidMotionProp } from \"../../../motion/utils/valid-prop\"\n\nfunction shouldForward(key: string, isValidProp?: IsValidProp) {\n return key.startsWith(\"on\")\n ? !isValidMotionProp(key)\n : isValidProp?.(key) ?? !isValidMotionProp(key)\n}\n\nexport function filterProps(\n props: MotionProps,\n isDom: boolean,\n forwardMotionProps: boolean,\n isValidProp?: IsValidProp\n) {\n const filteredProps: MotionProps = {}\n\n for (const key in props) {\n /**\n * values is considered a valid prop by Emotion, so if it's present\n * this will be rendered out to the DOM unless explicitly filtered.\n *\n * We check the type as it could be used with the `feColorMatrix`\n * element, which we support.\n */\n if (key === \"values\" && typeof props.values === \"object\") continue\n\n if (isMotionValue(props[key as keyof typeof props])) continue\n\n if (\n shouldForward(key, isValidProp) ||\n (forwardMotionProps === true && isValidMotionProp(key)) ||\n (!isDom && !isValidMotionProp(key)) ||\n // If trying to use native HTML drag events, forward drag listeners\n (props[\"draggable\" as keyof MotionProps] &&\n key.startsWith(\"onDrag\"))\n ) {\n filteredProps[key as keyof MotionProps] =\n props[key as keyof MotionProps]\n }\n }\n\n return filteredProps\n}\n"],"names":[],"mappings":";;;AAKA,SAAS,aAAa,CAAC,GAAW,EAAE,WAAyB,EAAA;AACzD,IAAA,OAAO,GAAG,CAAC,UAAU,CAAC,IAAI;AACtB,UAAE,CAAC,iBAAiB,CAAC,GAAG;AACxB,UAAE,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC;AACvD;AAEM,SAAU,WAAW,CACvB,KAAkB,EAClB,KAAc,EACd,kBAA2B,EAC3B,WAAyB,EAAA;IAEzB,MAAM,aAAa,GAAgB,EAAE;AAErC,IAAA,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE;AACrB;;;;;;AAMG;QACH,IAAI,GAAG,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ;YAAE;AAE1D,QAAA,IAAI,aAAa,CAAC,KAAK,CAAC,GAAyB,CAAC,CAAC;YAAE;AAErD,QAAA,IACI,aAAa,CAAC,GAAG,EAAE,WAAW,CAAC;aAC9B,kBAAkB,KAAK,IAAI,IAAI,iBAAiB,CAAC,GAAG,CAAC,CAAC;aACtD,CAAC,KAAK,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;;aAElC,KAAK,CAAC,WAAgC,CAAC;AACpC,gBAAA,GAAG,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,EAC/B;YACE,aAAa,CAAC,GAAwB,CAAC;gBACnC,KAAK,CAAC,GAAwB,CAAC;QACvC;IACJ;AAEA,IAAA,OAAO,aAAa;AACxB;;;;"}