storybook 9.0.0-beta.8 → 9.0.0-rc.0

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.
Files changed (75) hide show
  1. package/assets/server/base-preview-head.html +21 -0
  2. package/assets/server/template.ejs +4 -4
  3. package/dist/actions/preview.cjs +1 -1
  4. package/dist/actions/preview.d.ts +501 -0
  5. package/dist/actions/preview.js +1 -1
  6. package/dist/backgrounds/index.d.ts +501 -0
  7. package/dist/backgrounds/preview.d.ts +501 -0
  8. package/dist/bin/index.cjs +61 -61
  9. package/dist/bin/index.js +59 -59
  10. package/dist/builder-manager/index.cjs +208 -203
  11. package/dist/builder-manager/index.js +492 -487
  12. package/dist/channels/index.js +919 -941
  13. package/dist/cli/bin/index.cjs +1032 -1032
  14. package/dist/cli/bin/index.js +1032 -1032
  15. package/dist/cli/index.cjs +33709 -28783
  16. package/dist/cli/index.js +33641 -28711
  17. package/dist/common/index.cjs +2802 -2789
  18. package/dist/common/index.d.ts +2 -1
  19. package/dist/common/index.js +3250 -3237
  20. package/dist/components/index.cjs +711 -711
  21. package/dist/components/index.d.ts +2 -1
  22. package/dist/components/index.js +2266 -2272
  23. package/dist/controls/preview.d.ts +501 -0
  24. package/dist/core-events/index.cjs +55 -52
  25. package/dist/core-events/index.d.ts +3 -1
  26. package/dist/core-events/index.js +52 -49
  27. package/dist/core-server/index.cjs +3066 -3037
  28. package/dist/core-server/index.d.ts +512 -11
  29. package/dist/core-server/index.js +3271 -3241
  30. package/dist/core-server/presets/common-manager.js +4570 -5779
  31. package/dist/core-server/presets/common-override-preset.cjs +10 -12
  32. package/dist/core-server/presets/common-override-preset.js +3 -5
  33. package/dist/core-server/presets/common-preset.cjs +112 -116
  34. package/dist/core-server/presets/common-preset.js +10 -14
  35. package/dist/csf/index.d.ts +1 -1
  36. package/dist/csf-tools/index.cjs +116 -111
  37. package/dist/csf-tools/index.js +33 -28
  38. package/dist/docs-tools/index.js +596 -603
  39. package/dist/highlight/preview.d.ts +501 -0
  40. package/dist/instrumenter/index.js +1851 -3554
  41. package/dist/manager/globals-module-info.cjs +3 -0
  42. package/dist/manager/globals-module-info.js +3 -0
  43. package/dist/manager/globals-runtime.js +21347 -23051
  44. package/dist/manager/runtime.js +2510 -2498
  45. package/dist/manager-api/index.cjs +2302 -8594
  46. package/dist/manager-api/index.d.ts +501 -0
  47. package/dist/manager-api/index.js +2655 -2715
  48. package/dist/manager-errors.js +37 -41
  49. package/dist/measure/index.d.ts +501 -0
  50. package/dist/measure/preview.d.ts +501 -0
  51. package/dist/outline/index.d.ts +501 -0
  52. package/dist/outline/preview.d.ts +501 -0
  53. package/dist/preview/runtime.js +38393 -40149
  54. package/dist/preview-api/index.cjs +1546 -1459
  55. package/dist/preview-api/index.d.ts +8 -5
  56. package/dist/preview-api/index.js +1273 -1203
  57. package/dist/preview-errors.js +152 -173
  58. package/dist/router/index.cjs +5700 -2327
  59. package/dist/router/index.d.ts +622 -243
  60. package/dist/router/index.js +1297 -870
  61. package/dist/test/index.cjs +1810 -1811
  62. package/dist/test/index.d.ts +53 -5
  63. package/dist/test/index.js +7614 -7703
  64. package/dist/test/preview.cjs +51 -15860
  65. package/dist/test/preview.d.ts +520 -13
  66. package/dist/test/preview.js +44 -14491
  67. package/dist/theming/index.cjs +17 -0
  68. package/dist/theming/index.js +17 -0
  69. package/dist/types/index.d.ts +516 -82
  70. package/dist/viewport/index.d.ts +502 -3
  71. package/dist/viewport/preview.d.ts +501 -0
  72. package/package.json +3 -18
  73. package/dist/test/spy.cjs +0 -258
  74. package/dist/test/spy.d.ts +0 -62
  75. package/dist/test/spy.js +0 -240
