valid-prop.mjs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * A list of all valid MotionProps.
  3. *
  4. * @privateRemarks
  5. * This doesn't throw if a `MotionProp` name is missing - it should.
  6. */
  7. const validMotionProps = new Set([
  8. "animate",
  9. "exit",
  10. "variants",
  11. "initial",
  12. "style",
  13. "values",
  14. "variants",
  15. "transition",
  16. "transformTemplate",
  17. "custom",
  18. "inherit",
  19. "onBeforeLayoutMeasure",
  20. "onAnimationStart",
  21. "onAnimationComplete",
  22. "onUpdate",
  23. "onDragStart",
  24. "onDrag",
  25. "onDragEnd",
  26. "onMeasureDragConstraints",
  27. "onDirectionLock",
  28. "onDragTransitionEnd",
  29. "_dragX",
  30. "_dragY",
  31. "onHoverStart",
  32. "onHoverEnd",
  33. "onViewportEnter",
  34. "onViewportLeave",
  35. "globalTapTarget",
  36. "ignoreStrict",
  37. "viewport",
  38. ]);
  39. /**
  40. * Check whether a prop name is a valid `MotionProp` key.
  41. *
  42. * @param key - Name of the property to check
  43. * @returns `true` is key is a valid `MotionProp`.
  44. *
  45. * @public
  46. */
  47. function isValidMotionProp(key) {
  48. return (key.startsWith("while") ||
  49. (key.startsWith("drag") && key !== "draggable") ||
  50. key.startsWith("layout") ||
  51. key.startsWith("onTap") ||
  52. key.startsWith("onPan") ||
  53. key.startsWith("onLayout") ||
  54. validMotionProps.has(key));
  55. }
  56. export { isValidMotionProp };