diff --git a/src/presence.tsx b/src/presence.tsx index 644368e..9ab2d0b 100644 --- a/src/presence.tsx +++ b/src/presence.tsx @@ -10,8 +10,6 @@ import { type Accessor, } from "solid-js" -import type {Options} from "./types.js" - export type PresenceContextState = { initial: boolean mount: Accessor @@ -55,7 +53,7 @@ export const Presence: FlowComponent<{ onExit(el, done) { batch(() => { setMount(false) - ;(mountedStates.get(el)?.getOptions() as Options).exit + mountedStates.get(el)?.getOptions().exit ? el.addEventListener("motioncomplete", done) : done() }) diff --git a/src/types.ts b/src/types.ts index 6ae1753..806b0ac 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2,7 +2,7 @@ import type * as motionone from "@motionone/dom" import type {PropertiesHyphen} from "csstype" import type {JSX, ParentProps} from "solid-js" -export type VariantDefinition = motionone.VariantDefinition +export type {VariantDefinition, Options} from "@motionone/dom" export interface MotionEventHandlers { onMotionStart?: (event: motionone.MotionEvent) => void @@ -15,19 +15,25 @@ export interface MotionEventHandlers { onViewLeave?: (event: motionone.ViewEvent) => void } -/* - Solid style attribute supports only kebab-case properties. - While @motionone/dom supports both camelCase and kebab-case, - but provides only camelCase properties in the types. -*/ declare module "@motionone/dom" { + /* + Solid style attribute supports only kebab-case properties. + While @motionone/dom supports both camelCase and kebab-case, + but provides only camelCase properties in the types. + */ interface CSSStyleDeclarationWithTransform extends Omit {} + + /* + exit is missing in types in motionone core + because it is only used in the Presence implementations + */ + interface Options { + exit?: motionone.VariantDefinition + } } -export type Options = motionone.Options & {exit?: VariantDefinition} - -export type MotionComponentProps = ParentProps +export type MotionComponentProps = ParentProps export type MotionComponent = { // @@ -48,7 +54,7 @@ export type MotionProxy = MotionComponent & { declare module "solid-js" { namespace JSX { interface Directives { - motion: Options + motion: motionone.Options } } }