Skip to content

Commit 874b9dc

Browse files
committed
Extend motionone's Options interface with exit
This should remove the parenthesis used for typecasting, that was causing an issue reported in #11
1 parent 81376f7 commit 874b9dc

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/presence.tsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import {
1010
type Accessor,
1111
} from "solid-js"
1212

13-
import type {Options} from "./types.js"
14-
1513
export type PresenceContextState = {
1614
initial: boolean
1715
mount: Accessor<boolean>
@@ -55,7 +53,7 @@ export const Presence: FlowComponent<{
5553
onExit(el, done) {
5654
batch(() => {
5755
setMount(false)
58-
;(mountedStates.get(el)?.getOptions() as Options).exit
56+
mountedStates.get(el)?.getOptions().exit
5957
? el.addEventListener("motioncomplete", done)
6058
: done()
6159
})

src/types.ts

+16-10
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type * as motionone from "@motionone/dom"
22
import type {PropertiesHyphen} from "csstype"
33
import type {JSX, ParentProps} from "solid-js"
44

5-
export type VariantDefinition = motionone.VariantDefinition
5+
export type {VariantDefinition, Options} from "@motionone/dom"
66

77
export interface MotionEventHandlers {
88
onMotionStart?: (event: motionone.MotionEvent) => void
@@ -15,19 +15,25 @@ export interface MotionEventHandlers {
1515
onViewLeave?: (event: motionone.ViewEvent) => void
1616
}
1717

18-
/*
19-
Solid style attribute supports only kebab-case properties.
20-
While @motionone/dom supports both camelCase and kebab-case,
21-
but provides only camelCase properties in the types.
22-
*/
2318
declare module "@motionone/dom" {
19+
/*
20+
Solid style attribute supports only kebab-case properties.
21+
While @motionone/dom supports both camelCase and kebab-case,
22+
but provides only camelCase properties in the types.
23+
*/
2424
interface CSSStyleDeclarationWithTransform
2525
extends Omit<PropertiesHyphen, "direction" | "transition"> {}
26+
27+
/*
28+
exit is missing in types in motionone core
29+
because it is only used in the Presence implementations
30+
*/
31+
interface Options {
32+
exit?: motionone.VariantDefinition
33+
}
2634
}
2735

28-
export type Options = motionone.Options & {exit?: VariantDefinition}
29-
30-
export type MotionComponentProps = ParentProps<MotionEventHandlers & Options>
36+
export type MotionComponentProps = ParentProps<MotionEventHandlers & motionone.Options>
3137

3238
export type MotionComponent = {
3339
// <Motion />
@@ -48,7 +54,7 @@ export type MotionProxy = MotionComponent & {
4854
declare module "solid-js" {
4955
namespace JSX {
5056
interface Directives {
51-
motion: Options
57+
motion: motionone.Options
5258
}
5359
}
5460
}

0 commit comments

Comments
 (0)