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.
Files changed (126) hide show
  1. package/assets/server/openBrowser.applescript +94 -0
  2. package/dist/_browser-chunks/Color-KPLIACXP.js +1569 -0
  3. package/dist/_browser-chunks/{WithTooltip-2E62HIBN.js → WithTooltip-SK46ZJ2J.js} +1 -1
  4. package/dist/_browser-chunks/{chunk-YY5GICNT.js → chunk-6E2SHJSL.js} +175 -32
  5. package/dist/_browser-chunks/{chunk-FWKO3E35.js → chunk-BOOOPFZF.js} +10 -3
  6. package/dist/_browser-chunks/{chunk-YWDKX534.js → chunk-FA42P6MO.js} +49 -4
  7. package/dist/_browser-chunks/chunk-G33S6YM3.js +521 -0
  8. package/dist/_browser-chunks/{chunk-MZNYTCNT.js → chunk-HMIIJ6UD.js} +6 -6
  9. package/dist/_browser-chunks/{chunk-4QPX7WIQ.js → chunk-JJZMHC3A.js} +57 -166
  10. package/dist/_browser-chunks/{chunk-MD2FTHCZ.js → chunk-JVSKG4YS.js} +3 -16
  11. package/dist/_browser-chunks/{chunk-E7VLET3C.js → chunk-KSCAWCCE.js} +3947 -4291
  12. package/dist/_browser-chunks/{chunk-PYK5ZTFK.js → chunk-PS3AOQI4.js} +48 -25
  13. package/dist/_browser-chunks/chunk-QK3L5AXO.js +372 -0
  14. package/dist/_browser-chunks/chunk-SHR3NNR3.js +5810 -0
  15. package/dist/_browser-chunks/{chunk-O5R5CGFA.js → chunk-TMDZCWME.js} +1 -2
  16. package/dist/_browser-chunks/chunk-VUAFL5XK.js +20 -0
  17. package/dist/_browser-chunks/{chunk-T7RCAJIX.js → chunk-Y3M7TW6K.js} +43 -47
  18. package/dist/_browser-chunks/{syntaxhighlighter-YYAA4CS4.js → syntaxhighlighter-R46XOLMC.js} +1 -1
  19. package/dist/_node-chunks/{builder-manager-OW6YGKXV.js → builder-manager-SJGIDEN6.js} +45 -155
  20. package/dist/_node-chunks/camelcase-VZHWABQV.js +18 -0
  21. package/dist/_node-chunks/{chunk-6JSVPEAU.js → chunk-6CZW7AGN.js} +7 -7
  22. package/dist/_node-chunks/{chunk-CD3IP6HA.js → chunk-6XT5OLNL.js} +12 -12
  23. package/dist/_node-chunks/{chunk-2H7LZ2SD.js → chunk-AHRH5RPR.js} +7 -7
  24. package/dist/_node-chunks/{chunk-5HLANIBM.js → chunk-AOH6ABSV.js} +7 -7
  25. package/dist/_node-chunks/chunk-C5V22GP7.js +79 -0
  26. package/dist/_node-chunks/{chunk-IBXERYDG.js → chunk-FIROF4DV.js} +7 -7
  27. package/dist/_node-chunks/{chunk-I3YCPGZJ.js → chunk-GUJVZUYI.js} +7 -7
  28. package/dist/_node-chunks/chunk-IHPLRRAR.js +4741 -0
  29. package/dist/_node-chunks/{chunk-7TISOZS6.js → chunk-JMXKCRWR.js} +30 -21
  30. package/dist/_node-chunks/{chunk-YWGNEBRO.js → chunk-JUMUXWEV.js} +162 -103
  31. package/dist/_node-chunks/{chunk-UIREEOC7.js → chunk-KGX33KXX.js} +7 -7
  32. package/dist/_node-chunks/{chunk-3QB3ZG6H.js → chunk-KLVABNEU.js} +7 -7
  33. package/dist/_node-chunks/{chunk-H5LTFJHQ.js → chunk-OL6DY6BT.js} +631 -752
  34. package/dist/_node-chunks/{chunk-X5GAZ3EW.js → chunk-ONJV3K2L.js} +399 -116
  35. package/dist/_node-chunks/{chunk-LKB7KRSV.js → chunk-PTHTD4RO.js} +223 -243
  36. package/dist/_node-chunks/{chunk-UHHZPSP7.js → chunk-QQ3Z5KGJ.js} +6 -6
  37. package/dist/_node-chunks/{chunk-MUD3GH3L.js → chunk-QRTDDTZJ.js} +9 -9
  38. package/dist/_node-chunks/chunk-R54K4KSM.js +1540 -0
  39. package/dist/_node-chunks/{chunk-IQAUGVYR.js → chunk-S2LZC6JK.js} +8 -8
  40. package/dist/_node-chunks/chunk-SFJFSPRT.js +62 -0
  41. package/dist/_node-chunks/{chunk-LH3BEEIR.js → chunk-SSN5PKIY.js} +6 -6
  42. package/dist/_node-chunks/{chunk-NOQITS3C.js → chunk-SXR2DITB.js} +7 -7
  43. package/dist/_node-chunks/{chunk-FWUE7SRE.js → chunk-TH5QVQRL.js} +7 -7
  44. package/dist/_node-chunks/chunk-U34NWAU2.js +18 -0
  45. package/dist/_node-chunks/{chunk-FBMMEEO4.js → chunk-UV3CZ3KS.js} +7 -7
  46. package/dist/_node-chunks/{chunk-NZGJJABJ.js → chunk-UVUGJDAI.js} +60 -102
  47. package/dist/_node-chunks/{chunk-GZUNYRFU.js → chunk-VOUNSD2E.js} +7 -7
  48. package/dist/_node-chunks/chunk-WFCPBKQJ.js +64656 -0
  49. package/dist/_node-chunks/{chunk-BFXER3XW.js → chunk-XHF3WWNP.js} +623 -750
  50. package/dist/_node-chunks/{chunk-ANEKBWDX.js → chunk-XU45KXNQ.js} +16 -25
  51. package/dist/_node-chunks/{camelcase-2K3EMR6G.js → chunk-YHO6XR7U.js} +9 -8
  52. package/dist/_node-chunks/{dist-465RSKRC.js → dist-IIC5PBL7.js} +9 -9
  53. package/dist/_node-chunks/{globby-LJ3MVB6M.js → globby-CJACC3HJ.js} +17 -13
  54. package/dist/_node-chunks/{lib-OW3DENXB.js → lib-ZY4TKSOR.js} +40 -16
  55. package/dist/_node-chunks/{mdx-N42X6CFJ-PYX2IFUO.js → mdx-N42X6CFJ-3XNW3DFO.js} +8 -8
  56. package/dist/_node-chunks/{p-limit-X4OG45RB.js → p-limit-R2OFT5HE.js} +76 -10
  57. package/dist/_node-chunks/{plugin-ALTIQMDE.js → plugin-5XD5R2KD.js} +10 -10
  58. package/dist/_node-chunks/{plugin-GE36R32R.js → plugin-WAWVQMVR.js} +10 -12
  59. package/dist/_node-chunks/{webpack-inject-mocker-runtime-plugin-NLCAF7S6.js → webpack-inject-mocker-runtime-plugin-SCRGJLIS.js} +1307 -847
  60. package/dist/_node-chunks/{webpack-mock-plugin-BRYODMCC.js → webpack-mock-plugin-3VAXEGG2.js} +9 -11
  61. package/dist/babel/index.d.ts +1 -1
  62. package/dist/babel/index.js +11 -12
  63. package/dist/bin/core.js +638 -187
  64. package/dist/bin/dispatcher.js +11 -11
  65. package/dist/bin/loader.js +8 -8
  66. package/dist/cli/index.d.ts +62 -75
  67. package/dist/cli/index.js +66 -56
  68. package/dist/common/index.d.ts +3 -1
  69. package/dist/common/index.js +22 -22
  70. package/dist/components/index.d.ts +234 -2
  71. package/dist/components/index.js +74 -5741
  72. package/dist/core-events/index.d.ts +18 -2
  73. package/dist/core-events/index.js +7 -1
  74. package/dist/core-server/index.d.ts +540 -39
  75. package/dist/core-server/index.js +4647 -4182
  76. package/dist/core-server/presets/common-manager.js +1570 -1272
  77. package/dist/core-server/presets/common-override-preset.js +9 -9
  78. package/dist/core-server/presets/common-preset.js +691 -38
  79. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +9 -11
  80. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +10 -12
  81. package/dist/csf/index.d.ts +9 -4
  82. package/dist/csf/index.js +50 -15
  83. package/dist/csf-tools/index.d.ts +47 -6
  84. package/dist/csf-tools/index.js +9 -9
  85. package/dist/docs-tools/index.js +4 -4
  86. package/dist/instrumenter/index.js +1 -1
  87. package/dist/manager/globals-runtime.js +9233 -18113
  88. package/dist/manager/globals.d.ts +0 -4
  89. package/dist/manager/globals.js +1 -6
  90. package/dist/manager/runtime.js +13396 -11518
  91. package/dist/manager-api/index.d.ts +540 -32
  92. package/dist/manager-api/index.js +364 -90
  93. package/dist/manager-errors.d.ts +527 -0
  94. package/dist/node-logger/index.d.ts +1 -1
  95. package/dist/node-logger/index.js +1136 -662
  96. package/dist/preview/globals.js +1 -1
  97. package/dist/preview/runtime.js +12103 -21579
  98. package/dist/preview-api/index.d.ts +3 -3
  99. package/dist/preview-api/index.js +10 -10
  100. package/dist/preview-errors.d.ts +527 -0
  101. package/dist/router/index.d.ts +668 -10
  102. package/dist/router/index.js +2 -2
  103. package/dist/server-errors.d.ts +527 -0
  104. package/dist/server-errors.js +10 -10
  105. package/dist/telemetry/index.d.ts +1 -1
  106. package/dist/telemetry/index.js +23 -25
  107. package/dist/test/index.js +1874 -4024
  108. package/dist/theming/index.d.ts +2 -2
  109. package/dist/theming/index.js +6 -6
  110. package/dist/types/index.d.ts +553 -16
  111. package/dist/viewport/index.d.ts +36 -4
  112. package/dist/viewport/index.js +1 -1
  113. package/package.json +9 -46
  114. package/dist/_browser-chunks/Color-SFYJJKWL.js +0 -605
  115. package/dist/_browser-chunks/chunk-DHO2SA6L.js +0 -12
  116. package/dist/_browser-chunks/chunk-WPHPDNUA.js +0 -974
  117. package/dist/_node-chunks/chunk-27W2Z6VL.js +0 -28502
  118. package/dist/_node-chunks/chunk-G46DWX7Z.js +0 -266
  119. package/dist/_node-chunks/chunk-GZZDIJIB.js +0 -80
  120. package/dist/_node-chunks/chunk-JDKH3XYB.js +0 -9845
  121. package/dist/_node-chunks/chunk-R7RKO2DC.js +0 -35783
  122. package/dist/_node-chunks/chunk-T23YQHYB.js +0 -62
  123. package/dist/_node-chunks/chunk-VKKLKNFC.js +0 -2377
  124. package/dist/_node-chunks/chunk-W6GKFQ7F.js +0 -87
  125. package/dist/_node-chunks/chunk-YUYBO6S7.js +0 -18
  126. package/dist/_node-chunks/default-browser-id-Z6WQ7DZA.js +0 -1719