@@ -23,242 +23,606 @@ type Match$1 = {
23
23
  };
24
24
  declare const getMatch: (current: string, target: string | RegExp, startsWith?: any) => Match$1 | null;
25
25
 
26
- /**
27
- * Actions represent the type of change to a location value.
28
- *
29
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#action
30
- */
31
- declare enum Action {
32
- /**
33
- * A POP indicates a change to an arbitrary index in the history stack, such
34
- * as a back or forward navigation. It does not describe the direction of the
35
- * navigation, only that the current index changed.
36
- *
37
- * Note: This is the default action for newly created history objects.
38
- */
39
- Pop = "POP",
40
- /**
41
- * A PUSH indicates a new entry being added to the history stack, such as when
42
- * a link is clicked and a new page loads. When this happens, all subsequent
43
- * entries in the stack are lost.
44
- */
45
- Push = "PUSH",
46
- /**
47
- * A REPLACE indicates the entry at the current index in the history stack
48
- * being replaced by a new one.
49
- */
50
- Replace = "REPLACE"
51
- }
52
- /**
53
- * A URL pathname, beginning with a /.
54
- *
55
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.pathname
56
- */
57
- declare type Pathname = string;
58
- /**
59
- * A URL search string, beginning with a ?.
60
- *
61
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.search
62
- */
63
- declare type Search = string;
64
- /**
65
- * A URL fragment identifier, beginning with a #.
66
- *
67
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.hash
68
- */
69
- declare type Hash = string;
70
- /**
71
- * A unique string associated with a location. May be used to safely store
72
- * and retrieve data in some other storage API, like `localStorage`.
73
- *
74
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.key
75
- */
76
- declare type Key = string;
77
- /**
78
- * The pathname, search, and hash values of a URL.
79
- */
80
- interface Path {
81
- /**
82
- * A URL pathname, beginning with a /.
83
- *
84
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.pathname
85
- */
86
- pathname: Pathname;
87
- /**
88
- * A URL search string, beginning with a ?.
89
- *
90
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.search
91
- */
92
- search: Search;
93
- /**
94
- * A URL fragment identifier, beginning with a #.
95
- *
96
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.hash
97
- */
98
- hash: Hash;
99
- }
100
- /**
101
- * An entry in a history stack. A location contains information about the
102
- * URL path, as well as possibly some arbitrary state and a key.
103
- *
104
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location
105
- */
106
- interface Location$2 extends Path {
107
- /**
108
- * A value of arbitrary data associated with this location.
109
- *
110
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.state
111
- */
112
- state: unknown;
113
- /**
114
- * A unique string associated with this location. May be used to safely store
115
- * and retrieve data in some other storage API, like `localStorage`.
116
- *
117
- * Note: This value is always "default" on the initial location.
118
- *
119
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#location.key
120
- */
121
- key: Key;
122
- }
123
- /**
124
- * A change to the current location.
125
- */
126
- interface Update {
127
- /**
128
- * The action that triggered the change.
129
- */
130
- action: Action;
131
- /**
132
- * The new location.
133
- */
134
- location: Location$2;
135
- }
136
- /**
137
- * A function that receives notifications about location changes.
138
- */
139
- interface Listener {
140
- (update: Update): void;
141
- }
142
- /**
143
- * A change to the current location that was blocked. May be retried
144
- * after obtaining user confirmation.
145
- */
146
- interface Transition extends Update {
147
- /**
148
- * Retries the update to the current location.
149
- */
150
- retry(): void;
151
- }
152
- /**
153
- * A function that receives transitions when navigation is blocked.
154
- */
155
- interface Blocker {
156
- (tx: Transition): void;
157
- }
158
- /**
159
- * Describes a location that is the destination of some navigation, either via
160
- * `history.push` or `history.replace`. May be either a URL or the pieces of a
161
- * URL path.
162
- */
163
- declare type To = string | Partial<Path>;
164
- /**
165
- * A history is an interface to the navigation stack. The history serves as the
166
- * source of truth for the current location, as well as provides a set of
167
- * methods that may be used to change it.
168
- *
169
- * It is similar to the DOM's `window.history` object, but with a smaller, more
170
- * focused API.
171
- */
172
- interface History {
173
- /**
174
- * The last action that modified the current location. This will always be
175
- * Action.Pop when a history instance is first created. This value is mutable.
176
- *
177
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#history.action
178
- */
179
- readonly action: Action;
180
- /**
181
- * The current location. This value is mutable.
182
- *
183
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#history.location
184
- */
185
- readonly location: Location$2;
186
- /**
187
- * Returns a valid href for the given `to` value that may be used as
188
- * the value of an <a href> attribute.
189
- *
190
- * @param to - The destination URL
191
- *
192
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#history.createHref
193
- */
194
- createHref(to: To): string;
195
- /**
196
- * Pushes a new location onto the history stack, increasing its length by one.
197
- * If there were any entries in the stack after the current one, they are
198
- * lost.
199
- *
200
- * @param to - The new URL
201
- * @param state - Data to associate with the new location
202
- *
203
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#history.push
204
- */
205
- push(to: To, state?: any): void;
206
- /**
207
- * Replaces the current location in the history stack with a new one. The
208
- * location that was replaced will no longer be available.
209
- *
210
- * @param to - The new URL
211
- * @param state - Data to associate with the new location
212
- *
213
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#history.replace
214
- */
215
- replace(to: To, state?: any): void;
216
- /**
217
- * Navigates `n` entries backward/forward in the history stack relative to the
218
- * current index. For example, a "back" navigation would use go(-1).
219
- *
220
- * @param delta - The delta in the stack index
221
- *
222
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#history.go
223
- */
224
- go(delta: number): void;
225
- /**
226
- * Navigates to the previous entry in the stack. Identical to go(-1).
227
- *
228
- * Warning: if the current location is the first location in the stack, this
229
- * will unload the current document.
230
- *
231
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#history.back
232
- */
233
- back(): void;
234
- /**
235
- * Navigates to the next entry in the stack. Identical to go(1).
236
- *
237
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#history.forward
238
- */
239
- forward(): void;
240
- /**
241
- * Sets up a listener that will be called whenever the current location
242
- * changes.
243
- *
244
- * @param listener - A function that will be called when the location changes
245
- * @returns unlisten - A function that may be used to stop listening
246
- *
247
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#history.listen
248
- */
249
- listen(listener: Listener): () => void;
250
- /**
251
- * Prevents the current location from changing and sets up a listener that
252
- * will be called instead.
253
- *
254
- * @param blocker - A function that will be called when a transition is blocked
255
- * @returns unblock - A function that may be used to stop blocking
256
- *
257
- * @see https://github.com/remix-run/history/tree/main/docs/api-reference.md#history.block
258
- */
259
- block(blocker: Blocker): () => void;
26
+ /**
27
+ * Actions represent the type of change to a location value.
28
+ */
29
+ declare enum Action {
30
+ /**
31
+ * A POP indicates a change to an arbitrary index in the history stack, such
32
+ * as a back or forward navigation. It does not describe the direction of the
33
+ * navigation, only that the current index changed.
34
+ *
35
+ * Note: This is the default action for newly created history objects.
36
+ */
37
+ Pop = "POP",
38
+ /**
39
+ * A PUSH indicates a new entry being added to the history stack, such as when
40
+ * a link is clicked and a new page loads. When this happens, all subsequent
41
+ * entries in the stack are lost.
42
+ */
43
+ Push = "PUSH",
44
+ /**
45
+ * A REPLACE indicates the entry at the current index in the history stack
46
+ * being replaced by a new one.
47
+ */
48
+ Replace = "REPLACE"
49
+ }
50
+ /**
51
+ * The pathname, search, and hash values of a URL.
52
+ */
53
+ interface Path {
54
+ /**
55
+ * A URL pathname, beginning with a /.
56
+ */
57
+ pathname: string;
58
+ /**
59
+ * A URL search string, beginning with a ?.
60
+ */
61
+ search: string;
62
+ /**
63
+ * A URL fragment identifier, beginning with a #.
64
+ */
65
+ hash: string;
66
+ }
67
+ /**
68
+ * An entry in a history stack. A location contains information about the
69
+ * URL path, as well as possibly some arbitrary state and a key.
70
+ */
71
+ interface Location$2 extends Path {
72
+ /**
73
+ * A value of arbitrary data associated with this location.
74
+ */
75
+ state: any;
76
+ /**
77
+ * A unique string associated with this location. May be used to safely store
78
+ * and retrieve data in some other storage API, like `localStorage`.
79
+ *
80
+ * Note: This value is always "default" on the initial location.
81
+ */
82
+ key: string;
83
+ }
84
+ /**
85
+ * A change to the current location.
86
+ */
87
+ interface Update {
88
+ /**
89
+ * The action that triggered the change.
90
+ */
91
+ action: Action;
92
+ /**
93
+ * The new location.
94
+ */
95
+ location: Location$2;
96
+ /**
97
+ * The delta between this location and the former location in the history stack
98
+ */
99
+ delta: number | null;
100
+ }
101
+ /**
102
+ * A function that receives notifications about location changes.
103
+ */
104
+ interface Listener {
105
+ (update: Update): void;
106
+ }
107
+ /**
108
+ * Describes a location that is the destination of some navigation, either via
109
+ * `history.push` or `history.replace`. May be either a URL or the pieces of a
110
+ * URL path.
111
+ */
112
+ type To = string | Partial<Path>;
113
+ /**
114
+ * A history is an interface to the navigation stack. The history serves as the
115
+ * source of truth for the current location, as well as provides a set of
116
+ * methods that may be used to change it.
117
+ *
118
+ * It is similar to the DOM's `window.history` object, but with a smaller, more
119
+ * focused API.
120
+ */
121
+ interface History {
122
+ /**
123
+ * The last action that modified the current location. This will always be
124
+ * Action.Pop when a history instance is first created. This value is mutable.
125
+ */
126
+ readonly action: Action;
127
+ /**
128
+ * The current location. This value is mutable.
129
+ */
130
+ readonly location: Location$2;
131
+ /**
132
+ * Returns a valid href for the given `to` value that may be used as
133
+ * the value of an <a href> attribute.
134
+ *
135
+ * @param to - The destination URL
136
+ */
137
+ createHref(to: To): string;
138
+ /**
139
+ * Returns a URL for the given `to` value
140
+ *
141
+ * @param to - The destination URL
142
+ */
143
+ createURL(to: To): URL;
144
+ /**
145
+ * Encode a location the same way window.history would do (no-op for memory
146
+ * history) so we ensure our PUSH/REPLACE navigations for data routers
147
+ * behave the same as POP
148
+ *
149
+ * @param to Unencoded path
150
+ */
151
+ encodeLocation(to: To): Path;
152
+ /**
153
+ * Pushes a new location onto the history stack, increasing its length by one.
154
+ * If there were any entries in the stack after the current one, they are
155
+ * lost.
156
+ *
157
+ * @param to - The new URL
158
+ * @param state - Data to associate with the new location
159
+ */
160
+ push(to: To, state?: any): void;
161
+ /**
162
+ * Replaces the current location in the history stack with a new one. The
163
+ * location that was replaced will no longer be available.
164
+ *
165
+ * @param to - The new URL
166
+ * @param state - Data to associate with the new location
167
+ */
168
+ replace(to: To, state?: any): void;
169
+ /**
170
+ * Navigates `n` entries backward/forward in the history stack relative to the
171
+ * current index. For example, a "back" navigation would use go(-1).
172
+ *
173
+ * @param delta - The delta in the stack index
174
+ */
175
+ go(delta: number): void;
176
+ /**
177
+ * Sets up a listener that will be called whenever the current location
178
+ * changes.
179
+ *
180
+ * @param listener - A function that will be called when the location changes
181
+ * @returns unlisten - A function that may be used to stop listening
182
+ */
183
+ listen(listener: Listener): () => void;
260
184
  }
261
185
 
186
+ /**
187
+ * Map of routeId -> data returned from a loader/action/error
188
+ */
189
+ interface RouteData {
190
+ [routeId: string]: any;
191
+ }
192
+ declare enum ResultType {
193
+ data = "data",
194
+ deferred = "deferred",
195
+ redirect = "redirect",
196
+ error = "error"
197
+ }
198
+ /**
199
+ * Successful result from a loader or action
200
+ */
201
+ interface SuccessResult {
202
+ type: ResultType.data;
203
+ data: any;
204
+ statusCode?: number;
205
+ headers?: Headers;
206
+ }
207
+ /**
208
+ * Successful defer() result from a loader or action
209
+ */
210
+ interface DeferredResult {
211
+ type: ResultType.deferred;
212
+ deferredData: DeferredData;
213
+ statusCode?: number;
214
+ headers?: Headers;
215
+ }
216
+ /**
217
+ * Redirect result from a loader or action
218
+ */
219
+ interface RedirectResult {
220
+ type: ResultType.redirect;
221
+ status: number;
222
+ location: string;
223
+ revalidate: boolean;
224
+ reloadDocument?: boolean;
225
+ }
226
+ /**
227
+ * Unsuccessful result from a loader or action
228
+ */
229
+ interface ErrorResult {
230
+ type: ResultType.error;
231
+ error: any;
232
+ headers?: Headers;
233
+ }
234
+ /**
235
+ * Result from a loader or action - potentially successful or unsuccessful
236
+ */
237
+ type DataResult = SuccessResult | DeferredResult | RedirectResult | ErrorResult;
238
+ type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
239
+ type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
240
+ /**
241
+ * Active navigation/fetcher form methods are exposed in lowercase on the
242
+ * RouterState
243
+ */
244
+ type FormMethod = LowerCaseFormMethod;
245
+ /**
246
+ * In v7, active navigation/fetcher form methods are exposed in uppercase on the
247
+ * RouterState. This is to align with the normalization done via fetch().
248
+ */
249
+ type V7_FormMethod = UpperCaseFormMethod;
250
+ type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
251
+ type JsonObject = {
252
+ [Key in string]: JsonValue;
253
+ } & {
254
+ [Key in string]?: JsonValue | undefined;
255
+ };
256
+ type JsonArray = JsonValue[] | readonly JsonValue[];
257
+ type JsonPrimitive = string | number | boolean | null;
258
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
259
+ /**
260
+ * @private
261
+ * Internal interface to pass around for action submissions, not intended for
262
+ * external consumption
263
+ */
264
+ type Submission = {
265
+ formMethod: FormMethod | V7_FormMethod;
266
+ formAction: string;
267
+ formEncType: FormEncType;
268
+ formData: FormData;
269
+ json: undefined;
270
+ text: undefined;
271
+ } | {
272
+ formMethod: FormMethod | V7_FormMethod;
273
+ formAction: string;
274
+ formEncType: FormEncType;
275
+ formData: undefined;
276
+ json: JsonValue;
277
+ text: undefined;
278
+ } | {
279
+ formMethod: FormMethod | V7_FormMethod;
280
+ formAction: string;
281
+ formEncType: FormEncType;
282
+ formData: undefined;
283
+ json: undefined;
284
+ text: string;
285
+ };
286
+ /**
287
+ * @private
288
+ * Arguments passed to route loader/action functions. Same for now but we keep
289
+ * this as a private implementation detail in case they diverge in the future.
290
+ */
291
+ interface DataFunctionArgs {
292
+ request: Request;
293
+ params: Params;
294
+ context?: any;
295
+ }
296
+ /**
297
+ * Arguments passed to loader functions
298
+ */
299
+ interface LoaderFunctionArgs extends DataFunctionArgs {
300
+ }
301
+ /**
302
+ * Arguments passed to action functions
303
+ */
304
+ interface ActionFunctionArgs extends DataFunctionArgs {
305
+ }
306
+ /**
307
+ * Loaders and actions can return anything except `undefined` (`null` is a
308
+ * valid return value if there is no data to return). Responses are preferred
309
+ * and will ease any future migration to Remix
310
+ */
311
+ type DataFunctionValue = Response | NonNullable<unknown> | null;
312
+ /**
313
+ * Route loader function signature
314
+ */
315
+ interface LoaderFunction {
316
+ (args: LoaderFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
317
+ }
318
+ /**
319
+ * Route action function signature
320
+ */
321
+ interface ActionFunction {
322
+ (args: ActionFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
323
+ }
324
+ /**
325
+ * Route shouldRevalidate function signature. This runs after any submission
326
+ * (navigation or fetcher), so we flatten the navigation/fetcher submission
327
+ * onto the arguments. It shouldn't matter whether it came from a navigation
328
+ * or a fetcher, what really matters is the URLs and the formData since loaders
329
+ * have to re-run based on the data models that were potentially mutated.
330
+ */
331
+ interface ShouldRevalidateFunction {
332
+ (args: {
333
+ currentUrl: URL;
334
+ currentParams: AgnosticDataRouteMatch["params"];
335
+ nextUrl: URL;
336
+ nextParams: AgnosticDataRouteMatch["params"];
337
+ formMethod?: Submission["formMethod"];
338
+ formAction?: Submission["formAction"];
339
+ formEncType?: Submission["formEncType"];
340
+ text?: Submission["text"];
341
+ formData?: Submission["formData"];
342
+ json?: Submission["json"];
343
+ actionResult?: DataResult;
344
+ defaultShouldRevalidate: boolean;
345
+ }): boolean;
346
+ }
347
+ /**
348
+ * Keys we cannot change from within a lazy() function. We spread all other keys
349
+ * onto the route. Either they're meaningful to the router, or they'll get
350
+ * ignored.
351
+ */
352
+ type ImmutableRouteKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
353
+ type RequireOne<T, Key = keyof T> = Exclude<{
354
+ [K in keyof T]: K extends Key ? Omit<T, K> & Required<Pick<T, K>> : never;
355
+ }[keyof T], undefined>;
356
+ /**
357
+ * lazy() function to load a route definition, which can add non-matching
358
+ * related properties to a route
359
+ */
360
+ interface LazyRouteFunction<R extends AgnosticRouteObject> {
361
+ (): Promise<RequireOne<Omit<R, ImmutableRouteKey>>>;
362
+ }
363
+ /**
364
+ * Base RouteObject with common props shared by all types of routes
365
+ */
366
+ type AgnosticBaseRouteObject = {
367
+ caseSensitive?: boolean;
368
+ path?: string;
369
+ id?: string;
370
+ loader?: LoaderFunction;
371
+ action?: ActionFunction;
372
+ hasErrorBoundary?: boolean;
373
+ shouldRevalidate?: ShouldRevalidateFunction;
374
+ handle?: any;
375
+ lazy?: LazyRouteFunction<AgnosticBaseRouteObject>;
376
+ };
377
+ /**
378
+ * Index routes must not have children
379
+ */
380
+ type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
381
+ children?: undefined;
382
+ index: true;
383
+ };
384
+ /**
385
+ * Non-index routes may have children, but cannot have index
386
+ */
387
+ type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
388
+ children?: AgnosticRouteObject[];
389
+ index?: false;
390
+ };
391
+ /**
392
+ * A route object represents a logical route, with (optionally) its child
393
+ * routes organized in a tree-like structure.
394
+ */
395
+ type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
396
+ type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
397
+ id: string;
398
+ };
399
+ type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
400
+ children?: AgnosticDataRouteObject[];
401
+ id: string;
402
+ };
403
+ /**
404
+ * A data route object, which is just a RouteObject with a required unique ID
405
+ */
406
+ type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
407
+ /**
408
+ * The parameters that were parsed from the URL path.
409
+ */
410
+ type Params<Key extends string = string> = {
411
+ readonly [key in Key]: string | undefined;
412
+ };
413
+ /**
414
+ * A RouteMatch contains info about how a route matched a URL.
415
+ */
416
+ interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
417
+ /**
418
+ * The names and values of dynamic parameters in the URL.
419
+ */
420
+ params: Params<ParamKey>;
421
+ /**
422
+ * The portion of the URL pathname that was matched.
423
+ */
424
+ pathname: string;
425
+ /**
426
+ * The portion of the URL pathname that was matched before child routes.
427
+ */
428
+ pathnameBase: string;
429
+ /**
430
+ * The route object that was used to match.
431
+ */
432
+ route: RouteObjectType;
433
+ }
434
+ interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
435
+ }
436
+ declare class DeferredData {
437
+ private pendingKeysSet;
438
+ private controller;
439
+ private abortPromise;
440
+ private unlistenAbortSignal;
441
+ private subscribers;
442
+ data: Record<string, unknown>;
443
+ init?: ResponseInit;
444
+ deferredKeys: string[];
445
+ constructor(data: Record<string, unknown>, responseInit?: ResponseInit);
446
+ private trackPromise;
447
+ private onSettle;
448
+ private emit;
449
+ subscribe(fn: (aborted: boolean, settledKey?: string) => void): () => boolean;
450
+ cancel(): void;
451
+ resolveData(signal: AbortSignal): Promise<boolean>;
452
+ get done(): boolean;
453
+ get unwrappedData(): {};
454
+ get pendingKeys(): string[];
455
+ }
456
+
457
+ /**
458
+ * State maintained internally by the router. During a navigation, all states
459
+ * reflect the the "old" location unless otherwise noted.
460
+ */
461
+ interface RouterState {
462
+ /**
463
+ * The action of the most recent navigation
464
+ */
465
+ historyAction: Action;
466
+ /**
467
+ * The current location reflected by the router
468
+ */
469
+ location: Location$2;
470
+ /**
471
+ * The current set of route matches
472
+ */
473
+ matches: AgnosticDataRouteMatch[];
474
+ /**
475
+ * Tracks whether we've completed our initial data load
476
+ */
477
+ initialized: boolean;
478
+ /**
479
+ * Current scroll position we should start at for a new view
480
+ * - number -> scroll position to restore to
481
+ * - false -> do not restore scroll at all (used during submissions)
482
+ * - null -> don't have a saved position, scroll to hash or top of page
483
+ */
484
+ restoreScrollPosition: number | false | null;
485
+ /**
486
+ * Indicate whether this navigation should skip resetting the scroll position
487
+ * if we are unable to restore the scroll position
488
+ */
489
+ preventScrollReset: boolean;
490
+ /**
491
+ * Tracks the state of the current navigation
492
+ */
493
+ navigation: Navigation;
494
+ /**
495
+ * Tracks any in-progress revalidations
496
+ */
497
+ revalidation: RevalidationState;
498
+ /**
499
+ * Data from the loaders for the current matches
500
+ */
501
+ loaderData: RouteData;
502
+ /**
503
+ * Data from the action for the current matches
504
+ */
505
+ actionData: RouteData | null;
506
+ /**
507
+ * Errors caught from loaders for the current matches
508
+ */
509
+ errors: RouteData | null;
510
+ /**
511
+ * Map of current fetchers
512
+ */
513
+ fetchers: Map<string, Fetcher>;
514
+ /**
515
+ * Map of current blockers
516
+ */
517
+ blockers: Map<string, Blocker>;
518
+ }
519
+ /**
520
+ * Data that can be passed into hydrate a Router from SSR
521
+ */
522
+ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
523
+ type RelativeRoutingType = "route" | "path";
524
+ /**
525
+ * Potential states for state.navigation
526
+ */
527
+ type NavigationStates = {
528
+ Idle: {
529
+ state: "idle";
530
+ location: undefined;
531
+ formMethod: undefined;
532
+ formAction: undefined;
533
+ formEncType: undefined;
534
+ formData: undefined;
535
+ json: undefined;
536
+ text: undefined;
537
+ };
538
+ Loading: {
539
+ state: "loading";
540
+ location: Location$2;
541
+ formMethod: Submission["formMethod"] | undefined;
542
+ formAction: Submission["formAction"] | undefined;
543
+ formEncType: Submission["formEncType"] | undefined;
544
+ formData: Submission["formData"] | undefined;
545
+ json: Submission["json"] | undefined;
546
+ text: Submission["text"] | undefined;
547
+ };
548
+ Submitting: {
549
+ state: "submitting";
550
+ location: Location$2;
551
+ formMethod: Submission["formMethod"];
552
+ formAction: Submission["formAction"];
553
+ formEncType: Submission["formEncType"];
554
+ formData: Submission["formData"];
555
+ json: Submission["json"];
556
+ text: Submission["text"];
557
+ };
558
+ };
559
+ type Navigation = NavigationStates[keyof NavigationStates];
560
+ type RevalidationState = "idle" | "loading";
561
+ /**
562
+ * Potential states for fetchers
563
+ */
564
+ type FetcherStates<TData = any> = {
565
+ Idle: {
566
+ state: "idle";
567
+ formMethod: undefined;
568
+ formAction: undefined;
569
+ formEncType: undefined;
570
+ text: undefined;
571
+ formData: undefined;
572
+ json: undefined;
573
+ data: TData | undefined;
574
+ " _hasFetcherDoneAnything "?: boolean;
575
+ };
576
+ Loading: {
577
+ state: "loading";
578
+ formMethod: Submission["formMethod"] | undefined;
579
+ formAction: Submission["formAction"] | undefined;
580
+ formEncType: Submission["formEncType"] | undefined;
581
+ text: Submission["text"] | undefined;
582
+ formData: Submission["formData"] | undefined;
583
+ json: Submission["json"] | undefined;
584
+ data: TData | undefined;
585
+ " _hasFetcherDoneAnything "?: boolean;
586
+ };
587
+ Submitting: {
588
+ state: "submitting";
589
+ formMethod: Submission["formMethod"];
590
+ formAction: Submission["formAction"];
591
+ formEncType: Submission["formEncType"];
592
+ text: Submission["text"];
593
+ formData: Submission["formData"];
594
+ json: Submission["json"];
595
+ data: TData | undefined;
596
+ " _hasFetcherDoneAnything "?: boolean;
597
+ };
598
+ };
599
+ type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
600
+ interface BlockerBlocked {
601
+ state: "blocked";
602
+ reset(): void;
603
+ proceed(): void;
604
+ location: Location$2;
605
+ }
606
+ interface BlockerUnblocked {
607
+ state: "unblocked";
608
+ reset: undefined;
609
+ proceed: undefined;
610
+ location: undefined;
611
+ }
612
+ interface BlockerProceeding {
613
+ state: "proceeding";
614
+ reset: undefined;
615
+ proceed: undefined;
616
+ location: Location$2;
617
+ }
618
+ type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
619
+
620
+ interface NavigateOptions$1 {
621
+ replace?: boolean;
622
+ state?: any;
623
+ preventScrollReset?: boolean;
624
+ relative?: RelativeRoutingType;
625
+ }
262
626
  /**
263
627
  * A Navigator is a "location changer"; it's how you get to different locations.
264
628
  *
@@ -268,7 +632,17 @@ interface History {
268
632
  * to avoid "tearing" that may occur in a suspense-enabled app if the action
269
633
  * and/or location were to be read directly from the history instance.
270
634
  */
