UNPKG

2.62 kBTypeScriptView Raw
1
2import { InitialEntry } from "../../router/history.js";
3import { ActionFunction, IndexRouteObject, LoaderFunction, NonIndexRouteObject, RouterContextProvider } from "../../router/utils.js";
4import { HydrationState } from "../../router/router.js";
5import { LinksFunction, MetaFunction } from "./routeModules.js";
6import { FutureConfig } from "./entry.js";
7import * as React$1 from "react";
8
9//#region lib/dom/ssr/routes-test-stub.d.ts
10interface StubRouteExtensions {
11 Component?: React$1.ComponentType<any>;
12 HydrateFallback?: React$1.ComponentType<any>;
13 ErrorBoundary?: React$1.ComponentType<any>;
14 loader?: LoaderFunction;
15 action?: ActionFunction;
16 children?: StubRouteObject[];
17 meta?: MetaFunction;
18 links?: LinksFunction;
19}
20interface StubIndexRouteObject extends Omit<IndexRouteObject, "Component" | "HydrateFallback" | "ErrorBoundary" | "loader" | "action" | "element" | "errorElement" | "children">, StubRouteExtensions {}
21interface StubNonIndexRouteObject extends Omit<NonIndexRouteObject, "Component" | "HydrateFallback" | "ErrorBoundary" | "loader" | "action" | "element" | "errorElement" | "children">, StubRouteExtensions {}
22type StubRouteObject = StubIndexRouteObject | StubNonIndexRouteObject;
23interface RoutesTestStubProps {
24 /**
25 * The initial entries in the history stack. This allows you to start a test with
26 * multiple locations already in the history stack (for testing a back navigation, etc.)
27 * The test will default to the last entry in initialEntries if no initialIndex is provided.
28 * e.g. initialEntries={["/home", "/about", "/contact"]}
29 */
30 initialEntries?: InitialEntry[];
31 /**
32 * The initial index in the history stack to render. This allows you to start a test at a specific entry.
33 * It defaults to the last entry in initialEntries.
34 * e.g.
35 * initialEntries: ["/", "/events/123"]
36 * initialIndex: 1 // start at "/events/123"
37 */
38 initialIndex?: number;
39 /**
40 * Used to set the route's initial loader and action data.
41 * e.g. hydrationData={{
42 * loaderData: { "/contact": { locale: "en-US" } },
43 * actionData: { "/login": { errors: { email: "invalid email" } }}
44 * }}
45 */
46 hydrationData?: HydrationState;
47 /**
48 * Future flags mimicking the settings in react-router.config.ts
49 */
50 future?: Partial<FutureConfig>;
51}
52/**
53 * @category Utils
54 */
55declare function createRoutesStub(routes: StubRouteObject[], _context?: RouterContextProvider): ({
56 initialEntries,
57 initialIndex,
58 hydrationData,
59 future
60}: RoutesTestStubProps) => React$1.JSX.Element;
61//#endregion
62export { RoutesTestStubProps, createRoutesStub };
\No newline at end of file