page-transition 0.1.0-beta.56 → 0.1.0-beta.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -32
- package/dist/components/{TransitionLink.js → css/TransitionLink.js} +2 -2
- package/dist/components/manual/TransitionLink.d.ts +10 -0
- package/dist/components/manual/TransitionLink.js +10 -0
- package/dist/context/CssContext.d.ts +12 -0
- package/dist/context/CssContext.js +9 -0
- package/dist/context/CssTransitionProvider.d.ts +1 -0
- package/dist/context/CssTransitionProvider.js +16 -4
- package/dist/context/ManualContext.d.ts +9 -0
- package/dist/context/ManualContext.js +9 -0
- package/dist/context/ManualTransitionProvider.js +2 -2
- package/dist/context/TransitionProvider.d.ts +23 -0
- package/dist/context/TransitionProvider.js +10 -0
- package/dist/css.d.ts +1 -0
- package/dist/css.js +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/manual.d.ts +1 -0
- package/dist/manual.js +1 -0
- package/package.json +15 -1
- package/dist/context/TransitionContext.d.ts +0 -33
- package/dist/context/TransitionContext.js +0 -18
- /package/dist/components/{TransitionLink.d.ts → css/TransitionLink.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ A page transition library for the Next.js App Router.
|
|
|
10
10
|
- Scroll restoration
|
|
11
11
|
|
|
12
12
|
## Install
|
|
13
|
-
 
|
|
14
14
|
|
|
15
15
|
`npm install page-transition@beta`
|
|
16
16
|
|
|
@@ -51,6 +51,7 @@ export default function RootLayout({ children }: LayoutProps<"/">) {
|
|
|
51
51
|
| Option | Type | Default | Required |
|
|
52
52
|
|---|---|---|---|
|
|
53
53
|
| transitionProperty | "opacity" \| "clip-path" \| "transform" | - | Yes |
|
|
54
|
+
| overlay | boolean | "false" | - |
|
|
54
55
|
| items | [number, number] | [0, 0] | - |
|
|
55
56
|
|
|
56
57
|
|
|
@@ -69,12 +70,14 @@ Components rendered outside .page-wrapper, but still inside the transition conta
|
|
|
69
70
|
|
|
70
71
|
**options.transitionProperty**
|
|
71
72
|
Defines which property transitionend waits for.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
**options.overlay**
|
|
76
|
+
Adds an element with the class `.overlay` to the transition container.
|
|
77
|
+
|
|
78
|
+
**options.items**
|
|
75
79
|
`options.items[0]`
|
|
76
|
-
Number of items in the first group. Each item receives the `.overlay-item` class.
|
|
77
|
-
<br/>
|
|
80
|
+
Number of items in the first group. Each item receives the `.overlay-item` class.
|
|
78
81
|
`options.items[1]`
|
|
79
82
|
Number of items in the second group. Each item receives the `.second-item` class.
|
|
80
83
|
|
|
@@ -99,7 +102,7 @@ options={{
|
|
|
99
102
|
| href | string | - | Yes |
|
|
100
103
|
| className | string | - | - |
|
|
101
104
|
| scroll | boolean | true | - |
|
|
102
|
-
| prefetch | "auto" \| null | null | - |
|
|
105
|
+
| prefetch | boolean \| "auto" \| null | null | - |
|
|
103
106
|
| onClick | (e: React.MouseEvent)=>void | - | - |
|
|
104
107
|
|
|
105
108
|
**Prop Descriptions**
|
|
@@ -108,7 +111,17 @@ TransitionLink uses the Next.js Link component internally. For details about nav
|
|
|
108
111
|
**Description**
|
|
109
112
|
Triggers the transition.
|
|
110
113
|
|
|
111
|
-
*Must be used within the TransitionProvider*
|
|
114
|
+
*Must be used within the TransitionProvider*
|
|
115
|
+
|
|
116
|
+
`css`
|
|
117
|
+
```tsx
|
|
118
|
+
import {TransitionLink} from "page-transition/css"
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
`manual`
|
|
122
|
+
```tsx
|
|
123
|
+
import {TransitionLink} from "page-transition/manual"
|
|
124
|
+
```
|
|
112
125
|
|
|
113
126
|
```tsx
|
|
114
127
|
<TransitionLink href={"/home"}>
|
|
@@ -118,25 +131,27 @@ Triggers the transition.
|
|
|
118
131
|
|
|
119
132
|
### CSS Mode
|
|
120
133
|
|
|
121
|
-
The `TransitionProvider` uses a container with a `data-transition` attribute. When navigation starts, it adds the exit class and waits for the transitionend event of the configured transition property
|
|
134
|
+
The `TransitionProvider` uses a container with a `data-transition` attribute. When navigation starts, it adds the `exit` class and waits for the transitionend event of the configured `transition property`.
|
|
122
135
|
|
|
136
|
+
By default, the event is tracked on `.page-wrapper`, which contains the page's children.
|
|
123
137
|
|
|
138
|
+
If `options.overlay` is set to true, the event is tracked on `.overlay` instead. This is primarily intended for fade transitions.
|
|
124
139
|
|
|
125
|
-
|
|
140
|
+
If `options.items` specifies one or more items in the first group, the event is tracked on the last item of that group.
|
|
126
141
|
|
|
142
|
+
An `.overlay-wrapper` is available to group and position transition items. You can configure the number of items in each group using the `options.items` array.
|
|
127
143
|
|
|
144
|
+
Once the transition ends, the scroll position is restored and navigation is performed.
|
|
128
145
|
|
|
129
146
|
After navigation, the `exit` class is removed and the `enter` class is added. Once the next transitionend event fires, the enter class is removed.
|
|
130
147
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
For overlay animations, an `.overlay-wrapper` is available. You can configure the number of overlay items using the options.items array.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
148
|
```tsx
|
|
138
149
|
<div data-transition>
|
|
139
150
|
{outside}
|
|
151
|
+
{
|
|
152
|
+
options.overlay &&
|
|
153
|
+
<div className="overlay"/>
|
|
154
|
+
}
|
|
140
155
|
{
|
|
141
156
|
(options.items[0] > 0 || options.items[1] > 0) &&
|
|
142
157
|
<div className="overlay-wrapper">
|
|
@@ -150,12 +165,13 @@ For overlay animations, an `.overlay-wrapper` is available. You can configure th
|
|
|
150
165
|
```
|
|
151
166
|
|
|
152
167
|
|
|
153
|
-
To access the page wrapper, overlay wrapper and
|
|
168
|
+
To access the page wrapper, overlay, overlay wrapper, and their respective items, use `useCssContext`.
|
|
154
169
|
```ts
|
|
155
170
|
import { useTransitionContext } from "page-transition"
|
|
156
171
|
|
|
157
172
|
const {
|
|
158
|
-
pageWrapper,
|
|
173
|
+
pageWrapper,
|
|
174
|
+
overlay,
|
|
159
175
|
overlayWrapper,
|
|
160
176
|
overlayItems,
|
|
161
177
|
secondItems
|
|
@@ -170,21 +186,27 @@ options
|
|
|
170
186
|
|
|
171
187
|
```ts
|
|
172
188
|
transitionProperty: "opacity"
|
|
189
|
+
overlay: true
|
|
173
190
|
|
|
174
191
|
```
|
|
175
192
|
|
|
176
193
|
```css
|
|
177
|
-
[data-transition] .
|
|
194
|
+
[data-transition] .overlay{
|
|
195
|
+
position: fixed;
|
|
196
|
+
z-index: 98;
|
|
197
|
+
inset: 0;
|
|
198
|
+
background: white;
|
|
199
|
+
|
|
200
|
+
opacity: 0;
|
|
178
201
|
will-change: opacity;
|
|
179
|
-
opacity: 1;
|
|
180
202
|
}
|
|
181
|
-
[data-transition].exit .
|
|
182
|
-
opacity:
|
|
203
|
+
[data-transition].exit .overlay{
|
|
204
|
+
opacity: 1;
|
|
183
205
|
transition: opacity 0.4s ease;
|
|
184
206
|
|
|
185
207
|
}
|
|
186
|
-
[data-transition].enter .
|
|
187
|
-
opacity:
|
|
208
|
+
[data-transition].enter .overlay{
|
|
209
|
+
opacity: 0;
|
|
188
210
|
transition: opacity 0.5s ease;
|
|
189
211
|
}
|
|
190
212
|
```
|
|
@@ -197,19 +219,28 @@ options
|
|
|
197
219
|
|
|
198
220
|
```ts
|
|
199
221
|
transitionProperty: "clip-path"
|
|
222
|
+
overlay: true
|
|
200
223
|
items: [1, 0]
|
|
201
224
|
```
|
|
202
225
|
|
|
203
226
|
```css
|
|
204
|
-
[data-transition] .
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
227
|
+
[data-transition] .overlay{
|
|
228
|
+
position: fixed;
|
|
229
|
+
z-index: 98;
|
|
230
|
+
inset: 0;
|
|
231
|
+
background: white;
|
|
232
|
+
|
|
209
233
|
opacity: 0;
|
|
234
|
+
will-change: opacity;
|
|
210
235
|
}
|
|
211
|
-
[data-transition].
|
|
212
|
-
|
|
236
|
+
[data-transition].exit .overlay{
|
|
237
|
+
opacity: 1;
|
|
238
|
+
transition: opacity 0.4s ease;
|
|
239
|
+
|
|
240
|
+
}
|
|
241
|
+
[data-transition].enter .overlay{
|
|
242
|
+
opacity: 0;
|
|
243
|
+
transition: opacity 0.5s ease;
|
|
213
244
|
}
|
|
214
245
|
|
|
215
246
|
[data-transition] .overlay-wrapper{
|
|
@@ -377,7 +408,7 @@ Once `state.current` is set to `entering`, the navigation has occurred. After th
|
|
|
377
408
|
|
|
378
409
|
|
|
379
410
|
```ts
|
|
380
|
-
import {
|
|
411
|
+
import { useManualContext } from "page-transition"
|
|
381
412
|
|
|
382
413
|
const { resolveFn, state } = useTransitionContext()
|
|
383
414
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import Link from "next/link";
|
|
3
|
-
import {
|
|
3
|
+
import { useCssContext } from "../../context/CssContext";
|
|
4
4
|
export function TransitionLink({ href, className, prefetch, onClick, children }) {
|
|
5
|
-
const { handleLinkClick } =
|
|
5
|
+
const { handleLinkClick } = useCssContext();
|
|
6
6
|
return (_jsx(Link, { href: href, onClick: (e) => {
|
|
7
7
|
onClick?.(e);
|
|
8
8
|
handleLinkClick.current(e, href);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
interface Props {
|
|
3
|
+
href: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
prefetch?: boolean;
|
|
6
|
+
onClick?: (e: React.MouseEvent) => void;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare function TransitionLink({ href, className, prefetch, onClick, children }: Props): import("react").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import Link from "next/link";
|
|
3
|
+
import { useManualContext } from "../../context/ManualContext";
|
|
4
|
+
export function TransitionLink({ href, className, prefetch, onClick, children }) {
|
|
5
|
+
const { handleLinkClick } = useManualContext();
|
|
6
|
+
return (_jsx(Link, { href: href, onClick: (e) => {
|
|
7
|
+
onClick?.(e);
|
|
8
|
+
handleLinkClick.current(e, href);
|
|
9
|
+
}, className: className, prefetch: prefetch, children: children }));
|
|
10
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
interface ContextProps {
|
|
3
|
+
handleLinkClick: RefObject<((e: React.MouseEvent, url: string) => void)>;
|
|
4
|
+
pageWrapper?: RefObject<HTMLDivElement | null>;
|
|
5
|
+
overlay?: RefObject<HTMLDivElement | null>;
|
|
6
|
+
overlayWrapper?: RefObject<HTMLDivElement | null>;
|
|
7
|
+
overlayItems?: RefObject<(HTMLDivElement | null)[]>;
|
|
8
|
+
secondItems?: RefObject<(HTMLDivElement | null)[]>;
|
|
9
|
+
}
|
|
10
|
+
export declare const CssContext: import("react").Context<ContextProps | null>;
|
|
11
|
+
export declare function useCssContext(): ContextProps;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
export const CssContext = createContext(null);
|
|
4
|
+
export function useCssContext() {
|
|
5
|
+
const context = useContext(CssContext);
|
|
6
|
+
if (!context)
|
|
7
|
+
throw new Error('useCssContext in Provider!');
|
|
8
|
+
return context;
|
|
9
|
+
}
|
|
@@ -2,6 +2,7 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
import type { TransitionProperty } from "../types/transitionPropertys.types";
|
|
3
3
|
interface TransitionOptions {
|
|
4
4
|
transitionProperty: TransitionProperty;
|
|
5
|
+
overlay?: boolean;
|
|
5
6
|
items?: [number, number];
|
|
6
7
|
}
|
|
7
8
|
interface ProviderProps {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { CssContext } from "./CssContext";
|
|
4
4
|
import { useRef, useMemo, useEffect } from "react";
|
|
5
5
|
import { usePathname } from "next/navigation";
|
|
6
6
|
import { useTransitionEndHandler } from "../hooks/useTransitionEndHandler";
|
|
@@ -18,6 +18,7 @@ export function CssTransitionProvider({ outside, scroll, options, children }) {
|
|
|
18
18
|
};
|
|
19
19
|
const container = useRef(null);
|
|
20
20
|
const pageWrapper = useRef(null);
|
|
21
|
+
const overlay = useRef(null);
|
|
21
22
|
const overlayWrapper = useRef(null);
|
|
22
23
|
const overlayItems = useRef([]);
|
|
23
24
|
const secondItems = useRef([]);
|
|
@@ -33,8 +34,11 @@ export function CssTransitionProvider({ outside, scroll, options, children }) {
|
|
|
33
34
|
const resolveUseFn = useRef(null);
|
|
34
35
|
const handleLinkClick = useRef(() => { });
|
|
35
36
|
const transitionEndHandler = useTransitionEndHandler();
|
|
37
|
+
const elArray = defaultOptions.items[0] === 0 &&
|
|
38
|
+
!defaultOptions.overlay ?
|
|
39
|
+
pageWrapper : defaultOptions.items[0] > 0 ? overlayItems : overlay;
|
|
36
40
|
const transitionEndData = useTransitionEndData({
|
|
37
|
-
elArray
|
|
41
|
+
elArray,
|
|
38
42
|
transitionProperty: defaultOptions.transitionProperty,
|
|
39
43
|
secondElArray: secondItems
|
|
40
44
|
});
|
|
@@ -94,8 +98,16 @@ export function CssTransitionProvider({ outside, scroll, options, children }) {
|
|
|
94
98
|
});
|
|
95
99
|
currentPathname.current = window.location.pathname;
|
|
96
100
|
}, [pathname]);
|
|
97
|
-
const value = useMemo(() => ({
|
|
98
|
-
|
|
101
|
+
const value = useMemo(() => ({
|
|
102
|
+
handleLinkClick,
|
|
103
|
+
pageWrapper,
|
|
104
|
+
overlay,
|
|
105
|
+
overlayWrapper,
|
|
106
|
+
overlayItems,
|
|
107
|
+
secondItems
|
|
108
|
+
}), []);
|
|
109
|
+
return (_jsx(CssContext.Provider, { value: value, children: _jsxs("div", { ref: container, "data-transition": true, children: [outside, defaultOptions.overlay &&
|
|
110
|
+
_jsx("div", { ref: overlay, className: "overlay" }), (defaultOptions.items[0] > 0 || defaultOptions.items[1] > 0) &&
|
|
99
111
|
_jsxs("div", { ref: overlayWrapper, className: "overlay-wrapper", children: [defaultOptions.items[0] > 0 && Array.from({ length: defaultOptions.items[0] }).map((_, i) => (_jsx("div", { ref: (el) => {
|
|
100
112
|
overlayItems.current[i] = el;
|
|
101
113
|
}, className: "overlay-item" }, i))), defaultOptions.items[1] > 0 && Array.from({ length: defaultOptions.items[1] }).map((_, i) => (_jsx("div", { ref: (el) => {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
interface ContextProps {
|
|
3
|
+
handleLinkClick: RefObject<((e: React.MouseEvent, url: string) => void)>;
|
|
4
|
+
resolveFn?: RefObject<(() => void) | null>;
|
|
5
|
+
state?: RefObject<'idle' | 'exiting' | 'entering'>;
|
|
6
|
+
}
|
|
7
|
+
export declare const ManualContext: import("react").Context<ContextProps | null>;
|
|
8
|
+
export declare function useManualContext(): ContextProps;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
export const ManualContext = createContext(null);
|
|
4
|
+
export function useManualContext() {
|
|
5
|
+
const context = useContext(ManualContext);
|
|
6
|
+
if (!context)
|
|
7
|
+
throw new Error('useManualContext in Provider!');
|
|
8
|
+
return context;
|
|
9
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { ManualContext } from "./ManualContext";
|
|
4
4
|
import { useEffect, useRef, useMemo } from "react";
|
|
5
5
|
import { usePathname } from "next/navigation";
|
|
6
6
|
import { usePopState } from "../hooks/manual/usePopState";
|
|
@@ -40,5 +40,5 @@ export function ManualTransitionProvider({ scroll, children }) {
|
|
|
40
40
|
currentPathname.current = window.location.pathname;
|
|
41
41
|
}, [pathname]);
|
|
42
42
|
const value = useMemo(() => ({ handleLinkClick, resolveFn, state }), []);
|
|
43
|
-
return (_jsx(
|
|
43
|
+
return (_jsx(ManualContext.Provider, { value: value, children: children }));
|
|
44
44
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { TransitionProperty } from "../types/transitionPropertys.types";
|
|
3
|
+
interface TransitionOptions {
|
|
4
|
+
transitionProperty: TransitionProperty;
|
|
5
|
+
overlay?: boolean;
|
|
6
|
+
items?: [number, number];
|
|
7
|
+
}
|
|
8
|
+
interface BaseProps {
|
|
9
|
+
scroll?: 'auto' | 'top';
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
type ModeProps = {
|
|
13
|
+
mode?: 'css';
|
|
14
|
+
outside?: ReactNode;
|
|
15
|
+
options: TransitionOptions;
|
|
16
|
+
} | {
|
|
17
|
+
mode: 'manual';
|
|
18
|
+
outside?: never;
|
|
19
|
+
options?: never;
|
|
20
|
+
};
|
|
21
|
+
type ProviderProps = BaseProps & ModeProps;
|
|
22
|
+
export declare function TransitionProvider(props: ProviderProps): import("react").JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { CssTransitionProvider } from "./CssTransitionProvider";
|
|
4
|
+
import { ManualTransitionProvider } from "./ManualTransitionProvider";
|
|
5
|
+
export function TransitionProvider(props) {
|
|
6
|
+
const { scroll = 'auto', children } = props;
|
|
7
|
+
return (props.mode === 'manual' ?
|
|
8
|
+
_jsx(ManualTransitionProvider, { scroll: scroll, children: children }) :
|
|
9
|
+
_jsx(CssTransitionProvider, { scroll: scroll, outside: props.outside, options: props.options, children: children }));
|
|
10
|
+
}
|
package/dist/css.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TransitionLink } from "./components/css/TransitionLink";
|
package/dist/css.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TransitionLink } from "./components/css/TransitionLink";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { TransitionProvider
|
|
2
|
-
export {
|
|
1
|
+
export { TransitionProvider } from "./context/TransitionProvider";
|
|
2
|
+
export { useCssContext } from "./context/CssContext";
|
|
3
|
+
export { useManualContext } from "./context/ManualContext";
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
export { TransitionProvider
|
|
3
|
-
export {
|
|
2
|
+
export { TransitionProvider } from "./context/TransitionProvider";
|
|
3
|
+
export { useCssContext } from "./context/CssContext";
|
|
4
|
+
export { useManualContext } from "./context/ManualContext";
|
package/dist/manual.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TransitionLink } from "./components/manual/TransitionLink";
|
package/dist/manual.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TransitionLink } from "./components/manual/TransitionLink";
|
package/package.json
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "page-transition",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.58",
|
|
4
4
|
"description": "A page transition library for the Next.js App Router.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
8
8
|
],
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./css": {
|
|
15
|
+
"types": "./dist/css.d.ts",
|
|
16
|
+
"default": "./dist/css.js"
|
|
17
|
+
},
|
|
18
|
+
"./manual": {
|
|
19
|
+
"types": "./dist/manual.d.ts",
|
|
20
|
+
"default": "./dist/manual.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
9
23
|
"main": "./dist/index.js",
|
|
10
24
|
"types": "./dist/index.d.ts",
|
|
11
25
|
"scripts": {
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { ReactNode, RefObject } from "react";
|
|
2
|
-
import type { TransitionProperty } from "../types/transitionPropertys.types";
|
|
3
|
-
interface ContextProps {
|
|
4
|
-
handleLinkClick: RefObject<((e: React.MouseEvent, url: string) => void)>;
|
|
5
|
-
resolveFn?: RefObject<(() => void) | null>;
|
|
6
|
-
state?: RefObject<'idle' | 'exiting' | 'entering'>;
|
|
7
|
-
pageWrapper?: RefObject<HTMLDivElement | null>;
|
|
8
|
-
overlayWrapper?: RefObject<HTMLDivElement | null>;
|
|
9
|
-
overlayItems?: RefObject<(HTMLDivElement | null)[]>;
|
|
10
|
-
secondItems?: RefObject<(HTMLDivElement | null)[]>;
|
|
11
|
-
}
|
|
12
|
-
export declare const TransitionContext: import("react").Context<ContextProps | null>;
|
|
13
|
-
export declare function useTransitionContext(): ContextProps;
|
|
14
|
-
interface TransitionOptions {
|
|
15
|
-
transitionProperty: TransitionProperty;
|
|
16
|
-
items?: [number, number];
|
|
17
|
-
}
|
|
18
|
-
interface BaseProps {
|
|
19
|
-
scroll?: 'auto' | 'top';
|
|
20
|
-
children: ReactNode;
|
|
21
|
-
}
|
|
22
|
-
type ModeProps = {
|
|
23
|
-
mode?: 'css';
|
|
24
|
-
outside?: ReactNode;
|
|
25
|
-
options: TransitionOptions;
|
|
26
|
-
} | {
|
|
27
|
-
mode: 'manual';
|
|
28
|
-
outside?: never;
|
|
29
|
-
options?: never;
|
|
30
|
-
};
|
|
31
|
-
type ProviderProps = BaseProps & ModeProps;
|
|
32
|
-
export declare function TransitionProvider(props: ProviderProps): import("react").JSX.Element;
|
|
33
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useContext } from "react";
|
|
4
|
-
import { CssTransitionProvider } from "./CssTransitionProvider";
|
|
5
|
-
import { ManualTransitionProvider } from "./ManualTransitionProvider";
|
|
6
|
-
export const TransitionContext = createContext(null);
|
|
7
|
-
export function useTransitionContext() {
|
|
8
|
-
const context = useContext(TransitionContext);
|
|
9
|
-
if (!context)
|
|
10
|
-
throw new Error('useTransitionContext in Provider!');
|
|
11
|
-
return context;
|
|
12
|
-
}
|
|
13
|
-
export function TransitionProvider(props) {
|
|
14
|
-
const { scroll = 'auto' } = props;
|
|
15
|
-
return (props.mode === 'manual' ?
|
|
16
|
-
_jsx(ManualTransitionProvider, { scroll: scroll, children: props.children }) :
|
|
17
|
-
_jsx(CssTransitionProvider, { outside: props.outside, scroll: scroll, options: props.options, children: props.children }));
|
|
18
|
-
}
|
|
File without changes
|