271
- declare type Navigator = Omit<History, "action" | "location" | "back" | "forward" | "listen" | "block">;
635
+ interface Navigator {
636
+ createHref: History["createHref"];
637
+ encodeLocation?: History["encodeLocation"];
638
+ go: History["go"];
639
+ push(to: To, state?: any, opts?: NavigateOptions$1): void;
640
+ replace(to: To, state?: any, opts?: NavigateOptions$1): void;
641
+ }
642
+
643
+ interface FutureConfig {
644
+ v7_startTransition: boolean;
645
+ }
272
646
  interface RouterProps {
273
647
  basename?: string;
274
648
  children?: React.ReactNode;
@@ -284,23 +658,28 @@ interface RouterProps {
284
658
  * router that is more specific to your environment such as a <BrowserRouter>
285
659
  * in web browsers or a <StaticRouter> for server rendering.
286
660
  *
287
- * @see https://reactrouter.com/docs/en/v6/api#router
661
+ * @see https://reactrouter.com/router-components/router
288
662
  */
289
- declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp }: RouterProps): React.ReactElement | null;
290
- interface NavigateOptions$1 {
291
- replace?: boolean;
292
- state?: any;
293
- }
663
+ declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
294
664
 
665
+ /**
666
+ * NOTE: If you refactor this to split up the modules into separate files,
667
+ * you'll need to update the rollup config for react-router-dom-v5-compat.
668
+ */
669
+
670
+ declare global {
671
+ var __staticRouterHydrationData: HydrationState | undefined;
672
+ }
295
673
  interface BrowserRouterProps {
296
674
  basename?: string;
297
675
  children?: React.ReactNode;
676
+ future?: FutureConfig;
298
677
  window?: Window;
299
678
  }
300
679
  /**
301
- * A <Router> for use in web browsers. Provides the cleanest URLs.
680
+ * A `<Router>` for use in web browsers. Provides the cleanest URLs.
302
681
  */
303
- declare function BrowserRouter({ basename, children, window }: BrowserRouterProps): JSX.Element;
682
+ declare function BrowserRouter({ basename, children, future, window, }: BrowserRouterProps): React.JSX.Element;
304
683
 
305
684
  interface Other extends StoryData {
306
685
  path: string;