Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/okikio/solid-motion-experiments.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105import 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<MotionComponentProps<"div">> = (props) => <div {...props} />; * ``` * * @example Motion-wrapped custom component * ```tsx * type CardProps = { title: string }; * declare const Card: Component<CardProps>; * type MotionCardProps = MotionComponentProps<typeof Card>; * ``` */export type MotionComponentProps<T extends ValidComponent> = & Omit<ComponentProps<T>, 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<T extends ValidComponent> = Component<MotionComponentProps<T>>;
/** * 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: <T extends ValidComponent>( component: T, options?: MotionCreateOptions, ) => MotionComponent<T>;} & { [K in keyof JSX.IntrinsicElements]: MotionComponent<K>;};