@@ -2,7 +2,7 @@ import React, { FC, ReactNode, ReactElement, Component } from 'react';
2
2
  import { Channel, Listener as Listener$1 } from 'storybook/internal/channels';
3
3
  export { Listener as ChannelListener } from 'storybook/internal/channels';
4
4
  import { RouterData, NavigateOptions } from 'storybook/internal/router';
5
- import { Addon_Types, Addon_TypesEnum, Addon_Collection, Addon_TypesMapping, Addon_BaseType, Addon_TestProviderType, Addon_PageType, Addon_WrapperType, Addon_Config, API_ProviderData, API_StateMerger, API_Provider, Globals, GlobalTypes, API_PanelPositions, API_Layout, API_LayoutCustomisations, API_UI, API_Notification, API_IframeRenderer, API_ComposedRef, API_SetRefData, API_ComposedRefUpdate, API_Refs, StoryId, API_Settings, API_HashEntry, API_ViewMode, API_LeafEntry, API_PreparedStoryIndex, API_StoryEntry, Args, API_IndexHash, API_DocsEntry, API_FilterFunction, API_LoadedRefData, API_Version, API_Versions, API_UnknownEntries, API_OptionsData, Parameters, ArgTypes, NormalizedProjectAnnotations, ProjectAnnotations, ComposedStoryFn } from 'storybook/internal/types';
5
+ import { Addon_Types, Addon_TypesEnum, Addon_Collection, Addon_TypesMapping, Addon_BaseType, Addon_TestProviderType, Addon_PageType, Addon_WrapperType, Addon_Config, API_ProviderData, API_StateMerger, API_Provider, Globals, GlobalTypes, API_PanelPositions, API_Layout, API_LayoutCustomisations, API_UI, API_Notification, API_IframeRenderer, API_ComposedRef, API_SetRefData, API_ComposedRefUpdate, API_Refs, StoryId, API_Settings, API_HashEntry, API_ViewMode, API_LeafEntry, API_PreparedStoryIndex, API_StoryEntry, API_TestEntry, Args, API_IndexHash, API_DocsEntry, API_FilterFunction, API_LoadedRefData, API_Version, API_Versions, API_UnknownEntries, API_OptionsData, Parameters, ArgTypes, NormalizedProjectAnnotations, ProjectAnnotations, ComposedStoryFn } from 'storybook/internal/types';
6
6
  export { Addon_Type as Addon, API_ComponentEntry as ComponentEntry, API_ComposedRef as ComposedRef, API_DocsEntry as DocsEntry, API_GroupEntry as GroupEntry, API_HashEntry as HashEntry, API_IndexHash as IndexHash, API_LeafEntry as LeafEntry, API_Refs as Refs, API_RootEntry as RootEntry, API_IndexHash as StoriesHash, API_StoryEntry as StoryEntry } from 'storybook/internal/types';
