import type { Component, ComponentProps, JSX, ValidComponent } from "solid-js"; import type { MotionProps } from "../motion/split-motion-props.ts"; /** * Configures how a Motion component factory should forward props to its rendered target. * * The first Solid renderer needs one important boundary that Motion Vue also exposes: * Motion props should be filtered out before reaching custom components unless the caller * explicitly asks to forward them. This keeps wrapper components from accidentally * receiving animation-only props they do not understand. * * @example Default filtering for custom components * ```ts * const MotionCard = motion.create(Card); * ``` * * @example Explicitly forward Motion props * ```ts * const MotionCard = motion.create(Card, { forwardMotionProps: true }); * ``` */ export interface MotionCreateOptions { /** * When true, Motion-owned props are passed through to the rendered component instead of * being filtered out at the wrapper boundary. */ forwardMotionProps?: boolean; } /** * Holds the Solid-specific wrapper props that control how a Motion component renders. * * These props are local to the Solid wrapper itself. They are not part of Motion's core * animation target model, which is why the wrapper splits them before forwarding DOM or * component props. */ export interface MotionLocalProps { /** * Renders a different intrinsic tag or component while keeping the Motion wrapper. */ as?: ValidComponent; /** * Overrides the factory-level forwarding rule for this component instance. */ forwardMotionProps?: boolean; } /** * Describes the public prop shape for a Motion-wrapped Solid component. * * This type keeps three prop categories separate: * 1. the rendered component's normal props * 2. Motion-owned animation props * 3. wrapper-local props like `as` * * That separation matters because Solid's prop reactivity is property-read based. The * wrapper needs to split these categories lazily rather than destructuring them up front. * * @example Motion-wrapped intrinsic component * ```tsx * const MotionDiv: Component> = (props) =>
; * ``` * * @example Motion-wrapped custom component * ```tsx * type CardProps = { title: string }; * declare const Card: Component; * type MotionCardProps = MotionComponentProps; * ``` */ export type MotionComponentProps = & Omit, keyof MotionLocalProps | keyof MotionProps> & MotionProps & MotionLocalProps; /** * Describes one created Motion component. * * The public Solid surface is component-shaped rather than hook-shaped, so callers should * be able to treat a created Motion component like any other Solid component with extra * Motion props layered on top. */ export type MotionComponent = Component>; /** * Describes the Solid Motion namespace built by the cached Proxy factory. * * The namespace serves two different call sites: * 1. property access like `motion.div` * 2. explicit creation like `motion.create(Card)` * * Both should return cached component factories so repeated access does not create new * wrapper components and accidentally break animation identity. */ export type MotionNamespace = { create: ( component: T, options?: MotionCreateOptions, ) => MotionComponent; } & { [K in keyof JSX.IntrinsicElements]: MotionComponent; };