@react-motion-router/core 2.0.0-beta.sha-c19f37e → 2.0.0-beta.sha-9a4805f
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 +8 -6
- package/build/RouterBase.d.ts +4 -1
- package/build/ScreenBase.d.ts +7 -6
- package/build/ScreenTransitionLayer.d.ts +0 -1
- package/build/ScreenTransitionProvider.d.ts +12 -27
- package/build/ViewTransitionSharedElement.d.ts +14 -0
- package/build/__tests__/Anchor/common/constants.d.ts +1 -0
- package/build/__tests__/common/utils.d.ts +4 -0
- package/build/common/events.d.ts +1 -1
- package/build/common/test-utils.d.ts +1 -1
- package/build/common/types.d.ts +9 -5
- package/build/common/utils.d.ts +1 -1
- package/build/index.js +641 -692
- package/build/index.js.map +1 -1
- package/package.json +2 -2
package/build/Anchor.d.ts
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
1
|
import { default as React, RefObject } from 'react';
|
|
2
|
+
import { EventHandler } from './common/types';
|
|
2
3
|
type AnchorState = {
|
|
3
4
|
href?: string | null;
|
|
4
5
|
};
|
|
5
6
|
interface AnchorBaseProps extends Omit<AnchorProps, 'ref'> {
|
|
6
7
|
ref?: RefObject<AnchorBase | null>;
|
|
7
8
|
}
|
|
8
|
-
export declare class AnchorBase extends React.Component<AnchorBaseProps, AnchorState> {
|
|
9
|
+
export declare class AnchorBase extends React.Component<AnchorBaseProps, AnchorState> implements EventHandler {
|
|
9
10
|
constructor(props: AnchorBaseProps);
|
|
10
11
|
readonly anchorRef: React.RefObject<HTMLAnchorElement | null>;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
static directionFromRel(rel: string | undefined): "next" | "prev";
|
|
13
|
+
static findClosestEntryByHref(href: string, rel: string | undefined, entries: NavigationHistoryEntry[], index: number): NavigationHistoryEntry | undefined;
|
|
14
|
+
static findClosestEntry(rel: string | undefined, entries: NavigationHistoryEntry[], index: number): NavigationHistoryEntry;
|
|
14
15
|
componentDidMount(): void;
|
|
15
16
|
componentWillUnmount(): void;
|
|
16
|
-
|
|
17
|
+
handleEvent(e: Event): void;
|
|
18
|
+
onnavigatesuccess(): void;
|
|
19
|
+
onclick(event: MouseEvent): void;
|
|
17
20
|
private get href();
|
|
18
21
|
private get search();
|
|
19
|
-
private readonly handleClick;
|
|
20
22
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
21
23
|
}
|
|
22
24
|
export interface AnchorProps extends React.DetailedHTMLProps<React.AnchorHTMLAttributes<HTMLAnchorElement>, HTMLAnchorElement> {
|
package/build/RouterBase.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { ScreenChild, RouterBaseHTMLElement, EventHandler } from './common/types
|
|
|
4
4
|
import { NestedRouterContext } from './RouterContext';
|
|
5
5
|
import { Component } from 'react';
|
|
6
6
|
import { ScreenBase, ScreenBaseConfig } from './ScreenBase';
|
|
7
|
+
import { LoadEvent } from './common/events';
|
|
7
8
|
type ScreenType<T> = T extends ScreenChild<infer S> | ScreenChild<infer S>[] ? S : never;
|
|
8
9
|
export interface RouterBaseConfig {
|
|
9
10
|
screenConfig?: ScreenBaseConfig;
|
|
@@ -22,7 +23,6 @@ export declare abstract class RouterBase<P extends RouterBaseProps = RouterBaseP
|
|
|
22
23
|
abstract readonly navigation: NavigationBase;
|
|
23
24
|
readonly parent: RouterBase | null;
|
|
24
25
|
private loadDispatched;
|
|
25
|
-
private hasUAVisualTransition;
|
|
26
26
|
readonly parentScreen: ScreenBase | null;
|
|
27
27
|
private static rootRouterRef;
|
|
28
28
|
static readonly contextType: import('react').Context<{
|
|
@@ -34,6 +34,7 @@ export declare abstract class RouterBase<P extends RouterBaseProps = RouterBaseP
|
|
|
34
34
|
private static get events();
|
|
35
35
|
componentDidMount(): void;
|
|
36
36
|
componentWillUnmount(): void;
|
|
37
|
+
interceptHandler: () => Promise<void>;
|
|
37
38
|
onnavigate(e: NavigateEvent): void;
|
|
38
39
|
getRouterById(routerId: string, target?: RouterBase): RouterBase | null;
|
|
39
40
|
dispatchEvent(event: Event): Promise<boolean>;
|
|
@@ -48,6 +49,8 @@ export declare abstract class RouterBase<P extends RouterBaseProps = RouterBaseP
|
|
|
48
49
|
} | null;
|
|
49
50
|
protected preloadScreen(screen: ScreenChild): Promise<void>;
|
|
50
51
|
includesRoute(pathname: string, baseURLPattern?: string): boolean;
|
|
52
|
+
get activeEvent(): LoadEvent | NavigateEvent | null;
|
|
53
|
+
get hasUAVisualTransition(): boolean;
|
|
51
54
|
get id(): string;
|
|
52
55
|
get isRoot(): boolean;
|
|
53
56
|
get baseURL(): URL;
|
package/build/ScreenBase.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Component,
|
|
1
|
+
import { Component, RefObject } from 'react';
|
|
2
2
|
import { ScreenTransitionProvider } from './ScreenTransitionProvider';
|
|
3
|
-
import { AnimationEffectFactory, LazyExoticComponent, PlainObject, RoutePropBase } from './common/types';
|
|
3
|
+
import { AnimationEffectFactory, EventHandler, LazyExoticComponent, PlainObject, RoutePropBase } from './common/types';
|
|
4
4
|
import { RouterContext } from './RouterContext';
|
|
5
5
|
import { NavigationBase } from './NavigationBase';
|
|
6
6
|
import { SharedElementScene } from './SharedElementScene';
|
|
@@ -46,12 +46,11 @@ export interface ScreenBaseState<C extends ScreenBaseProps['config'] = ScreenBas
|
|
|
46
46
|
focused: boolean;
|
|
47
47
|
config: C;
|
|
48
48
|
params: P;
|
|
49
|
-
elementType: ElementType;
|
|
50
49
|
}
|
|
51
|
-
export declare abstract class ScreenBase<P extends ScreenBaseProps = ScreenBaseProps, S extends ScreenBaseState<P['config']> = ScreenBaseState<P['config']>, R extends RoutePropBase<P['config']> = RoutePropBase<P['config']>> extends Component<P, S> {
|
|
50
|
+
export declare abstract class ScreenBase<P extends ScreenBaseProps = ScreenBaseProps, S extends ScreenBaseState<P['config']> = ScreenBaseState<P['config']>, R extends RoutePropBase<P['config']> = RoutePropBase<P['config']>> extends Component<P, S> implements EventHandler {
|
|
52
51
|
#private;
|
|
53
52
|
readonly sharedElementScene: SharedElementScene;
|
|
54
|
-
protected readonly ref:
|
|
53
|
+
protected abstract readonly ref: RefObject<HTMLElement | null>;
|
|
55
54
|
protected readonly nestedRouterData: {
|
|
56
55
|
parentScreen: ScreenBase;
|
|
57
56
|
parentRouter: import('./RouterBase').RouterBase<import('./RouterBase').RouterBaseProps<ScreenBase<ScreenBaseProps, ScreenBaseState<ScreenBaseConfig<RoutePropBase<{}, PlainObject<any>>, NavigationBase> | undefined, PlainObject>, RoutePropBase<ScreenBaseConfig<RoutePropBase<{}, PlainObject<any>>, NavigationBase> | undefined, PlainObject<any>>>>, object>;
|
|
@@ -60,6 +59,7 @@ export declare abstract class ScreenBase<P extends ScreenBaseProps = ScreenBaseP
|
|
|
60
59
|
context: React.ContextType<typeof RouterContext>;
|
|
61
60
|
state: S;
|
|
62
61
|
constructor(props: P, context: React.ContextType<typeof RouterContext>);
|
|
62
|
+
handleEvent(e: Event): void;
|
|
63
63
|
protected setParams(newParams: PlainObject): void;
|
|
64
64
|
protected setConfig(newConfig: R['config']): void;
|
|
65
65
|
get focused(): boolean;
|
|
@@ -74,11 +74,12 @@ export declare abstract class ScreenBase<P extends ScreenBaseProps = ScreenBaseP
|
|
|
74
74
|
abstract get params(): R['params'];
|
|
75
75
|
abstract get resolvedPathname(): string;
|
|
76
76
|
abstract get id(): string;
|
|
77
|
+
abstract get viewTransitionName(): string;
|
|
77
78
|
onExited(signal: AbortSignal): Promise<void>;
|
|
78
79
|
onExit(signal: AbortSignal): Promise<void>;
|
|
79
80
|
onEnter(signal: AbortSignal): Promise<void>;
|
|
80
81
|
onEntered(signal: AbortSignal): Promise<void>;
|
|
81
82
|
get path(): P["path"];
|
|
82
|
-
get transitionProvider():
|
|
83
|
+
get transitionProvider(): RefObject<ScreenTransitionProvider | null>;
|
|
83
84
|
render(): import("react/jsx-runtime").JSX.Element;
|
|
84
85
|
}
|
|
@@ -5,7 +5,6 @@ import { ScreenChild } from './common/types';
|
|
|
5
5
|
import { NavigationBase } from './NavigationBase';
|
|
6
6
|
import { ScreenBase } from './ScreenBase';
|
|
7
7
|
interface ScreenTransitionLayerProps {
|
|
8
|
-
id: string;
|
|
9
8
|
children: ScreenChild | ScreenChild[];
|
|
10
9
|
navigation: NavigationBase;
|
|
11
10
|
hasUAVisualTransition: boolean;
|
|
@@ -1,31 +1,16 @@
|
|
|
1
|
-
import { ScreenTransitionLayerContext } from './ScreenTransitionLayerContext';
|
|
2
1
|
import { AnimationEffectFactory } from './common/types';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
interface ScreenTransitionProviderProps {
|
|
6
|
-
id: string;
|
|
7
|
-
animation?: AnimationEffectFactory;
|
|
8
|
-
children: React.ReactNode;
|
|
9
|
-
navigation: NavigationBase;
|
|
10
|
-
renderAs: ElementType;
|
|
11
|
-
focused: boolean;
|
|
12
|
-
}
|
|
13
|
-
interface ScreenTransitionProviderState {
|
|
14
|
-
zIndex: React.CSSProperties['zIndex'];
|
|
15
|
-
}
|
|
16
|
-
export declare class ScreenTransitionProvider extends Component<ScreenTransitionProviderProps, ScreenTransitionProviderState> {
|
|
17
|
-
readonly ref: import('react').RefObject<HTMLElement | null>;
|
|
18
|
-
static readonly contextType: import('react').Context<import('./ScreenTransitionLayer').ScreenTransitionLayer>;
|
|
19
|
-
context: React.ContextType<typeof ScreenTransitionLayerContext>;
|
|
2
|
+
import { RefObject } from 'react';
|
|
3
|
+
export interface ScreenTransitionProvider {
|
|
20
4
|
index: number;
|
|
21
5
|
exiting: boolean;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
6
|
+
readonly animationEffect: AnimationEffect | null;
|
|
7
|
+
readonly screenElementRef: RefObject<HTMLElement | null>;
|
|
8
|
+
}
|
|
9
|
+
export interface ScreenTransitionProviderProps {
|
|
10
|
+
viewTransitionName: string;
|
|
11
|
+
animation?: AnimationEffectFactory;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
screenElementRef: RefObject<HTMLElement | null>;
|
|
14
|
+
ref?: RefObject<ScreenTransitionProvider | null>;
|
|
30
15
|
}
|
|
31
|
-
export
|
|
16
|
+
export declare function ScreenTransitionProvider(props: ScreenTransitionProviderProps): import('react').ReactNode;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SharedElementTransitionType } from './common/types';
|
|
2
|
+
type SharedElement = {
|
|
3
|
+
[T in keyof JSX.IntrinsicElements]: ReturnType<typeof createSharedElement<T>>;
|
|
4
|
+
};
|
|
5
|
+
interface SharedElementConfig extends OptionalEffectTiming {
|
|
6
|
+
type?: SharedElementTransitionType;
|
|
7
|
+
}
|
|
8
|
+
interface SharedElementProps {
|
|
9
|
+
id: string;
|
|
10
|
+
config?: SharedElementConfig;
|
|
11
|
+
}
|
|
12
|
+
export declare const createSharedElement: <T extends keyof JSX.IntrinsicElements>(tag: T) => ({ ref: forwardedRef, ...props }: JSX.IntrinsicElements[T] & SharedElementProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const SharedElement: SharedElement;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const SECOND_INDEX = 1;
|
|
@@ -15,12 +15,15 @@ export declare class TestRouter extends RouterBase {
|
|
|
15
15
|
protected shouldIntercept(): boolean;
|
|
16
16
|
protected get screens(): React.CElement<import('../../ScreenBase').ScreenBaseProps, ScreenBase<import('../../ScreenBase').ScreenBaseProps, import('../../ScreenBase').ScreenBaseState<import('../../ScreenBase').ScreenBaseConfig<import('../..').RoutePropBase<{}, import('../..').PlainObject<any>>, NavigationBase> | undefined, import('../..').PlainObject>, import('../..').RoutePropBase<import('../../ScreenBase').ScreenBaseConfig<import('../..').RoutePropBase<{}, import('../..').PlainObject<any>>, NavigationBase> | undefined, import('../..').PlainObject<any>>>> | React.CElement<import('../../ScreenBase').ScreenBaseProps, ScreenBase<import('../../ScreenBase').ScreenBaseProps, import('../../ScreenBase').ScreenBaseState<import('../../ScreenBase').ScreenBaseConfig<import('../..').RoutePropBase<{}, import('../..').PlainObject<any>>, NavigationBase> | undefined, import('../..').PlainObject>, import('../..').RoutePropBase<import('../../ScreenBase').ScreenBaseConfig<import('../..').RoutePropBase<{}, import('../..').PlainObject<any>>, NavigationBase> | undefined, import('../..').PlainObject<any>>>>[];
|
|
17
17
|
protected intercept(e: NavigateEvent): void;
|
|
18
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
18
19
|
}
|
|
19
20
|
export declare class TestScreen extends ScreenBase {
|
|
21
|
+
protected ref: React.RefObject<HTMLDivElement | null>;
|
|
20
22
|
get id(): string;
|
|
21
23
|
get params(): import('../..').PlainObject;
|
|
22
24
|
get config(): import('../../ScreenBase').ScreenBaseConfig<import('../..').RoutePropBase<{}, import('../..').PlainObject<any>>, NavigationBase>;
|
|
23
25
|
get resolvedPathname(): string;
|
|
26
|
+
get viewTransitionName(): string;
|
|
24
27
|
protected get routeProp(): {
|
|
25
28
|
config: import('../../ScreenBase').ScreenBaseConfig<import('../..').RoutePropBase<{}, import('../..').PlainObject<any>>, NavigationBase>;
|
|
26
29
|
params: import('../..').PlainObject;
|
|
@@ -30,4 +33,5 @@ export declare class TestScreen extends ScreenBase {
|
|
|
30
33
|
setConfig(): void;
|
|
31
34
|
setParams(): void;
|
|
32
35
|
};
|
|
36
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
33
37
|
}
|
package/build/common/events.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LoadNavigationTransition } from './types';
|
|
2
|
-
export declare class LoadEvent extends Event implements Omit<NavigateEvent, 'navigationType'
|
|
2
|
+
export declare class LoadEvent extends Event implements Omit<NavigateEvent, 'navigationType'> {
|
|
3
3
|
#private;
|
|
4
4
|
readonly hasUAVisualTransition = false;
|
|
5
5
|
constructor(navigationType: 'load' | 'preload', loadEventInitDict?: {
|
|
@@ -4,7 +4,7 @@ export declare function triggerRerender(): void;
|
|
|
4
4
|
export declare function createHistoryEntry(url: string, index: number): NavigationHistoryEntry;
|
|
5
5
|
export declare function assertNavigationAvailable(): void;
|
|
6
6
|
export declare function waitForNavigateSuccess(): Promise<void>;
|
|
7
|
-
export declare function navTo(url: string): Promise<void>;
|
|
7
|
+
export declare function navTo(url: string, history?: NavigationNavigateOptions['history']): Promise<void>;
|
|
8
8
|
export declare function traverseTo(key: string): Promise<void>;
|
|
9
9
|
export declare function traverseToStart(): Promise<void>;
|
|
10
10
|
export declare function seedHistory(): Promise<void>;
|
package/build/common/types.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { StandardPropertiesHyphen } from 'csstype';
|
|
|
4
4
|
export type ScreenChild<E extends ScreenBase = ScreenBase> = E extends ScreenBase<infer P> ? React.CElement<P, E> : never;
|
|
5
5
|
export interface AnimationEffectFactoryProps<R extends HTMLElement = HTMLElement> {
|
|
6
6
|
ref: R | null;
|
|
7
|
+
viewTransitionName: string;
|
|
7
8
|
index: number;
|
|
8
9
|
screens: string[];
|
|
9
10
|
exiting: boolean;
|
|
@@ -43,6 +44,13 @@ declare global {
|
|
|
43
44
|
'routertransitioncancel': TransitionEvent;
|
|
44
45
|
'routertransitionend': TransitionEvent;
|
|
45
46
|
}
|
|
47
|
+
interface NavigationPrecommitController {
|
|
48
|
+
redirect(url: string, options?: NavigationNavigateOptions): void;
|
|
49
|
+
addHandler(handler: NavigationInterceptOptions['handler']): void;
|
|
50
|
+
}
|
|
51
|
+
interface NavigationInterceptOptions {
|
|
52
|
+
precommitHandler?(controller: NavigationPrecommitController): Promise<void>;
|
|
53
|
+
}
|
|
46
54
|
}
|
|
47
55
|
export type EventHandler = {
|
|
48
56
|
[K in keyof HTMLElementEventMap as `on${K}`]?: (e: HTMLElementEventMap[K]) => void;
|
|
@@ -87,11 +95,7 @@ export declare function isStylableElement(element: any): element is StylableElem
|
|
|
87
95
|
export interface LoadNavigationTransition extends Omit<NavigationTransition, 'navigationType'> {
|
|
88
96
|
navigationType: 'load' | 'preload';
|
|
89
97
|
}
|
|
90
|
-
declare global {
|
|
91
|
-
interface NavigateEvent extends Event {
|
|
92
|
-
commit?(): void;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
98
|
export type ElementPropType<C> = C extends React.CElement<infer P, infer T> ? P & React.ClassAttributes<T> : never;
|
|
96
99
|
export type ClonedElementType<C, IP extends Partial<ElementPropType<C>>> = C extends React.CElement<infer P, infer T> ? React.CElement<P & Partial<IP>, T & React.Component<P & IP>> : never;
|
|
100
|
+
export type ElementForTag<T extends keyof JSX.IntrinsicElements> = T extends keyof (HTMLElementTagNameMap & SVGElementTagNameMap) ? (HTMLElementTagNameMap & SVGElementTagNameMap)[T] : HTMLElement;
|
|
97
101
|
export {};
|
package/build/common/utils.d.ts
CHANGED
|
@@ -13,4 +13,4 @@ export declare function PromiseAllSequential<T>(values: Iterable<T | PromiseLike
|
|
|
13
13
|
export declare function toCamelCase(value: string): string;
|
|
14
14
|
export declare function cloneAndInject<C extends React.CElement<any, any>, IP extends Partial<ElementPropType<C>>>(element: C, injectProps: IP): ClonedElementType<C, IP>;
|
|
15
15
|
export declare function omit<T extends object, K extends readonly (keyof T)[]>(obj: T, keys: K): Omit<T, K[number]>;
|
|
16
|
-
export declare function historyEntryFromDestination(destination: NavigationDestination): NavigationHistoryEntry;
|
|
16
|
+
export declare function historyEntryFromDestination(destination: NavigationDestination, index?: number): NavigationHistoryEntry;
|