@react-motion-router/core 2.0.0-beta.e30cd0d → 2.0.0-beta.sha-dfc284b
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/MetaData.d.ts +19 -0
- package/build/MotionContext.d.ts +1 -0
- package/build/NavigationBase.d.ts +21 -0
- package/build/RoutePropContext.d.ts +2 -0
- package/build/RouterBase.d.ts +59 -0
- package/build/RouterContext.d.ts +22 -0
- package/build/ScreenBase.d.ts +105 -0
- package/build/ScreenTransitionLayer.d.ts +32 -0
- package/build/ScreenTransitionLayerContext.d.ts +2 -0
- package/build/ScreenTransitionProvider.d.ts +31 -0
- package/build/SharedElement.d.ts +36 -0
- package/build/SharedElementScene.d.ts +17 -0
- package/build/SharedElementSceneContext.d.ts +2 -0
- package/build/SharedElementTransitionLayer.d.ts +29 -0
- package/build/common/constants.d.ts +5 -0
- package/build/common/events.d.ts +38 -0
- package/build/common/hooks.d.ts +7 -0
- package/build/common/types.d.ts +82 -0
- package/build/common/utils.d.ts +14 -0
- package/build/common/utils.js +168 -0
- package/build/common/utils.js.map +1 -0
- package/build/index.d.ts +11 -0
- package/build/index.js +1448 -0
- package/build/index.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { MetaType } from "./common/types";
|
|
2
|
+
export declare class MetaData {
|
|
3
|
+
#private;
|
|
4
|
+
private mutationObserver;
|
|
5
|
+
constructor();
|
|
6
|
+
get(key: string | MetaType): string | [string, string][] | undefined;
|
|
7
|
+
set(key: string | MetaType, content?: string | [string, string][]): void;
|
|
8
|
+
has(key: string | MetaType): boolean;
|
|
9
|
+
delete(key: string | MetaType): void;
|
|
10
|
+
clear(): void;
|
|
11
|
+
entries(): IterableIterator<[`http-equiv=${string}` | `name=${string}` | `itemprop=${string}` | `property=${string}` | `charset=${string}`, string | undefined]>;
|
|
12
|
+
[Symbol.iterator](): IterableIterator<[`http-equiv=${string}` | `name=${string}` | `itemprop=${string}` | `property=${string}` | `charset=${string}`, string | undefined]>;
|
|
13
|
+
get size(): number;
|
|
14
|
+
private observeMutations;
|
|
15
|
+
private metaDataFromNode;
|
|
16
|
+
private getMetaKey;
|
|
17
|
+
private getMetaContent;
|
|
18
|
+
private updateMetaElement;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const MotionContext: import("react").Context<number>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RouterHTMLElement, RouterBaseEventMap } from "./common/types";
|
|
2
|
+
import { MetaData } from "./MetaData";
|
|
3
|
+
import { RouterBase } from "./RouterBase";
|
|
4
|
+
export declare abstract class NavigationBase<E extends RouterBaseEventMap = RouterBaseEventMap> {
|
|
5
|
+
protected readonly router: RouterBase;
|
|
6
|
+
private static rootNavigatorRef;
|
|
7
|
+
readonly metaData: MetaData;
|
|
8
|
+
constructor(router: RouterBase);
|
|
9
|
+
addEventListener<K extends keyof E>(type: K, listener: (this: RouterHTMLElement<E>, ev: E[K]) => any, options?: boolean | AddEventListenerOptions): () => void;
|
|
10
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
|
|
11
|
+
removeEventListener<K extends keyof E>(type: K, listener: (this: RouterHTMLElement<E>, ev: E[K]) => any, options?: boolean | EventListenerOptions | undefined): void;
|
|
12
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
13
|
+
dispatchEvent(event: Event): Promise<boolean>;
|
|
14
|
+
get parent(): NavigationBase | null;
|
|
15
|
+
get routerId(): string;
|
|
16
|
+
get baseURL(): URL;
|
|
17
|
+
get baseURLPattern(): URLPattern;
|
|
18
|
+
getNavigatorById(routerId: string): NavigationBase<RouterBaseEventMap> | null;
|
|
19
|
+
preloadRoute(path: string): Promise<boolean>;
|
|
20
|
+
private get isInDocument();
|
|
21
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { NavigationBase } from './NavigationBase';
|
|
2
|
+
import { ScreenTransitionLayer } from './ScreenTransitionLayer';
|
|
3
|
+
import { ScreenChild, RouterBaseEventMap, RouterHTMLElement, ScreenState } from './common/types';
|
|
4
|
+
import { NestedRouterContext } from './RouterContext';
|
|
5
|
+
import { Component } from 'react';
|
|
6
|
+
import { ScreenBase } from './ScreenBase';
|
|
7
|
+
export interface RouterBaseProps<S extends ScreenBase = ScreenBase> {
|
|
8
|
+
id?: string;
|
|
9
|
+
config: {
|
|
10
|
+
screenConfig?: S["props"]["config"];
|
|
11
|
+
basePath?: string;
|
|
12
|
+
};
|
|
13
|
+
children: ScreenChild<S["props"], S> | ScreenChild<S["props"], S>[];
|
|
14
|
+
}
|
|
15
|
+
export interface RouterBaseState {
|
|
16
|
+
}
|
|
17
|
+
export declare abstract class RouterBase<P extends RouterBaseProps = RouterBaseProps, S extends RouterBaseState = RouterBaseState, E extends RouterBaseEventMap = RouterBaseEventMap> extends Component<P, S> {
|
|
18
|
+
#private;
|
|
19
|
+
protected readonly ref: import("react").RefObject<RouterHTMLElement<E>>;
|
|
20
|
+
protected screenTransitionLayer: import("react").RefObject<ScreenTransitionLayer>;
|
|
21
|
+
abstract readonly navigation: NavigationBase;
|
|
22
|
+
readonly screenState: ScreenState;
|
|
23
|
+
readonly parent: RouterBase | null;
|
|
24
|
+
private loadDispatched;
|
|
25
|
+
readonly parentScreen: ScreenBase | null;
|
|
26
|
+
private static rootRouterRef;
|
|
27
|
+
static readonly contextType: import("react").Context<{
|
|
28
|
+
parentRouter: RouterBase;
|
|
29
|
+
parentScreen: ScreenBase;
|
|
30
|
+
} | null>;
|
|
31
|
+
context: React.ContextType<typeof NestedRouterContext>;
|
|
32
|
+
constructor(props: P, context: React.ContextType<typeof NestedRouterContext>);
|
|
33
|
+
componentDidMount(): void;
|
|
34
|
+
componentWillUnmount(): void;
|
|
35
|
+
private handleNavigationDispatch;
|
|
36
|
+
getRouterById(routerId: string, target?: RouterBase): RouterBase | null;
|
|
37
|
+
dispatchEvent(event: Event): Promise<boolean>;
|
|
38
|
+
addEventListener<K extends keyof E>(type: K, listener: (this: RouterHTMLElement<E>, ev: E[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
39
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
40
|
+
removeEventListener<K extends keyof E>(type: K, listener: (this: RouterHTMLElement<E>, ev: E[K]) => any, options?: boolean | EventListenerOptions | undefined): void;
|
|
41
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
42
|
+
preloadRoute(pathname: string): Promise<boolean>;
|
|
43
|
+
get id(): string;
|
|
44
|
+
get isRoot(): boolean;
|
|
45
|
+
get baseURL(): URL;
|
|
46
|
+
get baseURLPattern(): URLPattern;
|
|
47
|
+
get pathPatterns(): {
|
|
48
|
+
pattern: string;
|
|
49
|
+
caseSensitive: boolean;
|
|
50
|
+
}[];
|
|
51
|
+
get mounted(): boolean;
|
|
52
|
+
get child(): RouterBase | null;
|
|
53
|
+
set child(child: RouterBase | null);
|
|
54
|
+
protected abstract canIntercept(navigateEvent: NavigateEvent): boolean;
|
|
55
|
+
protected abstract shouldIntercept(navigateEvent: NavigateEvent): boolean;
|
|
56
|
+
protected abstract intercept(navigateEvent: NavigateEvent): void;
|
|
57
|
+
protected abstract get screens(): P["children"];
|
|
58
|
+
render(): JSX.Element | undefined;
|
|
59
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ScreenBase } from './ScreenBase';
|
|
2
|
+
import { RouterBase } from './RouterBase';
|
|
3
|
+
export declare const NestedRouterContext: import("react").Context<{
|
|
4
|
+
parentRouter: RouterBase;
|
|
5
|
+
parentScreen: ScreenBase;
|
|
6
|
+
} | null>;
|
|
7
|
+
export declare const RouterContext: import("react").Context<RouterBase<import("./RouterBase").RouterBaseProps<ScreenBase<import("./ScreenBase").ScreenBaseProps<import(".").RoutePropBase<{}, import(".").PlainObject<any>>>, import("./ScreenBase").ScreenBaseState, import(".").RoutePropBase<{
|
|
8
|
+
header?: {
|
|
9
|
+
fallback?: React.ReactNode;
|
|
10
|
+
component: React.JSXElementConstructor<any> | import(".").LazyExoticComponent<any>;
|
|
11
|
+
};
|
|
12
|
+
footer?: {
|
|
13
|
+
fallback?: React.ReactNode;
|
|
14
|
+
component: React.JSXElementConstructor<any> | import(".").LazyExoticComponent<any>;
|
|
15
|
+
};
|
|
16
|
+
animation?: import(".").AnimationEffectFactory;
|
|
17
|
+
onEnter?: ((props: import("./ScreenBase").LifecycleProps<import(".").RoutePropBase<{}, import(".").PlainObject<any>>>) => void | Promise<void>) | undefined;
|
|
18
|
+
onExit?: ((props: import("./ScreenBase").LifecycleProps<import(".").RoutePropBase<{}, import(".").PlainObject<any>>>) => void | Promise<void>) | undefined;
|
|
19
|
+
onEntered?: ((props: import("./ScreenBase").LifecycleProps<import(".").RoutePropBase<{}, import(".").PlainObject<any>>>) => void | Promise<void>) | undefined;
|
|
20
|
+
onExited?: ((props: import("./ScreenBase").LifecycleProps<import(".").RoutePropBase<{}, import(".").PlainObject<any>>>) => void | Promise<void>) | undefined;
|
|
21
|
+
onLoad?: ((props: import("./ScreenBase").LifecycleProps<import(".").RoutePropBase<{}, import(".").PlainObject<any>>>) => void | Promise<void>) | undefined;
|
|
22
|
+
} | undefined, import(".").PlainObject<any>>>>, import("./RouterBase").RouterBaseState, import(".").RouterBaseEventMap>>;
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Component, ElementType } from "react";
|
|
2
|
+
import { ScreenTransitionProvider } from "./ScreenTransitionProvider";
|
|
3
|
+
import { AnimationEffectFactory, LazyExoticComponent, PlainObject, RoutePropBase } from "./common/types";
|
|
4
|
+
import { RouterContext } from "./RouterContext";
|
|
5
|
+
import { NavigationBase } from "./NavigationBase";
|
|
6
|
+
import { SharedElementScene } from "./SharedElementScene";
|
|
7
|
+
export interface ScreenBaseComponentProps<R extends RoutePropBase = RoutePropBase, N extends NavigationBase = NavigationBase> {
|
|
8
|
+
route: R;
|
|
9
|
+
navigation: N;
|
|
10
|
+
}
|
|
11
|
+
export interface LifecycleProps<R extends RoutePropBase> extends ScreenBaseComponentProps<R, NavigationBase> {
|
|
12
|
+
signal: AbortSignal;
|
|
13
|
+
}
|
|
14
|
+
export interface ScreenBaseProps<R extends RoutePropBase = RoutePropBase> {
|
|
15
|
+
component: React.JSXElementConstructor<any> | LazyExoticComponent<any>;
|
|
16
|
+
fallback?: React.ReactNode;
|
|
17
|
+
path: string;
|
|
18
|
+
resolvedPathname?: string;
|
|
19
|
+
defaultParams?: PlainObject;
|
|
20
|
+
caseSensitive?: boolean;
|
|
21
|
+
id?: string;
|
|
22
|
+
config?: {
|
|
23
|
+
header?: {
|
|
24
|
+
fallback?: React.ReactNode;
|
|
25
|
+
component: React.JSXElementConstructor<any> | LazyExoticComponent<any>;
|
|
26
|
+
};
|
|
27
|
+
footer?: {
|
|
28
|
+
fallback?: React.ReactNode;
|
|
29
|
+
component: React.JSXElementConstructor<any> | LazyExoticComponent<any>;
|
|
30
|
+
};
|
|
31
|
+
animation?: AnimationEffectFactory;
|
|
32
|
+
onEnter?: (props: LifecycleProps<R>) => void | Promise<void>;
|
|
33
|
+
onExit?: (props: LifecycleProps<R>) => void | Promise<void>;
|
|
34
|
+
onEntered?: (props: LifecycleProps<R>) => void | Promise<void>;
|
|
35
|
+
onExited?: (props: LifecycleProps<R>) => void | Promise<void>;
|
|
36
|
+
onLoad?: (props: LifecycleProps<R>) => void | Promise<void>;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface ScreenBaseState {
|
|
40
|
+
focused: boolean;
|
|
41
|
+
elementType: ElementType;
|
|
42
|
+
}
|
|
43
|
+
export declare abstract class ScreenBase<P extends ScreenBaseProps = ScreenBaseProps, S extends ScreenBaseState = ScreenBaseState, R extends RoutePropBase<ScreenBaseProps["config"]> = RoutePropBase<ScreenBaseProps["config"]>> extends Component<P, S> {
|
|
44
|
+
#private;
|
|
45
|
+
readonly sharedElementScene: SharedElementScene;
|
|
46
|
+
protected readonly ref: import("react").RefObject<HTMLDivElement>;
|
|
47
|
+
protected readonly nestedRouterData: {
|
|
48
|
+
parentScreen: ScreenBase;
|
|
49
|
+
parentRouter: import("./RouterBase").RouterBase<import("./RouterBase").RouterBaseProps<ScreenBase<ScreenBaseProps<RoutePropBase<{}, PlainObject<any>>>, ScreenBaseState, RoutePropBase<{
|
|
50
|
+
header?: {
|
|
51
|
+
fallback?: React.ReactNode;
|
|
52
|
+
component: React.JSXElementConstructor<any> | LazyExoticComponent<any>;
|
|
53
|
+
};
|
|
54
|
+
footer?: {
|
|
55
|
+
fallback?: React.ReactNode;
|
|
56
|
+
component: React.JSXElementConstructor<any> | LazyExoticComponent<any>;
|
|
57
|
+
};
|
|
58
|
+
animation?: AnimationEffectFactory;
|
|
59
|
+
onEnter?: ((props: LifecycleProps<RoutePropBase<{}, PlainObject<any>>>) => void | Promise<void>) | undefined;
|
|
60
|
+
onExit?: ((props: LifecycleProps<RoutePropBase<{}, PlainObject<any>>>) => void | Promise<void>) | undefined;
|
|
61
|
+
onEntered?: ((props: LifecycleProps<RoutePropBase<{}, PlainObject<any>>>) => void | Promise<void>) | undefined;
|
|
62
|
+
onExited?: ((props: LifecycleProps<RoutePropBase<{}, PlainObject<any>>>) => void | Promise<void>) | undefined;
|
|
63
|
+
onLoad?: ((props: LifecycleProps<RoutePropBase<{}, PlainObject<any>>>) => void | Promise<void>) | undefined;
|
|
64
|
+
} | undefined, PlainObject<any>>>>, import("./RouterBase").RouterBaseState, import("./common/types").RouterBaseEventMap>;
|
|
65
|
+
};
|
|
66
|
+
static readonly contextType: import("react").Context<import("./RouterBase").RouterBase<import("./RouterBase").RouterBaseProps<ScreenBase<ScreenBaseProps<RoutePropBase<{}, PlainObject<any>>>, ScreenBaseState, RoutePropBase<{
|
|
67
|
+
header?: {
|
|
68
|
+
fallback?: React.ReactNode;
|
|
69
|
+
component: React.JSXElementConstructor<any> | LazyExoticComponent<any>;
|
|
70
|
+
};
|
|
71
|
+
footer?: {
|
|
72
|
+
fallback?: React.ReactNode;
|
|
73
|
+
component: React.JSXElementConstructor<any> | LazyExoticComponent<any>;
|
|
74
|
+
};
|
|
75
|
+
animation?: AnimationEffectFactory;
|
|
76
|
+
onEnter?: ((props: LifecycleProps<RoutePropBase<{}, PlainObject<any>>>) => void | Promise<void>) | undefined;
|
|
77
|
+
onExit?: ((props: LifecycleProps<RoutePropBase<{}, PlainObject<any>>>) => void | Promise<void>) | undefined;
|
|
78
|
+
onEntered?: ((props: LifecycleProps<RoutePropBase<{}, PlainObject<any>>>) => void | Promise<void>) | undefined;
|
|
79
|
+
onExited?: ((props: LifecycleProps<RoutePropBase<{}, PlainObject<any>>>) => void | Promise<void>) | undefined;
|
|
80
|
+
onLoad?: ((props: LifecycleProps<RoutePropBase<{}, PlainObject<any>>>) => void | Promise<void>) | undefined;
|
|
81
|
+
} | undefined, PlainObject<any>>>>, import("./RouterBase").RouterBaseState, import("./common/types").RouterBaseEventMap>>;
|
|
82
|
+
context: React.ContextType<typeof RouterContext>;
|
|
83
|
+
state: S;
|
|
84
|
+
constructor(props: P, context: React.ContextType<typeof RouterContext>);
|
|
85
|
+
protected setParams(params: PlainObject): void;
|
|
86
|
+
protected setConfig(config: P['config']): void;
|
|
87
|
+
get id(): string;
|
|
88
|
+
get focused(): boolean;
|
|
89
|
+
blur(): Promise<void>;
|
|
90
|
+
focus(): Promise<void>;
|
|
91
|
+
load(signal: AbortSignal): Promise<{
|
|
92
|
+
default: any;
|
|
93
|
+
}>;
|
|
94
|
+
abstract get routeProp(): R;
|
|
95
|
+
abstract get config(): R["config"];
|
|
96
|
+
abstract get params(): R["params"];
|
|
97
|
+
onExited(signal: AbortSignal): Promise<void>;
|
|
98
|
+
onExit(signal: AbortSignal): Promise<void>;
|
|
99
|
+
onEnter(signal: AbortSignal): Promise<void>;
|
|
100
|
+
onEntered(signal: AbortSignal): Promise<void>;
|
|
101
|
+
get resolvedPathname(): P["resolvedPathname"] | undefined;
|
|
102
|
+
get path(): P["path"];
|
|
103
|
+
get transitionProvider(): import("react").RefObject<ScreenTransitionProvider>;
|
|
104
|
+
render(): JSX.Element;
|
|
105
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Component, RefObject } from 'react';
|
|
2
|
+
import { SharedElementTransitionLayer } from './SharedElementTransitionLayer';
|
|
3
|
+
import { Animation } from 'web-animations-extension';
|
|
4
|
+
import { ScreenChild } from './common/types';
|
|
5
|
+
import { NavigationBase } from './NavigationBase';
|
|
6
|
+
import { ScreenBase } from './ScreenBase';
|
|
7
|
+
interface ScreenTransitionLayerProps {
|
|
8
|
+
children: ScreenChild | ScreenChild[];
|
|
9
|
+
navigation: NavigationBase;
|
|
10
|
+
}
|
|
11
|
+
interface ScreenTransitionLayerState {
|
|
12
|
+
gestureNavigating: boolean;
|
|
13
|
+
progress: number;
|
|
14
|
+
}
|
|
15
|
+
export declare class ScreenTransitionLayer extends Component<ScreenTransitionLayerProps, ScreenTransitionLayerState> {
|
|
16
|
+
#private;
|
|
17
|
+
readonly sharedElementTransitionLayer: RefObject<SharedElementTransitionLayer>;
|
|
18
|
+
readonly animation: Animation;
|
|
19
|
+
state: ScreenTransitionLayerState;
|
|
20
|
+
private onAnimationFrame;
|
|
21
|
+
private onTransitionCancel;
|
|
22
|
+
private onTransitionStart;
|
|
23
|
+
private onTransitionEnd;
|
|
24
|
+
private onProgress;
|
|
25
|
+
get screens(): RefObject<ScreenBase>[];
|
|
26
|
+
set screens(screens: RefObject<ScreenBase>[]);
|
|
27
|
+
set direction(direction: PlaybackDirection);
|
|
28
|
+
get direction(): PlaybackDirection;
|
|
29
|
+
transition(): Animation;
|
|
30
|
+
render(): JSX.Element;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ScreenTransitionLayerContext } from './ScreenTransitionLayerContext';
|
|
2
|
+
import { AnimationEffectFactory } from './common/types';
|
|
3
|
+
import { NavigationBase } from './NavigationBase';
|
|
4
|
+
import { Component, ElementType } from 'react';
|
|
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>;
|
|
18
|
+
static readonly contextType: import("react").Context<import("./ScreenTransitionLayer").ScreenTransitionLayer>;
|
|
19
|
+
context: React.ContextType<typeof ScreenTransitionLayerContext>;
|
|
20
|
+
index: number;
|
|
21
|
+
exiting: boolean;
|
|
22
|
+
state: ScreenTransitionProviderState;
|
|
23
|
+
private onAnimationEnd;
|
|
24
|
+
private onAnimationStart;
|
|
25
|
+
componentDidMount(): void;
|
|
26
|
+
componentWillUnmount(): void;
|
|
27
|
+
get animationEffect(): AnimationEffect | null;
|
|
28
|
+
setZIndex(zIndex: React.CSSProperties["zIndex"]): Promise<void>;
|
|
29
|
+
render(): JSX.Element;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Component } from 'react';
|
|
2
|
+
import { SharedElementTransitionType, StyleKeyList } from './common/types';
|
|
3
|
+
import { SharedElementSceneContext } from './SharedElementSceneContext';
|
|
4
|
+
interface SharedElementConfig extends OptionalEffectTiming {
|
|
5
|
+
type?: SharedElementTransitionType;
|
|
6
|
+
transformOrigin?: React.CSSProperties["transformOrigin"];
|
|
7
|
+
styles?: StyleKeyList;
|
|
8
|
+
deepClone?: boolean;
|
|
9
|
+
}
|
|
10
|
+
interface SharedElementProps {
|
|
11
|
+
id: string;
|
|
12
|
+
children: React.ReactElement;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
config?: SharedElementConfig;
|
|
15
|
+
}
|
|
16
|
+
interface SharedElementState {
|
|
17
|
+
}
|
|
18
|
+
export declare class SharedElement extends Component<SharedElementProps, SharedElementState> {
|
|
19
|
+
readonly ref: import("react").RefObject<HTMLDivElement>;
|
|
20
|
+
static readonly contextType: import("react").Context<import("./SharedElementScene").SharedElementScene>;
|
|
21
|
+
context: React.ContextType<typeof SharedElementSceneContext>;
|
|
22
|
+
componentDidMount(): void;
|
|
23
|
+
componentDidUpdate(prevProps: SharedElementProps): void;
|
|
24
|
+
componentWillUnmount(): void;
|
|
25
|
+
get styles(): StyleKeyList;
|
|
26
|
+
get canTransition(): boolean;
|
|
27
|
+
get scene(): import("./SharedElementScene").SharedElementScene;
|
|
28
|
+
get id(): string;
|
|
29
|
+
get transitionType(): SharedElementTransitionType;
|
|
30
|
+
getBoundingClientRect(): DOMRect;
|
|
31
|
+
clone(): HTMLElement | null;
|
|
32
|
+
hide(): void;
|
|
33
|
+
unhide(): void;
|
|
34
|
+
render(): JSX.Element;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SharedElement } from "./SharedElement";
|
|
2
|
+
export declare class SharedElementScene {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly nodes: Map<string, SharedElement>;
|
|
5
|
+
getScreenRect: () => DOMRect;
|
|
6
|
+
keepAlive: boolean;
|
|
7
|
+
previousScene: SharedElementScene | null;
|
|
8
|
+
canTransition: boolean;
|
|
9
|
+
constructor(id: string);
|
|
10
|
+
addNode(node: SharedElement | null): void;
|
|
11
|
+
removeNode(_id: string): void;
|
|
12
|
+
get xRatio(): number;
|
|
13
|
+
get yRatio(): number;
|
|
14
|
+
get x(): number;
|
|
15
|
+
get y(): number;
|
|
16
|
+
isEmpty(): boolean;
|
|
17
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { StylableElement, StyleKeyList } from './common/types';
|
|
2
|
+
import { Component, RefObject } from 'react';
|
|
3
|
+
import { NavigationBase } from './NavigationBase';
|
|
4
|
+
import { ScreenBase } from './ScreenBase';
|
|
5
|
+
import { ParallelEffect } from 'web-animations-extension';
|
|
6
|
+
import { SharedElement } from './SharedElement';
|
|
7
|
+
interface SharedElementTransitionLayerProps {
|
|
8
|
+
navigation: NavigationBase;
|
|
9
|
+
}
|
|
10
|
+
interface SharedElementTransitionLayerState {
|
|
11
|
+
}
|
|
12
|
+
export declare class SharedElementTransitionLayer extends Component<SharedElementTransitionLayerProps, SharedElementTransitionLayerState> {
|
|
13
|
+
#private;
|
|
14
|
+
readonly ref: RefObject<HTMLDialogElement>;
|
|
15
|
+
state: SharedElementTransitionLayerState;
|
|
16
|
+
set outgoingScreen(outgoingScreen: RefObject<ScreenBase> | null);
|
|
17
|
+
set incomingScreen(incomingScreen: RefObject<ScreenBase> | null);
|
|
18
|
+
get outgoingScreen(): RefObject<ScreenBase> | null;
|
|
19
|
+
get incomingScreen(): RefObject<ScreenBase> | null;
|
|
20
|
+
getKeyframeProperties(element: Element, styleList: StyleKeyList): Record<string, string>;
|
|
21
|
+
copyStyles(srcElement: StylableElement, cloneElement: StylableElement, styleList: StyleKeyList): void;
|
|
22
|
+
getAnimationEffect<T extends {
|
|
23
|
+
instance: SharedElement;
|
|
24
|
+
clone: HTMLElement;
|
|
25
|
+
}>(start: T, end: T): ParallelEffect;
|
|
26
|
+
get animationEffect(): ParallelEffect | null;
|
|
27
|
+
render(): JSX.Element;
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export declare class TransitionStartEvent extends Event {
|
|
2
|
+
constructor();
|
|
3
|
+
}
|
|
4
|
+
export declare class TransitionCancelEvent extends Event {
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
export declare class TransitionEndEvent extends Event {
|
|
8
|
+
constructor();
|
|
9
|
+
}
|
|
10
|
+
export declare class MotionProgressStartEvent extends Event {
|
|
11
|
+
constructor();
|
|
12
|
+
}
|
|
13
|
+
export declare class MotionProgressEvent extends Event {
|
|
14
|
+
readonly progress: number;
|
|
15
|
+
constructor(progress: number);
|
|
16
|
+
}
|
|
17
|
+
export declare class MotionProgressEndEvent extends Event {
|
|
18
|
+
constructor();
|
|
19
|
+
}
|
|
20
|
+
export declare class LoadEvent extends Event implements Omit<NavigateEvent, 'navigationType'> {
|
|
21
|
+
#private;
|
|
22
|
+
constructor();
|
|
23
|
+
intercept(options?: NavigationInterceptOptions | undefined): void;
|
|
24
|
+
scroll(): void;
|
|
25
|
+
get transition(): {
|
|
26
|
+
from: NavigationHistoryEntry | null;
|
|
27
|
+
finished: Promise<void>;
|
|
28
|
+
navigationType: "load";
|
|
29
|
+
} | null;
|
|
30
|
+
get navigationType(): "load";
|
|
31
|
+
get userInitiated(): boolean;
|
|
32
|
+
get canIntercept(): boolean;
|
|
33
|
+
get hashChange(): boolean;
|
|
34
|
+
get formData(): FormData | null;
|
|
35
|
+
get downloadRequest(): string | null;
|
|
36
|
+
get destination(): NavigationDestination;
|
|
37
|
+
get signal(): AbortSignal;
|
|
38
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { NavigationBase } from "../NavigationBase";
|
|
2
|
+
import { RouterBase } from "../RouterBase";
|
|
3
|
+
import { RoutePropBase } from "./types";
|
|
4
|
+
export declare function useNavigationBase<T extends NavigationBase = NavigationBase>(): T;
|
|
5
|
+
export declare function useRouterBase<T extends RouterBase = RouterBase>(): T;
|
|
6
|
+
export declare function useMotion(): number;
|
|
7
|
+
export declare function useRouteBase<R extends RoutePropBase>(): R;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { ScreenBase, ScreenBaseProps } from '../ScreenBase';
|
|
2
|
+
import { MotionProgressEndEvent, MotionProgressEvent, MotionProgressStartEvent, TransitionCancelEvent, TransitionEndEvent, TransitionStartEvent } from './events';
|
|
3
|
+
import { SharedElement } from '../SharedElement';
|
|
4
|
+
import { StandardPropertiesHyphen } from 'csstype';
|
|
5
|
+
export type ScreenChild<P extends ScreenBaseProps = ScreenBaseProps, E extends ScreenBase<P> = ScreenBase<P>> = React.CElement<P, E>;
|
|
6
|
+
export interface AnimationEffectFactoryProps<R extends HTMLElement = HTMLElement> {
|
|
7
|
+
ref: R | null;
|
|
8
|
+
index: number;
|
|
9
|
+
exiting: boolean;
|
|
10
|
+
timeline: AnimationTimeline | null;
|
|
11
|
+
playbackRate: number;
|
|
12
|
+
direction: PlaybackDirection;
|
|
13
|
+
}
|
|
14
|
+
export type AnimationEffectFactory<R extends HTMLElement = HTMLElement> = (props: AnimationEffectFactoryProps<R>) => AnimationEffect;
|
|
15
|
+
export type MetaTypeKey = 'http-equiv' | 'name' | 'itemprop' | 'property' | 'charset';
|
|
16
|
+
export type MetaType = [MetaTypeKey, string];
|
|
17
|
+
export type MetaKey = `${MetaTypeKey}=${string}`;
|
|
18
|
+
export interface LazyExoticComponent<T extends React.ComponentType<any>> extends React.LazyExoticComponent<T> {
|
|
19
|
+
load: () => Promise<{
|
|
20
|
+
default: T;
|
|
21
|
+
}>;
|
|
22
|
+
module?: {
|
|
23
|
+
default: T;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export type ScreenState<P extends ScreenBaseProps = ScreenBaseProps> = Map<string, Pick<RoutePropBase<P["config"], PlainObject>, "config" | "params">>;
|
|
27
|
+
export interface RoutePropBase<C extends ScreenBaseProps["config"] = {}, P extends PlainObject = PlainObject> {
|
|
28
|
+
path: string;
|
|
29
|
+
resolvedPathname?: string;
|
|
30
|
+
config: Partial<NonNullable<C>>;
|
|
31
|
+
focused: boolean;
|
|
32
|
+
params: P;
|
|
33
|
+
setParams(params: Partial<P>): void;
|
|
34
|
+
setConfig(config: Partial<NonNullable<C>>): void;
|
|
35
|
+
}
|
|
36
|
+
export declare function isValidScreenChild<S extends ScreenBase>(value: any): value is ScreenChild<S["props"], S>;
|
|
37
|
+
export type PlainObject<T = any> = {
|
|
38
|
+
[key: string]: T;
|
|
39
|
+
};
|
|
40
|
+
export interface RouterBaseEventMap extends HTMLElementEventMap {
|
|
41
|
+
"transition-start": TransitionStartEvent;
|
|
42
|
+
"transition-cancel": TransitionCancelEvent;
|
|
43
|
+
"transition-end": TransitionEndEvent;
|
|
44
|
+
"motion-progress-start": MotionProgressStartEvent;
|
|
45
|
+
"motion-progress": MotionProgressEvent;
|
|
46
|
+
"motion-progress-end": MotionProgressEndEvent;
|
|
47
|
+
}
|
|
48
|
+
export type RouterHTMLElement<E extends RouterBaseEventMap, T extends HTMLElement = HTMLDivElement> = T & {
|
|
49
|
+
addEventListener<K extends keyof E>(type: K, listener: (this: T, ev: E[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
50
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
51
|
+
removeEventListener<K extends keyof E>(type: K, listener: (this: T, ev: E[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
52
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
53
|
+
};
|
|
54
|
+
export type CustomElementType = `${string}-${string}`;
|
|
55
|
+
export interface MatchedRoute {
|
|
56
|
+
params?: PlainObject<string | undefined>;
|
|
57
|
+
}
|
|
58
|
+
export interface PathPattern {
|
|
59
|
+
pattern: string;
|
|
60
|
+
caseSensitive: boolean;
|
|
61
|
+
}
|
|
62
|
+
export type AnimationDirection = "normal" | "reverse";
|
|
63
|
+
declare enum SharedElementTransitionTypeEnum {
|
|
64
|
+
"morph" = 0,
|
|
65
|
+
"fade-through" = 1,
|
|
66
|
+
"fade" = 2,
|
|
67
|
+
"cross-fade" = 3
|
|
68
|
+
}
|
|
69
|
+
export type SharedElementTransitionType = keyof typeof SharedElementTransitionTypeEnum;
|
|
70
|
+
export interface SharedElementNode {
|
|
71
|
+
id: string;
|
|
72
|
+
instance: SharedElement;
|
|
73
|
+
}
|
|
74
|
+
export type SharedElementNodeMap = Map<string, SharedElementNode>;
|
|
75
|
+
export type StyleKeyList = (keyof StandardPropertiesHyphen | string)[];
|
|
76
|
+
export declare function isNativeLazyExoticComponent(value: any): value is React.LazyExoticComponent<any>;
|
|
77
|
+
export declare function isLazyExoticComponent(value: any): value is LazyExoticComponent<any>;
|
|
78
|
+
export type StylableElement = Element & {
|
|
79
|
+
style: CSSStyleDeclaration;
|
|
80
|
+
};
|
|
81
|
+
export declare function isStylableElement(element: any): element is StylableElement;
|
|
82
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { LazyExoticComponent, MatchedRoute, PathPattern } from "./types";
|
|
2
|
+
export declare function resolveBaseURLFromPattern(pattern: string, pathname: string): URL | null;
|
|
3
|
+
export declare function matchRoute(pathnamePattern: string, pathname: string, baseURLPattern?: string, caseSensitive?: boolean): MatchedRoute | null;
|
|
4
|
+
export declare function includesRoute(pathnamePatterns: PathPattern[], pathname: string, baseURL?: string): boolean;
|
|
5
|
+
export declare function dispatchEvent<T>(event: CustomEvent<T> | Event, target?: HTMLElement | EventTarget): Promise<boolean>;
|
|
6
|
+
export declare function lazy<T extends React.ComponentType<any>>(factory: () => Promise<{
|
|
7
|
+
default: T;
|
|
8
|
+
}>): LazyExoticComponent<T>;
|
|
9
|
+
export declare function isNavigationSupported(): boolean;
|
|
10
|
+
export declare function isURLPatternSupported(): boolean;
|
|
11
|
+
export declare function polyfillURLPattern(): Promise<void>;
|
|
12
|
+
export declare function polyfillNavigation(): Promise<void>;
|
|
13
|
+
export declare function PromiseAllDynamic<T>(values: Iterable<T | PromiseLike<T>>): Promise<Awaited<T>[]>;
|
|
14
|
+
export declare function toCamelCase(value: string): string;
|