7
7
  import { ThemeVars } from 'storybook/theming';
8
8
  import { toId, StoryId as StoryId$1 } from 'storybook/internal/csf';
@@ -271,6 +271,11 @@ interface SubAPI$9 {
271
271
  * account customisations requested by the end user via a layoutCustomisations function.
272
272
  */
273
273
  getShowToolbarWithCustomisations: (showToolbar: boolean) => boolean;
274
+ /**
275
+ * GetShowPanelWithCustomisations - Returns the current visibility of the addon panel, taking into
276
+ * account customisations requested by the end user via a layoutCustomisations function.
277
+ */
278
+ getShowPanelWithCustomisations: (showPanel: boolean) => boolean;
274
279
  /**
275
280
  * GetNavSizeWithCustomisations - Returns the size to apply to the sidebar/nav, taking into
276
281
  * account customisations requested by the end user via a layoutCustomisations function.
@@ -388,7 +393,7 @@ interface SubState$5 {
388
393
 
389
394
  declare const isMacLike: () => boolean;
390
395
  declare const controlOrMetaSymbol: () => "⌘" | "ctrl";
391
- declare const controlOrMetaKey: () => "meta" | "control";
396
+ declare const controlOrMetaKey: () => "control" | "meta";
392
397
  declare const optionOrAltSymbol: () => "⌥" | "alt";
393
398
  declare const isShortcutTaken: (arr1: string[], arr2: string[]) => boolean;
394
399
  type KeyboardEventLike = Pick<KeyboardEvent, 'altKey' | 'ctrlKey' | 'metaKey' | 'shiftKey' | 'key' | 'code' | 'keyCode' | 'preventDefault'>;
@@ -483,6 +488,8 @@ interface API_Shortcuts {
483
488
  collapseAll: API_KeyCollection;
484
489
  expandAll: API_KeyCollection;
485
490
  remount: API_KeyCollection;
491
+ openInEditor: API_KeyCollection;
492
+ copyStoryLink: API_KeyCollection;
486
493
  }
487
494
  type API_Action = keyof API_Shortcuts;
488
495
  interface API_AddonShortcut {
@@ -617,20 +624,20 @@ interface SubAPI$3 {
617
624
  /**
618
625
  * Updates the arguments for the given story with the provided new arguments.
619
626
  *
620
- * @param {API_StoryEntry} story - The story to update the arguments for.
627
+ * @param {API_StoryEntry | API_TestEntry} story - The story to update the arguments for.
621
628
  * @param {Args} newArgs - The new arguments to set for the story.
622
629
  * @returns {void}
623
630
  */
624
- updateStoryArgs(story: API_StoryEntry, newArgs: Args): void;
631
+ updateStoryArgs(story: API_StoryEntry | API_TestEntry, newArgs: Args): void;
625
632
  /**
626
633
  * Resets the arguments for the given story to their initial values.
627
634
  *
628
- * @param {API_StoryEntry} story - The story to reset the arguments for.
635
+ * @param {API_StoryEntry | API_TestEntry} story - The story to reset the arguments for.
629
636
  * @param {string[]} [argNames] - An optional array of argument names to reset. If not provided,
630
637
  * all arguments will be reset.
631
638
  * @returns {void}
632
639
  */
633
- resetStoryArgs: (story: API_StoryEntry, argNames?: string[]) => void;
640
+ resetStoryArgs: (story: API_StoryEntry | API_TestEntry, argNames?: string[]) => void;
634
641
  /**
635
642
  * Finds the leaf entry for the given story ID in the given story index.
636
643
  *
@@ -1190,37 +1197,506 @@ declare class MockUniversalStore<State, CustomEvent extends {
1190
1197
  unsubscribeAll(): void;
1191
1198
  }
1192
1199
 
1193
- type StatusValue = 'status-value:pending' | 'status-value:success' | 'status-value:error' | 'status-value:warning' | 'status-value:unknown';
1194
- type StatusTypeId = string;
1195
- type StatusByTypeId = Record<StatusTypeId, Status>;
1196
- type StatusesByStoryIdAndTypeId = Record<StoryId$1, StatusByTypeId>;
1197
- interface Status {
1198
- value: StatusValue;
1199
- typeId: StatusTypeId;
1200
- storyId: StoryId$1;
1201
- title: string;
1202
- description: string;
1203
- data?: any;
1204
- sidebarContextMenu?: boolean;
1200
+ /**
1201
+ * Actions represent the type of change to a location value.
1202
+ */
1203
+ declare enum Action {
1204
+ /**
1205
+ * A POP indicates a change to an arbitrary index in the history stack, such
1206
+ * as a back or forward navigation. It does not describe the direction of the
1207
+ * navigation, only that the current index changed.
1208
+ *
1209
+ * Note: This is the default action for newly created history objects.
1210
+ */
1211
+ Pop = "POP",
1212
+ /**
1213
+ * A PUSH indicates a new entry being added to the history stack, such as when
1214
+ * a link is clicked and a new page loads. When this happens, all subsequent
1215
+ * entries in the stack are lost.
1216
+ */
1217
+ Push = "PUSH",
1218
+ /**
1219
+ * A REPLACE indicates the entry at the current index in the history stack
1220
+ * being replaced by a new one.
1221
+ */
1222
+ Replace = "REPLACE"
1205
1223
  }
1206
- declare const StatusStoreEventType: {
1207
- readonly SELECT: "select";
1224
+ /**
1225
+ * The pathname, search, and hash values of a URL.
1226
+ */
1227
+ interface Path {
1228
+ /**
1229
+ * A URL pathname, beginning with a /.
1230
+ */
1231
+ pathname: string;
1232
+ /**
1233
+ * A URL search string, beginning with a ?.
1234
+ */
1235
+ search: string;
1236
+ /**
1237
+ * A URL fragment identifier, beginning with a #.
1238
+ */
1239
+ hash: string;
1240
+ }
1241
+ /**
1242
+ * An entry in a history stack. A location contains information about the
1243
+ * URL path, as well as possibly some arbitrary state and a key.
1244
+ */
1245
+ interface Location extends Path {
1246
+ /**
1247
+ * A value of arbitrary data associated with this location.
1248
+ */
1249
+ state: any;
1250
+ /**
1251
+ * A unique string associated with this location. May be used to safely store
1252
+ * and retrieve data in some other storage API, like `localStorage`.
1253
+ *
1254
+ * Note: This value is always "default" on the initial location.
1255
+ */
1256
+ key: string;
1257
+ }
1258
+
1259
+ /**
1260
+ * Map of routeId -> data returned from a loader/action/error
1261
+ */
1262
+ interface RouteData {
1263
+ [routeId: string]: any;
1264
+ }
1265
+ declare enum ResultType {
1266
+ data = "data",
1267
+ deferred = "deferred",
1268
+ redirect = "redirect",
1269
+ error = "error"
1270
+ }
1271
+ /**
1272
+ * Successful result from a loader or action
1273
+ */
1274
+ interface SuccessResult {
1275
+ type: ResultType.data;
1276
+ data: any;
1277
+ statusCode?: number;
1278
+ headers?: Headers;
1279
+ }
1280
+ /**
1281
+ * Successful defer() result from a loader or action
1282
+ */
1283
+ interface DeferredResult {
1284
+ type: ResultType.deferred;
1285
+ deferredData: DeferredData;
1286
+ statusCode?: number;
1287
+ headers?: Headers;
1288
+ }
1289
+ /**
1290
+ * Redirect result from a loader or action
1291
+ */
1292
+ interface RedirectResult {
1293
+ type: ResultType.redirect;
1294
+ status: number;
1295
+ location: string;
1296
+ revalidate: boolean;
1297
+ reloadDocument?: boolean;
1298
+ }
1299
+ /**
1300
+ * Unsuccessful result from a loader or action
1301
+ */
1302
+ interface ErrorResult {
1303
+ type: ResultType.error;
1304
+ error: any;
1305
+ headers?: Headers;
1306
+ }
1307
+ /**
1308
+ * Result from a loader or action - potentially successful or unsuccessful
1309
+ */
1310
+ type DataResult = SuccessResult | DeferredResult | RedirectResult | ErrorResult;
1311
+ type LowerCaseFormMethod = "get" | "post" | "put" | "patch" | "delete";
1312
+ type UpperCaseFormMethod = Uppercase<LowerCaseFormMethod>;
1313
+ /**
1314
+ * Active navigation/fetcher form methods are exposed in lowercase on the
1315
+ * RouterState
1316
+ */
1317
+ type FormMethod = LowerCaseFormMethod;
1318
+ /**
1319
+ * In v7, active navigation/fetcher form methods are exposed in uppercase on the
1320
+ * RouterState. This is to align with the normalization done via fetch().
1321
+ */
1322
+ type V7_FormMethod = UpperCaseFormMethod;
1323
+ type FormEncType = "application/x-www-form-urlencoded" | "multipart/form-data" | "application/json" | "text/plain";
1324
+ type JsonObject = {
1325
+ [Key in string]: JsonValue;
1326
+ } & {
1327
+ [Key in string]?: JsonValue | undefined;
1208
1328
  };
1209
- type StatusStoreEvent = {
1210
- type: typeof StatusStoreEventType.SELECT;
1211
- payload: Status[];
1329
+ type JsonArray = JsonValue[] | readonly JsonValue[];
1330
+ type JsonPrimitive = string | number | boolean | null;
1331
+ type JsonValue = JsonPrimitive | JsonObject | JsonArray;
1332
+ /**
1333
+ * @private
1334
+ * Internal interface to pass around for action submissions, not intended for
1335
+ * external consumption
1336
+ */
1337
+ type Submission = {
1338
+ formMethod: FormMethod | V7_FormMethod;
1339
+ formAction: string;
1340
+ formEncType: FormEncType;
1341
+ formData: FormData;
1342
+ json: undefined;
1343
+ text: undefined;
1344
+ } | {
1345
+ formMethod: FormMethod | V7_FormMethod;
1346
+ formAction: string;
1347
+ formEncType: FormEncType;
1348
+ formData: undefined;
1349
+ json: JsonValue;
1350
+ text: undefined;
1351
+ } | {
1352
+ formMethod: FormMethod | V7_FormMethod;
1353
+ formAction: string;
1354
+ formEncType: FormEncType;
1355
+ formData: undefined;
1356
+ json: undefined;
1357
+ text: string;
1212
1358
  };
1213
- type StatusStore = {
1214
- getAll: () => StatusesByStoryIdAndTypeId;
1215
- set: (statuses: Status[]) => void;
1216
- onAllStatusChange: (listener: (statuses: StatusesByStoryIdAndTypeId, previousStatuses: StatusesByStoryIdAndTypeId) => void) => () => void;
1217
- onSelect: (listener: (selectedStatuses: Status[]) => void) => () => void;
1218
- unset: (storyIds?: StoryId$1[]) => void;
1359
+ /**
1360
+ * @private
1361
+ * Arguments passed to route loader/action functions. Same for now but we keep
1362
+ * this as a private implementation detail in case they diverge in the future.
1363
+ */
1364
+ interface DataFunctionArgs {
1365
+ request: Request;
1366
+ params: Params;
1367
+ context?: any;
1368
+ }
1369
+ /**
1370
+ * Arguments passed to loader functions
1371
+ */
1372
+ interface LoaderFunctionArgs extends DataFunctionArgs {
1373
+ }
1374
+ /**
1375
+ * Arguments passed to action functions
1376
+ */
1377
+ interface ActionFunctionArgs extends DataFunctionArgs {
1378
+ }
1379
+ /**
1380
+ * Loaders and actions can return anything except `undefined` (`null` is a
1381
+ * valid return value if there is no data to return). Responses are preferred
1382
+ * and will ease any future migration to Remix
1383
+ */
1384
+ type DataFunctionValue = Response | NonNullable<unknown> | null;
1385
+ /**
1386
+ * Route loader function signature
1387
+ */
1388
+ interface LoaderFunction {
1389
+ (args: LoaderFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
1390
+ }
1391
+ /**
1392
+ * Route action function signature
1393
+ */
1394
+ interface ActionFunction {
1395
+ (args: ActionFunctionArgs): Promise<DataFunctionValue> | DataFunctionValue;
1396
+ }
1397
+ /**
1398
+ * Route shouldRevalidate function signature. This runs after any submission
1399
+ * (navigation or fetcher), so we flatten the navigation/fetcher submission
1400
+ * onto the arguments. It shouldn't matter whether it came from a navigation
1401
+ * or a fetcher, what really matters is the URLs and the formData since loaders
1402
+ * have to re-run based on the data models that were potentially mutated.
1403
+ */
1404
+ interface ShouldRevalidateFunction {
1405
+ (args: {
1406
+ currentUrl: URL;
1407
+ currentParams: AgnosticDataRouteMatch["params"];
1408
+ nextUrl: URL;
1409
+ nextParams: AgnosticDataRouteMatch["params"];
1410
+ formMethod?: Submission["formMethod"];
1411
+ formAction?: Submission["formAction"];
1412
+ formEncType?: Submission["formEncType"];
1413
+ text?: Submission["text"];
1414
+ formData?: Submission["formData"];
1415
+ json?: Submission["json"];
1416
+ actionResult?: DataResult;
1417
+ defaultShouldRevalidate: boolean;
1418
+ }): boolean;
1419
+ }
1420
+ /**
1421
+ * Keys we cannot change from within a lazy() function. We spread all other keys
1422
+ * onto the route. Either they're meaningful to the router, or they'll get
1423
+ * ignored.
1424
+ */
1425
+ type ImmutableRouteKey = "lazy" | "caseSensitive" | "path" | "id" | "index" | "children";
1426
+ type RequireOne<T, Key = keyof T> = Exclude<{
1427
+ [K in keyof T]: K extends Key ? Omit<T, K> & Required<Pick<T, K>> : never;
1428
+ }[keyof T], undefined>;
1429
+ /**
1430
+ * lazy() function to load a route definition, which can add non-matching
1431
+ * related properties to a route
1432
+ */
1433
+ interface LazyRouteFunction<R extends AgnosticRouteObject> {
1434
+ (): Promise<RequireOne<Omit<R, ImmutableRouteKey>>>;
1435
+ }
1436
+ /**
1437
+ * Base RouteObject with common props shared by all types of routes
1438
+ */
1439
+ type AgnosticBaseRouteObject = {
1440
+ caseSensitive?: boolean;
1441
+ path?: string;
1442
+ id?: string;
1443
+ loader?: LoaderFunction;
1444
+ action?: ActionFunction;
1445
+ hasErrorBoundary?: boolean;
1446
+ shouldRevalidate?: ShouldRevalidateFunction;
1447
+ handle?: any;
1448
+ lazy?: LazyRouteFunction<AgnosticBaseRouteObject>;
1219
1449
  };
1220
- type StatusStoreByTypeId = StatusStore & {
1221
- typeId: StatusTypeId;
1450
+ /**
1451
+ * Index routes must not have children
1452
+ */
1453
+ type AgnosticIndexRouteObject = AgnosticBaseRouteObject & {
1454
+ children?: undefined;
1455
+ index: true;
1222
1456
  };
1223
- type UseStatusStore = <T = StatusesByStoryIdAndTypeId>(selector?: (statuses: StatusesByStoryIdAndTypeId) => T) => T;
1457
+ /**
1458
+ * Non-index routes may have children, but cannot have index
1459
+ */
1460
+ type AgnosticNonIndexRouteObject = AgnosticBaseRouteObject & {
1461
+ children?: AgnosticRouteObject[];
1462
+ index?: false;
1463
+ };
1464
+ /**
1465
+ * A route object represents a logical route, with (optionally) its child
1466
+ * routes organized in a tree-like structure.
1467
+ */
1468
+ type AgnosticRouteObject = AgnosticIndexRouteObject | AgnosticNonIndexRouteObject;
1469
+ type AgnosticDataIndexRouteObject = AgnosticIndexRouteObject & {
1470
+ id: string;
1471
+ };
1472
+ type AgnosticDataNonIndexRouteObject = AgnosticNonIndexRouteObject & {
1473
+ children?: AgnosticDataRouteObject[];
1474
+ id: string;
1475
+ };
1476
+ /**
1477
+ * A data route object, which is just a RouteObject with a required unique ID
1478
+ */
1479
+ type AgnosticDataRouteObject = AgnosticDataIndexRouteObject | AgnosticDataNonIndexRouteObject;
1480
+ /**
1481
+ * The parameters that were parsed from the URL path.
1482
+ */
1483
+ type Params<Key extends string = string> = {
1484
+ readonly [key in Key]: string | undefined;
1485
+ };
1486
+ /**
1487
+ * A RouteMatch contains info about how a route matched a URL.
1488
+ */
1489
+ interface AgnosticRouteMatch<ParamKey extends string = string, RouteObjectType extends AgnosticRouteObject = AgnosticRouteObject> {
1490
+ /**
1491
+ * The names and values of dynamic parameters in the URL.
1492
+ */
1493
+ params: Params<ParamKey>;
1494
+ /**
1495
+ * The portion of the URL pathname that was matched.
1496
+ */
1497
+ pathname: string;
1498
+ /**
1499
+ * The portion of the URL pathname that was matched before child routes.
1500
+ */
1501
+ pathnameBase: string;
1502
+ /**
1503
+ * The route object that was used to match.
1504
+ */
1505
+ route: RouteObjectType;
1506
+ }
1507
+ interface AgnosticDataRouteMatch extends AgnosticRouteMatch<string, AgnosticDataRouteObject> {
1508
+ }
1509
+ declare class DeferredData {
1510
+ private pendingKeysSet;
1511
+ private controller;
1512
+ private abortPromise;
1513
+ private unlistenAbortSignal;
1514
+ private subscribers;
1515
+ data: Record<string, unknown>;
1516
+ init?: ResponseInit;
1517
+ deferredKeys: string[];
1518
+ constructor(data: Record<string, unknown>, responseInit?: ResponseInit);
1519
+ private trackPromise;
1520
+ private onSettle;
1521
+ private emit;
1522
+ subscribe(fn: (aborted: boolean, settledKey?: string) => void): () => boolean;
1523
+ cancel(): void;
1524
+ resolveData(signal: AbortSignal): Promise<boolean>;
1525
+ get done(): boolean;
1526
+ get unwrappedData(): {};
1527
+ get pendingKeys(): string[];
1528
+ }
1529
+
1530
+ /**
1531
+ * State maintained internally by the router. During a navigation, all states
1532
+ * reflect the the "old" location unless otherwise noted.
1533
+ */
1534
+ interface RouterState {
1535
+ /**
1536
+ * The action of the most recent navigation
1537
+ */
1538
+ historyAction: Action;
1539
+ /**
1540
+ * The current location reflected by the router
1541
+ */
1542
+ location: Location;
1543
+ /**
1544
+ * The current set of route matches
1545
+ */
1546
+ matches: AgnosticDataRouteMatch[];
1547
+ /**
1548
+ * Tracks whether we've completed our initial data load
1549
+ */
1550
+ initialized: boolean;
1551
+ /**
1552
+ * Current scroll position we should start at for a new view
1553
+ * - number -> scroll position to restore to
1554
+ * - false -> do not restore scroll at all (used during submissions)
1555
+ * - null -> don't have a saved position, scroll to hash or top of page
1556
+ */
1557
+ restoreScrollPosition: number | false | null;
1558
+ /**
1559
+ * Indicate whether this navigation should skip resetting the scroll position
1560
+ * if we are unable to restore the scroll position
1561
+ */
1562
+ preventScrollReset: boolean;
1563
+ /**
1564
+ * Tracks the state of the current navigation
1565
+ */
1566
+ navigation: Navigation;
1567
+ /**
1568
+ * Tracks any in-progress revalidations
1569
+ */
1570
+ revalidation: RevalidationState;
1571
+ /**
1572
+ * Data from the loaders for the current matches
1573
+ */
1574
+ loaderData: RouteData;
1575
+ /**
1576
+ * Data from the action for the current matches
1577
+ */
1578
+ actionData: RouteData | null;
1579
+ /**
1580
+ * Errors caught from loaders for the current matches
1581
+ */
1582
+ errors: RouteData | null;
1583
+ /**
1584
+ * Map of current fetchers
1585
+ */
1586
+ fetchers: Map<string, Fetcher>;
1587
+ /**
1588
+ * Map of current blockers
1589
+ */
1590
+ blockers: Map<string, Blocker>;
1591
+ }
1592
+ /**
1593
+ * Data that can be passed into hydrate a Router from SSR
1594
+ */
1595
+ type HydrationState = Partial<Pick<RouterState, "loaderData" | "actionData" | "errors">>;
1596
+ /**
1597
+ * Potential states for state.navigation
1598
+ */
1599
+ type NavigationStates = {
1600
+ Idle: {
1601
+ state: "idle";
1602
+ location: undefined;
1603
+ formMethod: undefined;
1604
+ formAction: undefined;
1605
+ formEncType: undefined;
1606
+ formData: undefined;
1607
+ json: undefined;
1608
+ text: undefined;
1609
+ };
1610
+ Loading: {
1611
+ state: "loading";
1612
+ location: Location;
1613
+ formMethod: Submission["formMethod"] | undefined;
1614
+ formAction: Submission["formAction"] | undefined;
1615
+ formEncType: Submission["formEncType"] | undefined;
1616
+ formData: Submission["formData"] | undefined;
1617
+ json: Submission["json"] | undefined;
1618
+ text: Submission["text"] | undefined;
1619
+ };
1620
+ Submitting: {
1621
+ state: "submitting";
1622
+ location: Location;
1623
+ formMethod: Submission["formMethod"];
1624
+ formAction: Submission["formAction"];
1625
+ formEncType: Submission["formEncType"];
1626
+ formData: Submission["formData"];
1627
+ json: Submission["json"];
1628
+ text: Submission["text"];
1629
+ };
1630
+ };
1631
+ type Navigation = NavigationStates[keyof NavigationStates];
1632
+ type RevalidationState = "idle" | "loading";
1633
+ /**
1634
+ * Potential states for fetchers
1635
+ */
1636
+ type FetcherStates<TData = any> = {
1637
+ Idle: {
1638
+ state: "idle";
1639
+ formMethod: undefined;
1640
+ formAction: undefined;
1641
+ formEncType: undefined;
1642
+ text: undefined;
1643
+ formData: undefined;
1644
+ json: undefined;
1645
+ data: TData | undefined;
1646
+ " _hasFetcherDoneAnything "?: boolean;
1647
+ };
1648
+ Loading: {
1649
+ state: "loading";
1650
+ formMethod: Submission["formMethod"] | undefined;
1651
+ formAction: Submission["formAction"] | undefined;
1652
+ formEncType: Submission["formEncType"] | undefined;
1653
+ text: Submission["text"] | undefined;
1654
+ formData: Submission["formData"] | undefined;
1655
+ json: Submission["json"] | undefined;
1656
+ data: TData | undefined;
1657
+ " _hasFetcherDoneAnything "?: boolean;
1658
+ };
1659
+ Submitting: {
1660
+ state: "submitting";
1661
+ formMethod: Submission["formMethod"];
1662
+ formAction: Submission["formAction"];
1663
+ formEncType: Submission["formEncType"];
1664
+ text: Submission["text"];
1665
+ formData: Submission["formData"];
1666
+ json: Submission["json"];
1667
+ data: TData | undefined;
1668
+ " _hasFetcherDoneAnything "?: boolean;
1669
+ };
1670
+ };
1671
+ type Fetcher<TData = any> = FetcherStates<TData>[keyof FetcherStates<TData>];
1672
+ interface BlockerBlocked {
1673
+ state: "blocked";
1674
+ reset(): void;
1675
+ proceed(): void;
1676
+ location: Location;
1677
+ }
1678
+ interface BlockerUnblocked {
1679
+ state: "unblocked";
1680
+ reset: undefined;
1681
+ proceed: undefined;
1682
+ location: undefined;
1683
+ }
1684
+ interface BlockerProceeding {
1685
+ state: "proceeding";
1686
+ reset: undefined;
1687
+ proceed: undefined;
1688
+ location: Location;
1689
+ }
1690
+ type Blocker = BlockerUnblocked | BlockerBlocked | BlockerProceeding;
1691
+
1692
+ /**
1693
+ * NOTE: If you refactor this to split up the modules into separate files,
1694
+ * you'll need to update the rollup config for react-router-dom-v5-compat.
1695
+ */
1696
+
1697
+ declare global {
1698
+ var __staticRouterHydrationData: HydrationState | undefined;
1699
+ }
1224
1700
 
1225
1701
  declare global {
1226
1702
  interface SymbolConstructor {
@@ -1495,6 +1971,38 @@ type UseTestProviderStore = <T = TestProviderStateByProviderId>(
1495
1971
  */
1496
1972
  selector?: (state: TestProviderStateByProviderId) => T) => T;
1497
1973
 
1974
+ type StatusValue = 'status-value:pending' | 'status-value:success' | 'status-value:error' | 'status-value:warning' | 'status-value:unknown';
1975
+ type StatusTypeId = string;
1976
+ type StatusByTypeId = Record<StatusTypeId, Status>;
1977
+ type StatusesByStoryIdAndTypeId = Record<StoryId$1, StatusByTypeId>;
1978
+ interface Status {
1979
+ value: StatusValue;
1980
+ typeId: StatusTypeId;
1981
+ storyId: StoryId$1;
1982
+ title: string;
1983
+ description: string;
1984
+ data?: any;
1985
+ sidebarContextMenu?: boolean;
1986
+ }
1987
+ declare const StatusStoreEventType: {
1988
+ readonly SELECT: "select";
1989
+ };
1990
+ type StatusStoreEvent = {
1991
+ type: typeof StatusStoreEventType.SELECT;
1992
+ payload: Status[];
1993
+ };
1994
+ type StatusStore = {
1995
+ getAll: () => StatusesByStoryIdAndTypeId;
1996
+ set: (statuses: Status[]) => void;
1997
+ onAllStatusChange: (listener: (statuses: StatusesByStoryIdAndTypeId, previousStatuses: StatusesByStoryIdAndTypeId) => void) => () => void;
1998
+ onSelect: (listener: (selectedStatuses: Status[]) => void) => () => void;
1999
+ unset: (storyIds?: StoryId$1[]) => void;
2000
+ };
2001
+ type StatusStoreByTypeId = StatusStore & {
2002
+ typeId: StatusTypeId;
2003
+ };
2004
+ type UseStatusStore = <T = StatusesByStoryIdAndTypeId>(selector?: (statuses: StatusesByStoryIdAndTypeId) => T) => T;
2005
+
1498
2006
  declare const fullStatusStore: StatusStore & {
1499
2007
  selectStatuses: (statuses: Status[]) => void;
1500
2008
  typeId: undefined;