@react-motion-router/stack 2.0.0-beta.sha-112968d → 2.0.0-beta.sha-c19f37e
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/build/Anchor.d.ts +10 -15
- package/build/GestureRegion.d.ts +8 -3
- package/build/Navigation.d.ts +4 -5
- package/build/Router.d.ts +11 -9
- package/build/Screen.d.ts +14 -12
- package/build/__tests__/Navigation/common/constants.d.ts +1 -0
- package/build/__tests__/Navigation/navigation.index.test.d.ts +1 -0
- package/build/common/hooks.d.ts +0 -4
- package/build/common/types.d.ts +10 -12
- package/build/common/utils.d.ts +5 -0
- package/build/index.js +833 -832
- package/build/index.js.map +1 -1
- package/package.json +2 -2
- package/build/common/promise-wrapper.d.ts +0 -8
package/build/Anchor.d.ts
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { PlainObject } from '../../core/build';
|
|
2
|
-
import {
|
|
3
|
-
import { NavigateOptions, XOR } from './common/types';
|
|
4
|
-
interface BaseAnchorProps extends React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> {
|
|
5
|
-
onClick?: React.MouseEventHandler<HTMLAnchorElement>;
|
|
6
|
-
navigation?: Navigation | null;
|
|
7
|
-
}
|
|
1
|
+
import { PlainObject, AnchorProps as AnchorBaseProps } from '../../core/build';
|
|
2
|
+
import { ScreenConfig } from './Screen';
|
|
8
3
|
interface OnSightPreloadBehaviour extends UseIntersectionOptions {
|
|
9
4
|
type: 'onsight';
|
|
10
5
|
}
|
|
@@ -12,23 +7,23 @@ interface OnHoverPreloadBehaviour {
|
|
|
12
7
|
type: 'onhover';
|
|
13
8
|
forceThreshold?: number;
|
|
14
9
|
}
|
|
15
|
-
interface
|
|
10
|
+
interface AnchorProps extends AnchorBaseProps {
|
|
16
11
|
params?: PlainObject<string | boolean | number>;
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Will override params object if supplied.
|
|
14
|
+
* Used to control the search params that get passed to the href attribute.
|
|
15
|
+
*/
|
|
16
|
+
searchParams?: PlainObject<string | boolean | number>;
|
|
17
|
+
config?: ScreenConfig;
|
|
19
18
|
preload?: boolean;
|
|
20
19
|
preloadBehaviour?: OnSightPreloadBehaviour | OnHoverPreloadBehaviour | {
|
|
21
20
|
type: 'force';
|
|
22
21
|
};
|
|
23
22
|
}
|
|
24
|
-
interface BackAnchorProps extends BaseAnchorProps {
|
|
25
|
-
goBack: boolean;
|
|
26
|
-
}
|
|
27
|
-
type AnchorProps = XOR<ForwardAnchorProps, BackAnchorProps>;
|
|
28
23
|
interface UseIntersectionOptions {
|
|
29
24
|
root?: Element | null;
|
|
30
25
|
rootMargin?: string;
|
|
31
26
|
threshold?: number | number[];
|
|
32
27
|
}
|
|
33
|
-
export declare function Anchor({ preload,
|
|
28
|
+
export declare function Anchor({ preload, params, searchParams, config, preloadBehaviour, children, ...aProps }: AnchorProps): import("react/jsx-runtime").JSX.Element;
|
|
34
29
|
export {};
|
package/build/GestureRegion.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type GestureRegion = {
|
|
2
|
+
[T in keyof JSX.IntrinsicElements]: ReturnType<typeof createGestureRegion<T>>;
|
|
3
|
+
};
|
|
4
|
+
interface GestureRegionProps {
|
|
5
|
+
gestureBehaviour?: 'contain' | 'none';
|
|
6
|
+
uaGestureAreaWidth?: number;
|
|
3
7
|
}
|
|
4
|
-
export declare
|
|
8
|
+
export declare const createGestureRegion: <T extends keyof JSX.IntrinsicElements>(tag: T) => ({ ref: forwardedRef, gestureBehaviour, uaGestureAreaWidth, ...props }: JSX.IntrinsicElements[T] & GestureRegionProps) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export declare const GestureRegion: GestureRegion;
|
|
5
10
|
export {};
|
package/build/Navigation.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { LoadNavigationTransition, NavigationBase, NavigationBaseConfig, PathPattern } from '../../core/build';
|
|
2
|
-
import { GoBackOptions, GoForwardOptions, NavigateOptions, NavigationBaseOptions, NavigationProps
|
|
2
|
+
import { GoBackOptions, GoForwardOptions, NavigateOptions, NavigationBaseOptions, NavigationProps } from './common/types';
|
|
3
3
|
import { HistoryEntry } from './HistoryEntry';
|
|
4
|
-
export interface NavigationConfig extends NavigationBaseConfig
|
|
5
|
-
preload(pathname: string, props?: NavigationProps, options?: NavigationBaseOptions): Promise<boolean>;
|
|
4
|
+
export interface NavigationConfig extends NavigationBaseConfig {
|
|
6
5
|
getCommitted(): Promise<NavigationHistoryEntry> | null;
|
|
7
6
|
getTransition(): NavigationTransition | LoadNavigationTransition | null;
|
|
8
7
|
getPathPatterns(): PathPattern[];
|
|
9
8
|
}
|
|
10
|
-
export declare class Navigation extends NavigationBase
|
|
9
|
+
export declare class Navigation extends NavigationBase {
|
|
11
10
|
private readonly config;
|
|
12
11
|
constructor(config: NavigationConfig);
|
|
13
|
-
preload(route: string,
|
|
12
|
+
preload(route: string, state?: NavigationProps): NavigationResult;
|
|
14
13
|
replace(route: string, props?: NavigationProps, options?: NavigationBaseOptions): NavigationResult;
|
|
15
14
|
push(route: string, props?: NavigationProps, options?: NavigationBaseOptions): NavigationResult;
|
|
16
15
|
reload(props?: NavigationProps): NavigationResult;
|
package/build/Router.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { RouterBase, ClonedElementType, LoadEvent, NestedRouterContext, RouterBaseConfig, RouterBaseProps, RouterBaseState, ScreenChild } from '../../core/build';
|
|
2
2
|
import { Navigation } from './Navigation';
|
|
3
3
|
import { ScreenProps, Screen, ScreenConfig } from './Screen';
|
|
4
|
-
import {
|
|
4
|
+
import { ScreenInternalProps, SwipeDirection } from './common/types';
|
|
5
|
+
import { SwipeStartEvent, SwipeEndEvent } from 'web-gesture-events';
|
|
5
6
|
export interface RouterConfig extends RouterBaseConfig {
|
|
6
7
|
screenConfig?: ScreenConfig;
|
|
7
8
|
disableBrowserRouting?: boolean;
|
|
@@ -26,7 +27,7 @@ export interface RouterState extends RouterBaseState {
|
|
|
26
27
|
documentTitle?: string;
|
|
27
28
|
controller: AbortController | null;
|
|
28
29
|
}
|
|
29
|
-
export declare class Router extends RouterBase<RouterProps, RouterState
|
|
30
|
+
export declare class Router extends RouterBase<RouterProps, RouterState> {
|
|
30
31
|
#private;
|
|
31
32
|
readonly navigation: Navigation;
|
|
32
33
|
constructor(props: RouterProps, context: React.ContextType<typeof NestedRouterContext>);
|
|
@@ -41,27 +42,28 @@ export declare class Router extends RouterBase<RouterProps, RouterState, RouterE
|
|
|
41
42
|
componentDidMount(): void;
|
|
42
43
|
shouldComponentUpdate(nextProps: Readonly<RouterProps>, nextState: Readonly<RouterState>): boolean;
|
|
43
44
|
componentWillUnmount(): void;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
onnavigate(e: NavigateEvent): void;
|
|
46
|
+
oncurrententrychange(): void;
|
|
47
|
+
onnavigatesuccess(): void;
|
|
48
|
+
onnavigateerror({ error }: ErrorEvent): void;
|
|
48
49
|
private readonly onGestureCancel;
|
|
49
50
|
private canGestureNavigate;
|
|
50
|
-
|
|
51
|
-
|
|
51
|
+
onswipestart(e: SwipeStartEvent): void;
|
|
52
|
+
onswipeend(e: SwipeEndEvent): void;
|
|
52
53
|
get committed(): Promise<NavigationHistoryEntry> | null;
|
|
53
54
|
private get backNavigating();
|
|
54
55
|
protected get screens(): import('react').CElement<ScreenProps & Partial<InjectedScreenProps>, Screen & import('react').Component<ScreenProps & Pick<ScreenProps, "config" | "defaultParams"> & ScreenInternalProps, {}, any>>[];
|
|
55
|
-
preload(pathname: string, props?: NavigationProps, options?: NavigationBaseOptions): Promise<boolean>;
|
|
56
56
|
private cloneScreenChildFromPathname;
|
|
57
57
|
private getScreenRefByKey;
|
|
58
58
|
protected canIntercept(e: NavigateEvent): boolean;
|
|
59
59
|
protected shouldIntercept(e: NavigateEvent): boolean;
|
|
60
60
|
protected intercept(e: NavigateEvent | LoadEvent): void;
|
|
61
|
+
handlePreload(e: LoadEvent): void;
|
|
61
62
|
private handleLoad;
|
|
62
63
|
private handleReplace;
|
|
63
64
|
private handleDefault;
|
|
64
65
|
private dispatchLifecycleHandlers;
|
|
65
66
|
private screenTransition;
|
|
67
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
66
68
|
}
|
|
67
69
|
export {};
|
package/build/Screen.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { ScreenBase, PlainObject, ScreenBaseProps, ScreenBaseState, ScreenBaseComponentProps, ScreenBaseConfig } from '../../core/build';
|
|
1
|
+
import { ScreenBase, PlainObject, ScreenBaseProps, ScreenBaseState, ScreenBaseComponentProps, ScreenBaseConfig, MatchedRoute } from '../../core/build';
|
|
2
2
|
import { Navigation } from './Navigation';
|
|
3
|
-
import { RouteProp, SwipeDirection } from './common/types';
|
|
3
|
+
import { HistoryEntryState, RouteProp, SwipeDirection } from './common/types';
|
|
4
4
|
import { Router } from './Router';
|
|
5
|
+
import { HistoryEntry } from './HistoryEntry';
|
|
5
6
|
export type ScreenComponentProps<T extends PlainObject = object> = ScreenBaseComponentProps<RouteProp<T>, Navigation>;
|
|
6
7
|
export interface ScreenConfig extends ScreenBaseConfig<RouteProp> {
|
|
7
8
|
readonly title?: string;
|
|
@@ -22,6 +23,7 @@ export declare class Screen extends ScreenBase<ScreenProps, ScreenBaseState, Rou
|
|
|
22
23
|
static getDerivedStateFromProps(props: ScreenProps): {
|
|
23
24
|
elementType: string;
|
|
24
25
|
};
|
|
26
|
+
static historyEntryStateFromEntry(entry: HistoryEntry, matchInfo: MatchedRoute | null): HistoryEntryState;
|
|
25
27
|
protected setParams(newParams: PlainObject): void;
|
|
26
28
|
protected setConfig(newConfig: NonNullable<ScreenProps['config']>): void;
|
|
27
29
|
protected get router(): Router;
|
|
@@ -42,11 +44,11 @@ export declare class Screen extends ScreenBase<ScreenProps, ScreenBaseState, Rou
|
|
|
42
44
|
component: React.JSXElementConstructor<any> | import('../../core/build').LazyExoticComponent<any>;
|
|
43
45
|
};
|
|
44
46
|
animation?: import('../../core/build').AnimationEffectFactory;
|
|
45
|
-
onEnter?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase
|
|
46
|
-
onExit?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase
|
|
47
|
-
onEntered?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase
|
|
48
|
-
onExited?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase
|
|
49
|
-
onLoad?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase
|
|
47
|
+
onEnter?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase>) => void | Promise<void>) | ((props: import('../../core/build').LifecycleProps<RouteProp<{}>, import('../../core/build').NavigationBase>) => void | Promise<void>) | undefined;
|
|
48
|
+
onExit?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase>) => void | Promise<void>) | ((props: import('../../core/build').LifecycleProps<RouteProp<{}>, import('../../core/build').NavigationBase>) => void | Promise<void>) | undefined;
|
|
49
|
+
onEntered?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase>) => void | Promise<void>) | ((props: import('../../core/build').LifecycleProps<RouteProp<{}>, import('../../core/build').NavigationBase>) => void | Promise<void>) | undefined;
|
|
50
|
+
onExited?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase>) => void | Promise<void>) | ((props: import('../../core/build').LifecycleProps<RouteProp<{}>, import('../../core/build').NavigationBase>) => void | Promise<void>) | undefined;
|
|
51
|
+
onLoad?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase>) => void | Promise<void>) | ((props: import('../../core/build').LifecycleProps<RouteProp<{}>, import('../../core/build').NavigationBase>) => void | Promise<void>) | undefined;
|
|
50
52
|
title?: string;
|
|
51
53
|
presentation?: "default" | "dialog" | "modal";
|
|
52
54
|
keepAlive?: boolean;
|
|
@@ -75,11 +77,11 @@ export declare class Screen extends ScreenBase<ScreenProps, ScreenBaseState, Rou
|
|
|
75
77
|
component: React.JSXElementConstructor<any> | import('../../core/build').LazyExoticComponent<any>;
|
|
76
78
|
};
|
|
77
79
|
animation?: import('../../core/build').AnimationEffectFactory;
|
|
78
|
-
onEnter?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase
|
|
79
|
-
onExit?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase
|
|
80
|
-
onEntered?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase
|
|
81
|
-
onExited?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase
|
|
82
|
-
onLoad?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase
|
|
80
|
+
onEnter?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase>) => void | Promise<void>) | ((props: import('../../core/build').LifecycleProps<RouteProp<{}>, import('../../core/build').NavigationBase>) => void | Promise<void>) | undefined;
|
|
81
|
+
onExit?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase>) => void | Promise<void>) | ((props: import('../../core/build').LifecycleProps<RouteProp<{}>, import('../../core/build').NavigationBase>) => void | Promise<void>) | undefined;
|
|
82
|
+
onEntered?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase>) => void | Promise<void>) | ((props: import('../../core/build').LifecycleProps<RouteProp<{}>, import('../../core/build').NavigationBase>) => void | Promise<void>) | undefined;
|
|
83
|
+
onExited?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase>) => void | Promise<void>) | ((props: import('../../core/build').LifecycleProps<RouteProp<{}>, import('../../core/build').NavigationBase>) => void | Promise<void>) | undefined;
|
|
84
|
+
onLoad?: ((props: import('../../core/build').LifecycleProps<import('../../core/build').RoutePropBase<{}, PlainObject<any>>, import('../../core/build').NavigationBase>) => void | Promise<void>) | ((props: import('../../core/build').LifecycleProps<RouteProp<{}>, import('../../core/build').NavigationBase>) => void | Promise<void>) | undefined;
|
|
83
85
|
title?: string;
|
|
84
86
|
presentation?: "default" | "dialog" | "modal";
|
|
85
87
|
keepAlive?: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/common/hooks.d.ts
CHANGED
|
@@ -2,11 +2,7 @@ import { PlainObject } from '../../../core/build';
|
|
|
2
2
|
import { Navigation } from '../Navigation';
|
|
3
3
|
import { Router } from '../Router';
|
|
4
4
|
import { RouteProp } from './types';
|
|
5
|
-
import { RefObject } from 'react';
|
|
6
5
|
export declare function useNavigation(): Navigation;
|
|
7
6
|
export declare function useRouter(): Router;
|
|
8
7
|
export declare function useRoute<T extends PlainObject = PlainObject>(): RouteProp<T>;
|
|
9
8
|
export declare function useParams<K extends string, S>(key: K, initialParams: S | (() => S)): [S, import('react').Dispatch<import('react').SetStateAction<S>>];
|
|
10
|
-
type EventListenerOptions = boolean | AddEventListenerOptions;
|
|
11
|
-
export declare function useEventListener<K extends keyof HTMLElementEventMap>(ref: RefObject<HTMLElement | null>, eventName: K, handler: (event: HTMLElementEventMap[K]) => void, options?: EventListenerOptions): void;
|
|
12
|
-
export {};
|
package/build/common/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PlainObject, RoutePropBase
|
|
1
|
+
import { PlainObject, RoutePropBase } from '../../../core/build';
|
|
2
2
|
import { ScreenProps } from '../Screen';
|
|
3
3
|
import { RefObject } from 'react';
|
|
4
4
|
import { BackEvent, ForwardEvent, GestureCancelEvent, GestureEndEvent, GestureStartEvent, NavigateEvent } from './events';
|
|
@@ -25,23 +25,21 @@ export interface HistoryEntryState {
|
|
|
25
25
|
params?: PlainObject;
|
|
26
26
|
}
|
|
27
27
|
export declare function isRefObject<T>(value?: React.LegacyRef<T>): value is RefObject<T>;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
declare global {
|
|
29
|
+
interface HTMLElementEventMap {
|
|
30
|
+
'navigate': NavigateEvent;
|
|
31
|
+
'back': BackEvent;
|
|
32
|
+
'forward': ForwardEvent;
|
|
33
|
+
'gesture-start': GestureStartEvent;
|
|
34
|
+
'gesture-end': GestureEndEvent;
|
|
35
|
+
'gesture-cancel': GestureCancelEvent;
|
|
36
|
+
}
|
|
35
37
|
}
|
|
36
38
|
export interface RouteProp<T extends PlainObject = {}> extends RoutePropBase<ScreenProps['config'], T> {
|
|
37
39
|
}
|
|
38
40
|
export type SwipeDirection = 'up' | 'down' | 'left' | 'right' | 'horizontal' | 'vertical';
|
|
39
41
|
export type Direction = Exclude<SwipeDirection, 'horizontal' | 'vertical'>;
|
|
40
42
|
export declare function isSupportedDirection(direction: Exclude<SwipeDirection, 'horizontal' | 'vertical'>, supported: SwipeDirection): boolean;
|
|
41
|
-
export declare function isOutOfBounds(direction: SwipeDirection, { x, y }: {
|
|
42
|
-
x: number;
|
|
43
|
-
y: number;
|
|
44
|
-
}, clientRect: DOMRect, gestureAreaWidth: number): false | undefined;
|
|
45
43
|
export declare function isHorizontalDirection(direction: SwipeDirection): direction is 'left' | 'right' | 'horizontal';
|
|
46
44
|
export interface ScreenInternalProps {
|
|
47
45
|
resolvedPathname: string;
|
package/build/common/utils.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Direction } from './types';
|
|
1
2
|
export declare function searchParamsToObject(searchParams: URLSearchParams): {
|
|
2
3
|
[k: string]: string;
|
|
3
4
|
};
|
|
@@ -7,3 +8,7 @@ export declare function searchParamsFromObject(params: {
|
|
|
7
8
|
export declare function isGesture(info?: unknown): boolean;
|
|
8
9
|
export declare function isRollback(info?: unknown): boolean;
|
|
9
10
|
export declare function deepEquals<T>(obj1: T, obj2: T): boolean;
|
|
11
|
+
export declare function isWithinGestureInset(direction: Direction, { x, y }: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
}, clientRect: DOMRect, gestureAreaWidth: number): boolean;
|