storybook 10.0.0-beta.0 → 10.0.0-beta.10
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/assets/server/openBrowser.applescript +94 -0
- package/dist/_browser-chunks/Color-KPLIACXP.js +1569 -0
- package/dist/_browser-chunks/{WithTooltip-2E62HIBN.js → WithTooltip-SK46ZJ2J.js} +1 -1
- package/dist/_browser-chunks/{chunk-YY5GICNT.js → chunk-6E2SHJSL.js} +175 -32
- package/dist/_browser-chunks/{chunk-FWKO3E35.js → chunk-BOOOPFZF.js} +10 -3
- package/dist/_browser-chunks/{chunk-YWDKX534.js → chunk-FA42P6MO.js} +49 -4
- package/dist/_browser-chunks/chunk-G33S6YM3.js +521 -0
- package/dist/_browser-chunks/{chunk-MZNYTCNT.js → chunk-HMIIJ6UD.js} +6 -6
- package/dist/_browser-chunks/{chunk-4QPX7WIQ.js → chunk-JJZMHC3A.js} +57 -166
- package/dist/_browser-chunks/{chunk-MD2FTHCZ.js → chunk-JVSKG4YS.js} +3 -16
- package/dist/_browser-chunks/{chunk-E7VLET3C.js → chunk-KSCAWCCE.js} +3947 -4291
- package/dist/_browser-chunks/{chunk-PYK5ZTFK.js → chunk-PS3AOQI4.js} +48 -25
- package/dist/_browser-chunks/chunk-QK3L5AXO.js +372 -0
- package/dist/_browser-chunks/chunk-SHR3NNR3.js +5810 -0
- package/dist/_browser-chunks/{chunk-O5R5CGFA.js → chunk-TMDZCWME.js} +1 -2
- package/dist/_browser-chunks/chunk-VUAFL5XK.js +20 -0
- package/dist/_browser-chunks/{chunk-T7RCAJIX.js → chunk-Y3M7TW6K.js} +43 -47
- package/dist/_browser-chunks/{syntaxhighlighter-YYAA4CS4.js → syntaxhighlighter-R46XOLMC.js} +1 -1
- package/dist/_node-chunks/{builder-manager-OW6YGKXV.js → builder-manager-SJGIDEN6.js} +45 -155
- package/dist/_node-chunks/camelcase-VZHWABQV.js +18 -0
- package/dist/_node-chunks/{chunk-6JSVPEAU.js → chunk-6CZW7AGN.js} +7 -7
- package/dist/_node-chunks/{chunk-CD3IP6HA.js → chunk-6XT5OLNL.js} +12 -12
- package/dist/_node-chunks/{chunk-2H7LZ2SD.js → chunk-AHRH5RPR.js} +7 -7
- package/dist/_node-chunks/{chunk-5HLANIBM.js → chunk-AOH6ABSV.js} +7 -7
- package/dist/_node-chunks/chunk-C5V22GP7.js +79 -0
- package/dist/_node-chunks/{chunk-IBXERYDG.js → chunk-FIROF4DV.js} +7 -7
- package/dist/_node-chunks/{chunk-I3YCPGZJ.js → chunk-GUJVZUYI.js} +7 -7
- package/dist/_node-chunks/chunk-IHPLRRAR.js +4741 -0
- package/dist/_node-chunks/{chunk-7TISOZS6.js → chunk-JMXKCRWR.js} +30 -21
- package/dist/_node-chunks/{chunk-YWGNEBRO.js → chunk-JUMUXWEV.js} +162 -103
- package/dist/_node-chunks/{chunk-UIREEOC7.js → chunk-KGX33KXX.js} +7 -7
- package/dist/_node-chunks/{chunk-3QB3ZG6H.js → chunk-KLVABNEU.js} +7 -7
- package/dist/_node-chunks/{chunk-H5LTFJHQ.js → chunk-OL6DY6BT.js} +631 -752
- package/dist/_node-chunks/{chunk-X5GAZ3EW.js → chunk-ONJV3K2L.js} +399 -116
- package/dist/_node-chunks/{chunk-LKB7KRSV.js → chunk-PTHTD4RO.js} +223 -243
- package/dist/_node-chunks/{chunk-UHHZPSP7.js → chunk-QQ3Z5KGJ.js} +6 -6
- package/dist/_node-chunks/{chunk-MUD3GH3L.js → chunk-QRTDDTZJ.js} +9 -9
- package/dist/_node-chunks/chunk-R54K4KSM.js +1540 -0
- package/dist/_node-chunks/{chunk-IQAUGVYR.js → chunk-S2LZC6JK.js} +8 -8
- package/dist/_node-chunks/chunk-SFJFSPRT.js +62 -0
- package/dist/_node-chunks/{chunk-LH3BEEIR.js → chunk-SSN5PKIY.js} +6 -6
- package/dist/_node-chunks/{chunk-NOQITS3C.js → chunk-SXR2DITB.js} +7 -7
- package/dist/_node-chunks/{chunk-FWUE7SRE.js → chunk-TH5QVQRL.js} +7 -7
- package/dist/_node-chunks/chunk-U34NWAU2.js +18 -0
- package/dist/_node-chunks/{chunk-FBMMEEO4.js → chunk-UV3CZ3KS.js} +7 -7
- package/dist/_node-chunks/{chunk-NZGJJABJ.js → chunk-UVUGJDAI.js} +60 -102
- package/dist/_node-chunks/{chunk-GZUNYRFU.js → chunk-VOUNSD2E.js} +7 -7
- package/dist/_node-chunks/chunk-WFCPBKQJ.js +64656 -0
- package/dist/_node-chunks/{chunk-BFXER3XW.js → chunk-XHF3WWNP.js} +623 -750
- package/dist/_node-chunks/{chunk-ANEKBWDX.js → chunk-XU45KXNQ.js} +16 -25
- package/dist/_node-chunks/{camelcase-2K3EMR6G.js → chunk-YHO6XR7U.js} +9 -8
- package/dist/_node-chunks/{dist-465RSKRC.js → dist-IIC5PBL7.js} +9 -9
- package/dist/_node-chunks/{globby-LJ3MVB6M.js → globby-CJACC3HJ.js} +17 -13
- package/dist/_node-chunks/{lib-OW3DENXB.js → lib-ZY4TKSOR.js} +40 -16
- package/dist/_node-chunks/{mdx-N42X6CFJ-PYX2IFUO.js → mdx-N42X6CFJ-3XNW3DFO.js} +8 -8
- package/dist/_node-chunks/{p-limit-X4OG45RB.js → p-limit-R2OFT5HE.js} +76 -10
- package/dist/_node-chunks/{plugin-ALTIQMDE.js → plugin-5XD5R2KD.js} +10 -10
- package/dist/_node-chunks/{plugin-GE36R32R.js → plugin-WAWVQMVR.js} +10 -12
- package/dist/_node-chunks/{webpack-inject-mocker-runtime-plugin-NLCAF7S6.js → webpack-inject-mocker-runtime-plugin-SCRGJLIS.js} +1307 -847
- package/dist/_node-chunks/{webpack-mock-plugin-BRYODMCC.js → webpack-mock-plugin-3VAXEGG2.js} +9 -11
- package/dist/babel/index.d.ts +1 -1
- package/dist/babel/index.js +11 -12
- package/dist/bin/core.js +638 -187
- package/dist/bin/dispatcher.js +11 -11
- package/dist/bin/loader.js +8 -8
- package/dist/cli/index.d.ts +62 -75
- package/dist/cli/index.js +66 -56
- package/dist/common/index.d.ts +3 -1
- package/dist/common/index.js +22 -22
- package/dist/components/index.d.ts +234 -2
- package/dist/components/index.js +74 -5741
- package/dist/core-events/index.d.ts +18 -2
- package/dist/core-events/index.js +7 -1
- package/dist/core-server/index.d.ts +540 -39
- package/dist/core-server/index.js +4647 -4182
- package/dist/core-server/presets/common-manager.js +1570 -1272
- package/dist/core-server/presets/common-override-preset.js +9 -9
- package/dist/core-server/presets/common-preset.js +691 -38
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +9 -11
- package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +10 -12
- package/dist/csf/index.d.ts +9 -4
- package/dist/csf/index.js +50 -15
- package/dist/csf-tools/index.d.ts +47 -6
- package/dist/csf-tools/index.js +9 -9
- package/dist/docs-tools/index.js +4 -4
- package/dist/instrumenter/index.js +1 -1
- package/dist/manager/globals-runtime.js +9233 -18113
- package/dist/manager/globals.d.ts +0 -4
- package/dist/manager/globals.js +1 -6
- package/dist/manager/runtime.js +13396 -11518
- package/dist/manager-api/index.d.ts +540 -32
- package/dist/manager-api/index.js +364 -90
- package/dist/manager-errors.d.ts +527 -0
- package/dist/node-logger/index.d.ts +1 -1
- package/dist/node-logger/index.js +1136 -662
- package/dist/preview/globals.js +1 -1
- package/dist/preview/runtime.js +12103 -21579
- package/dist/preview-api/index.d.ts +3 -3
- package/dist/preview-api/index.js +10 -10
- package/dist/preview-errors.d.ts +527 -0
- package/dist/router/index.d.ts +668 -10
- package/dist/router/index.js +2 -2
- package/dist/server-errors.d.ts +527 -0
- package/dist/server-errors.js +10 -10
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.js +23 -25
- package/dist/test/index.js +1874 -4024
- package/dist/theming/index.d.ts +2 -2
- package/dist/theming/index.js +6 -6
- package/dist/types/index.d.ts +553 -16
- package/dist/viewport/index.d.ts +36 -4
- package/dist/viewport/index.js +1 -1
- package/package.json +9 -46
- package/dist/_browser-chunks/Color-SFYJJKWL.js +0 -605
- package/dist/_browser-chunks/chunk-DHO2SA6L.js +0 -12
- package/dist/_browser-chunks/chunk-WPHPDNUA.js +0 -974
- package/dist/_node-chunks/chunk-27W2Z6VL.js +0 -28502
- package/dist/_node-chunks/chunk-G46DWX7Z.js +0 -266
- package/dist/_node-chunks/chunk-GZZDIJIB.js +0 -80
- package/dist/_node-chunks/chunk-JDKH3XYB.js +0 -9845
- package/dist/_node-chunks/chunk-R7RKO2DC.js +0 -35783
- package/dist/_node-chunks/chunk-T23YQHYB.js +0 -62
- package/dist/_node-chunks/chunk-VKKLKNFC.js +0 -2377
- package/dist/_node-chunks/chunk-W6GKFQ7F.js +0 -87
- package/dist/_node-chunks/chunk-YUYBO6S7.js +0 -18
- package/dist/_node-chunks/default-browser-id-Z6WQ7DZA.js +0 -1719
package/dist/router/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { ReactNode, ReactElement } from 'react';
|
|
3
3
|
|
|
4
4
|
interface StoryData {
|
|
5
5
|
viewMode?: string;
|
|
@@ -23,16 +23,674 @@ 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
|
+
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;
|
|
184
|
+
}
|
|
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
|
+
}
|
|
626
|
+
/**
|
|
627
|
+
* A Navigator is a "location changer"; it's how you get to different locations.
|
|
628
|
+
*
|
|
629
|
+
* Every history instance conforms to the Navigator interface, but the
|
|
630
|
+
* distinction is useful primarily when it comes to the low-level <Router> API
|
|
631
|
+
* where both the location and a navigator must be provided separately in order
|
|
632
|
+
* to avoid "tearing" that may occur in a suspense-enabled app if the action
|
|
633
|
+
* and/or location were to be read directly from the history instance.
|
|
634
|
+
*/
|
|
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
|
+
}
|
|
646
|
+
interface RouterProps {
|
|
647
|
+
basename?: string;
|
|
648
|
+
children?: React.ReactNode;
|
|
649
|
+
location: Partial<Location$2> | string;
|
|
650
|
+
navigationType?: Action;
|
|
651
|
+
navigator: Navigator;
|
|
652
|
+
static?: boolean;
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Provides location context for the rest of the app.
|
|
656
|
+
*
|
|
657
|
+
* Note: You usually won't render a <Router> directly. Instead, you'll render a
|
|
658
|
+
* router that is more specific to your environment such as a <BrowserRouter>
|
|
659
|
+
* in web browsers or a <StaticRouter> for server rendering.
|
|
660
|
+
*
|
|
661
|
+
* @see https://reactrouter.com/router-components/router
|
|
662
|
+
*/
|
|
663
|
+
declare function Router({ basename: basenameProp, children, location: locationProp, navigationType, navigator, static: staticProp, }: RouterProps): React.ReactElement | null;
|
|
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
|
+
}
|
|
673
|
+
interface BrowserRouterProps {
|
|
674
|
+
basename?: string;
|
|
675
|
+
children?: React.ReactNode;
|
|
676
|
+
future?: FutureConfig;
|
|
677
|
+
window?: Window;
|
|
678
|
+
}
|
|
679
|
+
/**
|
|
680
|
+
* A `<Router>` for use in web browsers. Provides the cleanest URLs.
|
|
681
|
+
*/
|
|
682
|
+
declare function BrowserRouter({ basename, children, future, window, }: BrowserRouterProps): React.JSX.Element;
|
|
683
|
+
|
|
26
684
|
interface Other extends StoryData {
|
|
27
685
|
path: string;
|
|
28
686
|
singleStory?: boolean;
|
|
29
687
|
}
|
|
30
|
-
type NavigateOptions =
|
|
688
|
+
type NavigateOptions = NavigateOptions$1 & {
|
|
31
689
|
plain?: boolean;
|
|
32
690
|
};
|
|
33
|
-
type NavigateFunction = (to:
|
|
691
|
+
type NavigateFunction = (to: To | number, options?: NavigateOptions) => void;
|
|
34
692
|
type RouterData = {
|
|
35
|
-
location: Partial<
|
|
693
|
+
location: Partial<Location$2>;
|
|
36
694
|
navigate: NavigateFunction;
|
|
37
695
|
} & Other;
|
|
38
696
|
type RenderData = Pick<RouterData, 'location'> & Other;
|
|
@@ -69,10 +727,10 @@ interface RoutePropsDefault {
|
|
|
69
727
|
startsWith?: false;
|
|
70
728
|
children: ReactNode;
|
|
71
729
|
}
|
|
72
|
-
declare const useNavigate: () => (to:
|
|
730
|
+
declare const useNavigate: () => (to: To | number, { plain, ...options }?: NavigateOptions) => void;
|
|
73
731
|
/** A component that will navigate to a new location/path when clicked */
|
|
74
732
|
declare const Link: {
|
|
75
|
-
({ to, children, ...rest }: LinkProps):
|
|
733
|
+
({ to, children, ...rest }: LinkProps): React__default.JSX.Element;
|
|
76
734
|
displayName: string;
|
|
77
735
|
};
|
|
78
736
|
/**
|
|
@@ -80,7 +738,7 @@ declare const Link: {
|
|
|
80
738
|
* changes
|
|
81
739
|
*/
|
|
82
740
|
declare const Location$1: {
|
|
83
|
-
({ children }: LocationProps):
|
|
741
|
+
({ children }: LocationProps): React__default.JSX.Element;
|
|
84
742
|
displayName: string;
|
|
85
743
|
};
|
|
86
744
|
/**
|
|
@@ -100,7 +758,7 @@ declare namespace Route {
|
|
|
100
758
|
var displayName: string;
|
|
101
759
|
}
|
|
102
760
|
|
|
103
|
-
declare const LocationProvider: typeof
|
|
104
|
-
declare const BaseLocationProvider: typeof
|
|
761
|
+
declare const LocationProvider: typeof BrowserRouter;
|
|
762
|
+
declare const BaseLocationProvider: typeof Router;
|
|
105
763
|
|
|
106
764
|
export { BaseLocationProvider, DEEPLY_EQUAL, Link, type LinkProps, Location$1 as Location, LocationProvider, Match, type NavigateFunction, type NavigateOptions, type Other, type RenderData, Route, type RouterData, type StoryData, buildArgsParam, deepDiff, getMatch, parsePath, queryFromLocation, stringifyQuery, useNavigate };
|