@storybook/manager-api 7.1.0-alpha.4 → 7.1.0-alpha.40
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/dist/index.d.ts +470 -10
- package/dist/index.js +3 -3
- package/dist/index.mjs +27 -3
- package/package.json +12 -12
- package/src/tests/addons.test.js +167 -0
- package/src/tests/layout.test.js +168 -0
- package/src/tests/notifications.test.js +35 -0
- package/src/tests/shortcut.test.js +111 -0
- package/src/tests/shortcuts.test.js +287 -0
- package/src/tests/store.test.js +153 -0
- package/src/tests/url.test.js +211 -0
- package/src/tests/versions.test.js +397 -0
- package/src/typings.d.ts +14 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode, Component, ReactElement, FC } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { API_IframeRenderer, Addon_Type, Addon_Types, API_Collection, API_Panels, API_StateMerger, API_Provider, API_Notification, API_Settings, API_LoadedRefData, StoryId, API_HashEntry, API_LeafEntry, API_PreparedStoryIndex, API_StoryEntry, Args, API_IndexHash, API_ComposedRef, API_DocsEntry, API_Refs, API_SetRefData, API_ComposedRefUpdate, API_Layout, API_UI, API_PanelPositions, API_Versions, API_UnknownEntries, API_Version, Globals, GlobalTypes, Addon_Collection, Addon_Config, API_ProviderData, API_OptionsData, Parameters, ArgTypes } from '@storybook/types';
|
|
3
3
|
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, Addon_TypesEnum as types } from '@storybook/types';
|
|
4
4
|
import { NavigateOptions, RouterData } from '@storybook/router';
|
|
5
5
|
import { Listener, Channel } from '@storybook/channels';
|
|
@@ -31,41 +31,150 @@ declare class Store {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
interface SubAPI$c {
|
|
34
|
-
renderPreview?:
|
|
34
|
+
renderPreview?: API_IframeRenderer;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
interface SubAPI$b {
|
|
38
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Returns a collection of elements of a specific type.
|
|
40
|
+
* @protected This is used internally in storybook's manager.
|
|
41
|
+
* @template T - The type of the elements in the collection.
|
|
42
|
+
* @param {Addon_Types} type - The type of the elements to retrieve.
|
|
43
|
+
* @returns {API_Collection<T>} - A collection of elements of the specified type.
|
|
44
|
+
*/
|
|
45
|
+
getElements: <T = Addon_Type>(type: Addon_Types) => API_Collection<T>;
|
|
46
|
+
/**
|
|
47
|
+
* Returns a collection of all panels.
|
|
48
|
+
* This is the same as calling getElements('panel')
|
|
49
|
+
* @protected This is used internally in storybook's manager.
|
|
50
|
+
* @deprecated please use getElements('panel') instead. This API will be removed in storybook 8.0.
|
|
51
|
+
* @returns {API_Panels} - A collection of all panels.
|
|
52
|
+
*/
|
|
39
53
|
getPanels: () => API_Panels;
|
|
54
|
+
/**
|
|
55
|
+
* Returns a collection of panels currently enabled for the selected story.
|
|
56
|
+
* @protected This is used internally in storybook's manager.
|
|
57
|
+
* @deprecated please use getElements('panel') instead, and do the filtering manually. This API will be removed in storybook 8.0.
|
|
58
|
+
* @returns {API_Panels} - A collection of all panels.
|
|
59
|
+
*/
|
|
40
60
|
getStoryPanels: () => API_Panels;
|
|
61
|
+
/**
|
|
62
|
+
* Returns the id of the currently selected panel.
|
|
63
|
+
* @returns {string} - The ID of the currently selected panel.
|
|
64
|
+
*/
|
|
41
65
|
getSelectedPanel: () => string;
|
|
66
|
+
/**
|
|
67
|
+
* Sets the currently selected panel via it's ID.
|
|
68
|
+
* @param {string} panelName - The ID of the panel to select.
|
|
69
|
+
* @returns {void}
|
|
70
|
+
*/
|
|
42
71
|
setSelectedPanel: (panelName: string) => void;
|
|
72
|
+
/**
|
|
73
|
+
* Sets the state of an addon with the given ID.
|
|
74
|
+
* @template S - The type of the addon state.
|
|
75
|
+
* @param {string} addonId - The ID of the addon to set the state for.
|
|
76
|
+
* @param {S | API_StateMerger<S>} newStateOrMerger - The new state to set, or a function that merges the current state with the new state.
|
|
77
|
+
* @param {Options} [options] - Optional options for the state update.
|
|
78
|
+
* @deprecated This API might get dropped, if you are using this, please file an issue.
|
|
79
|
+
* @returns {Promise<S>} - A promise that resolves with the new state after it has been set.
|
|
80
|
+
*/
|
|
43
81
|
setAddonState<S>(addonId: string, newStateOrMerger: S | API_StateMerger<S>, options?: Options): Promise<S>;
|
|
82
|
+
/**
|
|
83
|
+
* Returns the state of an addon with the given ID.
|
|
84
|
+
* @template S - The type of the addon state.
|
|
85
|
+
* @param {string} addonId - The ID of the addon to get the state for.
|
|
86
|
+
* @deprecated This API might get dropped, if you are using this, please file an issue.
|
|
87
|
+
* @returns {S} - The state of the addon with the given ID.
|
|
88
|
+
*/
|
|
44
89
|
getAddonState<S>(addonId: string): S;
|
|
45
90
|
}
|
|
46
91
|
|
|
47
92
|
interface SubAPI$a {
|
|
93
|
+
/**
|
|
94
|
+
* Returns the channel object.
|
|
95
|
+
* @protected Please do not use, it's for internal use only.
|
|
96
|
+
*/
|
|
48
97
|
getChannel: () => API_Provider<API>['channel'];
|
|
49
|
-
|
|
50
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Adds a listener to the channel for the given event type.
|
|
100
|
+
* Returns a function that can be called to remove the listener.
|
|
101
|
+
* @param type - The event type to listen for. If using a core event, import it from `@storybook/core-events`.
|
|
102
|
+
* @param handler - The callback function to be called when the event is emitted.
|
|
103
|
+
* @returns A function that can be called to remove the listener.
|
|
104
|
+
*/
|
|
105
|
+
on: (type: string, handler: Listener) => () => void;
|
|
106
|
+
/**
|
|
107
|
+
* Removes a listener from the channel for the given event type.
|
|
108
|
+
* @param type - The event type to remove the listener from. If using a core event, import it from `@storybook/core-events`.
|
|
109
|
+
* @param handler - The callback function to be removed.
|
|
110
|
+
*/
|
|
111
|
+
off: (type: string, handler: Listener) => void;
|
|
112
|
+
/**
|
|
113
|
+
* Emits an event on the channel for the given event type.
|
|
114
|
+
* @param type - The event type to emit. If using a core event, import it from `@storybook/core-events`.
|
|
115
|
+
* @param args - The arguments to pass to the event listener.
|
|
116
|
+
*/
|
|
51
117
|
emit: (type: string, ...args: any[]) => void;
|
|
52
|
-
|
|
118
|
+
/**
|
|
119
|
+
* Adds a one-time listener to the channel for the given event type.
|
|
120
|
+
* @param type - The event type to listen for. If using a core event, import it from `@storybook/core-events`.
|
|
121
|
+
* @param handler - The callback function to be called when the event is emitted.
|
|
122
|
+
*/
|
|
123
|
+
once: (type: string, handler: Listener) => void;
|
|
124
|
+
/**
|
|
125
|
+
* Emits an event to collapse all stories in the UI.
|
|
126
|
+
* @deprecated Use `emit(STORIES_COLLAPSE_ALL)` instead. This API will be removed in Storybook 8.0.
|
|
127
|
+
*/
|
|
53
128
|
collapseAll: () => void;
|
|
129
|
+
/**
|
|
130
|
+
* Emits an event to expand all stories in the UI.
|
|
131
|
+
* @deprecated Use `emit(STORIES_EXPAND_ALL)` instead. This API will be removed in Storybook 8.0.
|
|
132
|
+
*/
|
|
54
133
|
expandAll: () => void;
|
|
55
134
|
}
|
|
56
135
|
|
|
57
136
|
interface SubState$9 {
|
|
58
137
|
notifications: API_Notification[];
|
|
59
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* The API for managing notifications.
|
|
141
|
+
*/
|
|
60
142
|
interface SubAPI$9 {
|
|
143
|
+
/**
|
|
144
|
+
* Adds a new notification to the list of notifications.
|
|
145
|
+
* If a notification with the same ID already exists, it will be replaced.
|
|
146
|
+
* @param notification - The notification to add.
|
|
147
|
+
*/
|
|
61
148
|
addNotification: (notification: API_Notification) => void;
|
|
149
|
+
/**
|
|
150
|
+
* Removes a notification from the list of notifications.
|
|
151
|
+
* @param id - The ID of the notification to remove.
|
|
152
|
+
*/
|
|
62
153
|
clearNotification: (id: string) => void;
|
|
63
154
|
}
|
|
64
155
|
|
|
65
156
|
interface SubAPI$8 {
|
|
66
|
-
|
|
157
|
+
/**
|
|
158
|
+
* Changes the active settings tab.
|
|
159
|
+
* @param path - The path of the settings page to navigate to. The path NOT should include the `/settings` prefix.
|
|
160
|
+
* @example changeSettingsTab(`about`).
|
|
161
|
+
*/
|
|
162
|
+
changeSettingsTab: (path: string) => void;
|
|
163
|
+
/**
|
|
164
|
+
* Closes the settings screen and returns to the last tracked story or the first story.
|
|
165
|
+
*/
|
|
67
166
|
closeSettings: () => void;
|
|
167
|
+
/**
|
|
168
|
+
* Checks if the settings screen is currently active.
|
|
169
|
+
* @returns A boolean indicating whether the settings screen is active.
|
|
170
|
+
*/
|
|
68
171
|
isSettingsScreenActive: () => boolean;
|
|
172
|
+
/**
|
|
173
|
+
* Navigates to the specified settings page.
|
|
174
|
+
* @param path - The path of the settings page to navigate to. The path should include the `/settings` prefix.
|
|
175
|
+
* @example navigateToSettingsPage(`/settings/about`).
|
|
176
|
+
* @deprecated Use `changeSettingsTab` instead.
|
|
177
|
+
*/
|
|
69
178
|
navigateToSettingsPage: (path: string) => Promise<void>;
|
|
70
179
|
}
|
|
71
180
|
interface SubState$8 {
|
|
@@ -73,8 +182,20 @@ interface SubState$8 {
|
|
|
73
182
|
}
|
|
74
183
|
|
|
75
184
|
interface SubAPI$7 {
|
|
185
|
+
/**
|
|
186
|
+
* Returns the current version of the release notes.
|
|
187
|
+
* @returns {string} The current version of the release notes.
|
|
188
|
+
*/
|
|
76
189
|
releaseNotesVersion: () => string;
|
|
190
|
+
/**
|
|
191
|
+
* Sets the release notes as viewed.
|
|
192
|
+
* @returns {void}
|
|
193
|
+
*/
|
|
77
194
|
setDidViewReleaseNotes: () => void;
|
|
195
|
+
/**
|
|
196
|
+
* Determines whether to show the release notes on launch.
|
|
197
|
+
* @returns {boolean} Whether to show the release notes on launch.
|
|
198
|
+
*/
|
|
78
199
|
showReleaseNotesOnLaunch: () => boolean;
|
|
79
200
|
}
|
|
80
201
|
interface SubState$7 {
|
|
@@ -84,50 +205,247 @@ interface SubState$7 {
|
|
|
84
205
|
type Direction = -1 | 1;
|
|
85
206
|
type ParameterName = string;
|
|
86
207
|
type ViewMode = 'story' | 'info' | 'settings' | string | undefined;
|
|
87
|
-
type StoryUpdate = Pick<API_StoryEntry, 'parameters' | 'initialArgs' | 'argTypes' | 'args'
|
|
208
|
+
type StoryUpdate = Partial<Pick<API_StoryEntry, 'prepared' | 'parameters' | 'initialArgs' | 'argTypes' | 'args'>>;
|
|
209
|
+
interface StatusObject {
|
|
210
|
+
status: 'pending' | 'success' | 'error' | 'warn' | 'unknown';
|
|
211
|
+
title: string;
|
|
212
|
+
description: string;
|
|
213
|
+
data?: any;
|
|
214
|
+
}
|
|
215
|
+
type StatusState = Record<StoryId, Record<string, StatusObject>>;
|
|
216
|
+
type StatusUpdate = Record<StoryId, StatusObject>;
|
|
217
|
+
type DocsUpdate = Partial<Pick<API_DocsEntry, 'prepared' | 'parameters'>>;
|
|
88
218
|
interface SubState$6 extends API_LoadedRefData {
|
|
89
219
|
storyId: StoryId;
|
|
90
220
|
viewMode: ViewMode;
|
|
221
|
+
status: StatusState;
|
|
91
222
|
}
|
|
92
223
|
interface SubAPI$6 {
|
|
224
|
+
/**
|
|
225
|
+
* The `storyId` method is a reference to the `toId` function from `@storybook/csf`, which is used to generate a unique ID for a story.
|
|
226
|
+
* This ID is used to identify a specific story in the Storybook index.
|
|
227
|
+
*
|
|
228
|
+
* @type {typeof toId}
|
|
229
|
+
*/
|
|
93
230
|
storyId: typeof toId;
|
|
231
|
+
/**
|
|
232
|
+
* Resolves a story, docs, component or group ID to its corresponding hash entry in the index.
|
|
233
|
+
*
|
|
234
|
+
* @param {StoryId} storyId - The ID of the story to resolve.
|
|
235
|
+
* @param {string} [refsId] - The ID of the refs to use for resolving the story.
|
|
236
|
+
* @returns {API_HashEntry} - The hash entry corresponding to the given story ID.
|
|
237
|
+
*/
|
|
94
238
|
resolveStory: (storyId: StoryId, refsId?: string) => API_HashEntry;
|
|
239
|
+
/**
|
|
240
|
+
* Selects the first story to display in the Storybook UI.
|
|
241
|
+
*
|
|
242
|
+
* @returns {void}
|
|
243
|
+
*/
|
|
95
244
|
selectFirstStory: () => void;
|
|
96
|
-
|
|
245
|
+
/**
|
|
246
|
+
* Selects a story to display in the Storybook UI.
|
|
247
|
+
*
|
|
248
|
+
* @param {string} [kindOrId] - The kind or ID of the story to select.
|
|
249
|
+
* @param {StoryId} [story] - The ID of the story to select.
|
|
250
|
+
* @param {Object} [obj] - An optional object containing additional options.
|
|
251
|
+
* @param {string} [obj.ref] - The ref ID of the story to select.
|
|
252
|
+
* @param {ViewMode} [obj.viewMode] - The view mode to display the story in.
|
|
253
|
+
* @returns {void}
|
|
254
|
+
*/
|
|
255
|
+
selectStory: (kindOrId?: string, story?: StoryId, obj?: {
|
|
97
256
|
ref?: string;
|
|
98
257
|
viewMode?: ViewMode;
|
|
99
258
|
}) => void;
|
|
259
|
+
/**
|
|
260
|
+
* Returns the current story's data, including its ID, kind, name, and parameters.
|
|
261
|
+
*
|
|
262
|
+
* @returns {API_LeafEntry} The current story's data.
|
|
263
|
+
*/
|
|
100
264
|
getCurrentStoryData: () => API_LeafEntry;
|
|
265
|
+
/**
|
|
266
|
+
* Sets the prepared story index to the given value.
|
|
267
|
+
*
|
|
268
|
+
* @param {API_PreparedStoryIndex} index - The prepared story index to set.
|
|
269
|
+
* @returns {Promise<void>} A promise that resolves when the prepared story index has been set.
|
|
270
|
+
*/
|
|
101
271
|
setIndex: (index: API_PreparedStoryIndex) => Promise<void>;
|
|
272
|
+
/**
|
|
273
|
+
* Jumps to the next or previous component in the index.
|
|
274
|
+
*
|
|
275
|
+
* @param {Direction} direction - The direction to jump. Use -1 to jump to the previous component, and 1 to jump to the next component.
|
|
276
|
+
* @returns {void}
|
|
277
|
+
*/
|
|
102
278
|
jumpToComponent: (direction: Direction) => void;
|
|
279
|
+
/**
|
|
280
|
+
* Jumps to the next or previous story in the story index.
|
|
281
|
+
*
|
|
282
|
+
* @param {Direction} direction - The direction to jump. Use -1 to jump to the previous story, and 1 to jump to the next story.
|
|
283
|
+
* @returns {void}
|
|
284
|
+
*/
|
|
103
285
|
jumpToStory: (direction: Direction) => void;
|
|
286
|
+
/**
|
|
287
|
+
* Returns the data for the given story ID and optional ref ID.
|
|
288
|
+
*
|
|
289
|
+
* @param {StoryId} storyId - The ID of the story to retrieve data for.
|
|
290
|
+
* @param {string} [refId] - The ID of the ref to retrieve data for. If not provided, retrieves data for the default ref.
|
|
291
|
+
* @returns {API_LeafEntry} The data for the given story ID and optional ref ID.
|
|
292
|
+
*/
|
|
104
293
|
getData: (storyId: StoryId, refId?: string) => API_LeafEntry;
|
|
294
|
+
/**
|
|
295
|
+
* Returns a boolean indicating whether the given story ID and optional ref ID have been prepared.
|
|
296
|
+
*
|
|
297
|
+
* @param {StoryId} storyId - The ID of the story to check.
|
|
298
|
+
* @param {string} [refId] - The ID of the ref to check. If not provided, checks all refs for the given story ID.
|
|
299
|
+
* @returns {boolean} A boolean indicating whether the given story ID and optional ref ID have been prepared.
|
|
300
|
+
*/
|
|
105
301
|
isPrepared: (storyId: StoryId, refId?: string) => boolean;
|
|
302
|
+
/**
|
|
303
|
+
* Returns the parameters for the given story ID and optional ref ID.
|
|
304
|
+
*
|
|
305
|
+
* @param {StoryId | { storyId: StoryId; refId: string }} storyId - The ID of the story to retrieve parameters for, or an object containing the story ID and ref ID.
|
|
306
|
+
* @param {ParameterName} [parameterName] - The name of the parameter to retrieve. If not provided, returns all parameters.
|
|
307
|
+
* @returns {API_StoryEntry['parameters'] | any} The parameters for the given story ID and optional ref ID.
|
|
308
|
+
*/
|
|
106
309
|
getParameters: (storyId: StoryId | {
|
|
107
310
|
storyId: StoryId;
|
|
108
311
|
refId: string;
|
|
109
312
|
}, parameterName?: ParameterName) => API_StoryEntry['parameters'] | any;
|
|
313
|
+
/**
|
|
314
|
+
* Returns the current value of the specified parameter for the currently selected story.
|
|
315
|
+
*
|
|
316
|
+
* @template S - The type of the parameter value.
|
|
317
|
+
* @param {ParameterName} [parameterName] - The name of the parameter to retrieve. If not provided, returns all parameters.
|
|
318
|
+
* @returns {S} The value of the specified parameter for the currently selected story.
|
|
319
|
+
*/
|
|
110
320
|
getCurrentParameter<S>(parameterName?: ParameterName): S;
|
|
321
|
+
/**
|
|
322
|
+
* Updates the arguments for the given story with the provided new arguments.
|
|
323
|
+
*
|
|
324
|
+
* @param {API_StoryEntry} story - The story to update the arguments for.
|
|
325
|
+
* @param {Args} newArgs - The new arguments to set for the story.
|
|
326
|
+
* @returns {void}
|
|
327
|
+
*/
|
|
111
328
|
updateStoryArgs(story: API_StoryEntry, newArgs: Args): void;
|
|
329
|
+
/**
|
|
330
|
+
* Resets the arguments for the given story to their initial values.
|
|
331
|
+
*
|
|
332
|
+
* @param {API_StoryEntry} story - The story to reset the arguments for.
|
|
333
|
+
* @param {string[]} [argNames] - An optional array of argument names to reset. If not provided, all arguments will be reset.
|
|
334
|
+
* @returns {void}
|
|
335
|
+
*/
|
|
112
336
|
resetStoryArgs: (story: API_StoryEntry, argNames?: string[]) => void;
|
|
337
|
+
/**
|
|
338
|
+
* Finds the leaf entry for the given story ID in the given story index.
|
|
339
|
+
*
|
|
340
|
+
* @param {API_IndexHash} index - The story index to search for the leaf entry in.
|
|
341
|
+
* @param {StoryId} storyId - The ID of the story to find the leaf entry for.
|
|
342
|
+
* @returns {API_LeafEntry} The leaf entry for the given story ID, or null if no leaf entry was found.
|
|
343
|
+
*/
|
|
113
344
|
findLeafEntry(index: API_IndexHash, storyId: StoryId): API_LeafEntry;
|
|
345
|
+
/**
|
|
346
|
+
* Finds the leaf story ID for the given component or group ID in the given index.
|
|
347
|
+
*
|
|
348
|
+
* @param {API_IndexHash} index - The story index to search for the leaf story ID in.
|
|
349
|
+
* @param {StoryId} storyId - The ID of the story to find the leaf story ID for.
|
|
350
|
+
* @returns {StoryId} The ID of the leaf story, or null if no leaf story was found.
|
|
351
|
+
*/
|
|
114
352
|
findLeafStoryId(index: API_IndexHash, storyId: StoryId): StoryId;
|
|
353
|
+
/**
|
|
354
|
+
* Finds the ID of the sibling story in the given direction for the given story ID in the given story index.
|
|
355
|
+
*
|
|
356
|
+
* @param {StoryId} storyId - The ID of the story to find the sibling of.
|
|
357
|
+
* @param {API_IndexHash} index - The story index to search for the sibling in.
|
|
358
|
+
* @param {Direction} direction - The direction to search for the sibling in.
|
|
359
|
+
* @param {boolean} toSiblingGroup - When true, skips over leafs within the same group.
|
|
360
|
+
* @returns {StoryId} The ID of the sibling story, or null if no sibling was found.
|
|
361
|
+
*/
|
|
115
362
|
findSiblingStoryId(storyId: StoryId, index: API_IndexHash, direction: Direction, toSiblingGroup: boolean): StoryId;
|
|
363
|
+
/**
|
|
364
|
+
* Fetches the story index from the server.
|
|
365
|
+
*
|
|
366
|
+
* @returns {Promise<void>} A promise that resolves when the index has been fetched.
|
|
367
|
+
*/
|
|
116
368
|
fetchIndex: () => Promise<void>;
|
|
369
|
+
/**
|
|
370
|
+
* Updates the story with the given ID with the provided update object.
|
|
371
|
+
*
|
|
372
|
+
* @param {StoryId} storyId - The ID of the story to update.
|
|
373
|
+
* @param {StoryUpdate} update - An object containing the updated story information.
|
|
374
|
+
* @param {API_ComposedRef} [ref] - The composed ref of the story to update.
|
|
375
|
+
* @returns {Promise<void>} A promise that resolves when the story has been updated.
|
|
376
|
+
*/
|
|
117
377
|
updateStory: (storyId: StoryId, update: StoryUpdate, ref?: API_ComposedRef) => Promise<void>;
|
|
378
|
+
/**
|
|
379
|
+
* Updates the documentation for the given story ID with the given update object.
|
|
380
|
+
*
|
|
381
|
+
* @param {StoryId} storyId - The ID of the story to update.
|
|
382
|
+
* @param {DocsUpdate} update - An object containing the updated documentation information.
|
|
383
|
+
* @param {API_ComposedRef} [ref] - The composed ref of the story to update.
|
|
384
|
+
* @returns {Promise<void>} A promise that resolves when the documentation has been updated.
|
|
385
|
+
*/
|
|
386
|
+
updateDocs: (storyId: StoryId, update: DocsUpdate, ref?: API_ComposedRef) => Promise<void>;
|
|
387
|
+
/**
|
|
388
|
+
* Sets the preview as initialized.
|
|
389
|
+
*
|
|
390
|
+
* @param {ComposedRef} [ref] - The composed ref of the story to set as initialized.
|
|
391
|
+
* @returns {Promise<void>} A promise that resolves when the preview has been set as initialized.
|
|
392
|
+
*/
|
|
118
393
|
setPreviewInitialized: (ref?: API_ComposedRef) => Promise<void>;
|
|
394
|
+
/**
|
|
395
|
+
* Updates the status of a collection of stories.
|
|
396
|
+
*
|
|
397
|
+
* @param {string} addonId - The ID of the addon to update.
|
|
398
|
+
* @param {StatusUpdate} update - An object containing the updated status information.
|
|
399
|
+
* @returns {Promise<void>} A promise that resolves when the status has been updated.
|
|
400
|
+
*/
|
|
401
|
+
experimental_updateStatus: (addonId: string, update: StatusUpdate) => Promise<void>;
|
|
119
402
|
}
|
|
120
403
|
|
|
121
404
|
interface SubState$5 {
|
|
122
405
|
refs: API_Refs;
|
|
123
406
|
}
|
|
124
407
|
interface SubAPI$5 {
|
|
408
|
+
/**
|
|
409
|
+
* Finds a composed ref by its source.
|
|
410
|
+
* @param {string} source - The source/URL of the composed ref.
|
|
411
|
+
* @returns {API_ComposedRef} - The composed ref object.
|
|
412
|
+
*/
|
|
125
413
|
findRef: (source: string) => API_ComposedRef;
|
|
414
|
+
/**
|
|
415
|
+
* Sets a composed ref by its ID and data.
|
|
416
|
+
* @param {string} id - The ID of the composed ref.
|
|
417
|
+
* @param {API_SetRefData} data - The data to set for the composed ref.
|
|
418
|
+
* @param {boolean} [ready] - Whether the composed ref is ready.
|
|
419
|
+
*/
|
|
126
420
|
setRef: (id: string, data: API_SetRefData, ready?: boolean) => void;
|
|
421
|
+
/**
|
|
422
|
+
* Updates a composed ref by its ID and update object.
|
|
423
|
+
* @param {string} id - The ID of the composed ref.
|
|
424
|
+
* @param {API_ComposedRefUpdate} ref - The update object for the composed ref.
|
|
425
|
+
*/
|
|
127
426
|
updateRef: (id: string, ref: API_ComposedRefUpdate) => void;
|
|
427
|
+
/**
|
|
428
|
+
* Gets all composed refs.
|
|
429
|
+
* @returns {API_Refs} - The composed refs object.
|
|
430
|
+
*/
|
|
128
431
|
getRefs: () => API_Refs;
|
|
432
|
+
/**
|
|
433
|
+
* Checks if a composed ref is valid.
|
|
434
|
+
* @param {API_SetRefData} ref - The composed ref to check.
|
|
435
|
+
* @returns {Promise<void>} - A promise that resolves when the check is complete.
|
|
436
|
+
*/
|
|
129
437
|
checkRef: (ref: API_SetRefData) => Promise<void>;
|
|
438
|
+
/**
|
|
439
|
+
* Changes the version of a composed ref by its ID and URL.
|
|
440
|
+
* @param {string} id - The ID of the composed ref.
|
|
441
|
+
* @param {string} url - The new URL for the composed ref.
|
|
442
|
+
*/
|
|
130
443
|
changeRefVersion: (id: string, url: string) => void;
|
|
444
|
+
/**
|
|
445
|
+
* Changes the state of a composed ref by its ID and previewInitialized flag.
|
|
446
|
+
* @param {string} id - The ID of the composed ref.
|
|
447
|
+
* @param {boolean} previewInitialized - The new previewInitialized flag for the composed ref.
|
|
448
|
+
*/
|
|
131
449
|
changeRefState: (id: string, previewInitialized: boolean) => void;
|
|
132
450
|
}
|
|
133
451
|
|
|
@@ -138,11 +456,35 @@ interface SubState$4 {
|
|
|
138
456
|
theme: ThemeVars;
|
|
139
457
|
}
|
|
140
458
|
interface SubAPI$4 {
|
|
459
|
+
/**
|
|
460
|
+
* Toggles the fullscreen mode of the Storybook UI.
|
|
461
|
+
* @param toggled - Optional boolean value to set the fullscreen mode to. If not provided, it will toggle the current state.
|
|
462
|
+
*/
|
|
141
463
|
toggleFullscreen: (toggled?: boolean) => void;
|
|
464
|
+
/**
|
|
465
|
+
* Toggles the visibility of the panel in the Storybook UI.
|
|
466
|
+
* @param toggled - Optional boolean value to set the panel visibility to. If not provided, it will toggle the current state.
|
|
467
|
+
*/
|
|
142
468
|
togglePanel: (toggled?: boolean) => void;
|
|
469
|
+
/**
|
|
470
|
+
* Toggles the position of the panel in the Storybook UI.
|
|
471
|
+
* @param position - Optional string value to set the panel position to. If not provided, it will toggle between 'bottom' and 'right'.
|
|
472
|
+
*/
|
|
143
473
|
togglePanelPosition: (position?: API_PanelPositions) => void;
|
|
474
|
+
/**
|
|
475
|
+
* Toggles the visibility of the navigation bar in the Storybook UI.
|
|
476
|
+
* @param toggled - Optional boolean value to set the navigation bar visibility to. If not provided, it will toggle the current state.
|
|
477
|
+
*/
|
|
144
478
|
toggleNav: (toggled?: boolean) => void;
|
|
479
|
+
/**
|
|
480
|
+
* Toggles the visibility of the toolbar in the Storybook UI.
|
|
481
|
+
* @param toggled - Optional boolean value to set the toolbar visibility to. If not provided, it will toggle the current state.
|
|
482
|
+
*/
|
|
145
483
|
toggleToolbar: (toggled?: boolean) => void;
|
|
484
|
+
/**
|
|
485
|
+
* Sets the options for the Storybook UI.
|
|
486
|
+
* @param options - An object containing the options to set.
|
|
487
|
+
*/
|
|
146
488
|
setOptions: (options: any) => void;
|
|
147
489
|
}
|
|
148
490
|
|
|
@@ -162,17 +504,66 @@ interface SubState$3 {
|
|
|
162
504
|
shortcuts: API_Shortcuts;
|
|
163
505
|
}
|
|
164
506
|
interface SubAPI$3 {
|
|
507
|
+
/**
|
|
508
|
+
* Returns the current shortcuts.
|
|
509
|
+
*/
|
|
165
510
|
getShortcutKeys(): API_Shortcuts;
|
|
511
|
+
/**
|
|
512
|
+
* Returns the default shortcuts.
|
|
513
|
+
*/
|
|
166
514
|
getDefaultShortcuts(): API_Shortcuts | API_AddonShortcutDefaults;
|
|
515
|
+
/**
|
|
516
|
+
* Returns the shortcuts for addons.
|
|
517
|
+
*/
|
|
167
518
|
getAddonsShortcuts(): API_AddonShortcuts;
|
|
519
|
+
/**
|
|
520
|
+
* Returns the labels for addon shortcuts.
|
|
521
|
+
*/
|
|
168
522
|
getAddonsShortcutLabels(): API_AddonShortcutLabels;
|
|
523
|
+
/**
|
|
524
|
+
* Returns the default shortcuts for addons.
|
|
525
|
+
*/
|
|
169
526
|
getAddonsShortcutDefaults(): API_AddonShortcutDefaults;
|
|
527
|
+
/**
|
|
528
|
+
* Sets the shortcuts to the given value.
|
|
529
|
+
* @param shortcuts The new shortcuts to set.
|
|
530
|
+
* @returns A promise that resolves to the new shortcuts.
|
|
531
|
+
*/
|
|
170
532
|
setShortcuts(shortcuts: API_Shortcuts): Promise<API_Shortcuts>;
|
|
533
|
+
/**
|
|
534
|
+
* Sets the shortcut for the given action to the given value.
|
|
535
|
+
* @param action The action to set the shortcut for.
|
|
536
|
+
* @param value The new shortcut to set.
|
|
537
|
+
* @returns A promise that resolves to the new shortcut.
|
|
538
|
+
*/
|
|
171
539
|
setShortcut(action: API_Action, value: API_KeyCollection): Promise<API_KeyCollection>;
|
|
540
|
+
/**
|
|
541
|
+
* Sets the shortcut for the given addon to the given value.
|
|
542
|
+
* @param addon The addon to set the shortcut for.
|
|
543
|
+
* @param shortcut The new shortcut to set.
|
|
544
|
+
* @returns A promise that resolves to the new addon shortcut.
|
|
545
|
+
*/
|
|
172
546
|
setAddonShortcut(addon: string, shortcut: API_AddonShortcut): Promise<API_AddonShortcut>;
|
|
547
|
+
/**
|
|
548
|
+
* Restores all default shortcuts.
|
|
549
|
+
* @returns A promise that resolves to the new shortcuts.
|
|
550
|
+
*/
|
|
173
551
|
restoreAllDefaultShortcuts(): Promise<API_Shortcuts>;
|
|
552
|
+
/**
|
|
553
|
+
* Restores the default shortcut for the given action.
|
|
554
|
+
* @param action The action to restore the default shortcut for.
|
|
555
|
+
* @returns A promise that resolves to the new shortcut.
|
|
556
|
+
*/
|
|
174
557
|
restoreDefaultShortcut(action: API_Action): Promise<API_KeyCollection>;
|
|
558
|
+
/**
|
|
559
|
+
* Handles a keydown event.
|
|
560
|
+
* @param event The event to handle.
|
|
561
|
+
*/
|
|
175
562
|
handleKeydownEvent(event: KeyboardEventLike): void;
|
|
563
|
+
/**
|
|
564
|
+
* Handles a shortcut feature.
|
|
565
|
+
* @param feature The feature to handle.
|
|
566
|
+
*/
|
|
176
567
|
handleShortcutFeature(feature: API_Action): void;
|
|
177
568
|
}
|
|
178
569
|
type API_KeyCollection = string[];
|
|
@@ -215,9 +606,33 @@ interface SubState$2 {
|
|
|
215
606
|
interface QueryParams {
|
|
216
607
|
[key: string]: string | null;
|
|
217
608
|
}
|
|
609
|
+
/**
|
|
610
|
+
* SubAPI for managing URL navigation and state.
|
|
611
|
+
*/
|
|
218
612
|
interface SubAPI$2 {
|
|
613
|
+
/**
|
|
614
|
+
* Navigate to a new URL.
|
|
615
|
+
* @param {string} url - The URL to navigate to.
|
|
616
|
+
* @param {NavigateOptions} options - Options for the navigation.
|
|
617
|
+
* @returns {void}
|
|
618
|
+
*/
|
|
219
619
|
navigateUrl: (url: string, options: NavigateOptions) => void;
|
|
620
|
+
/**
|
|
621
|
+
* Get the value of a query parameter from the current URL.
|
|
622
|
+
* @param {string} key - The key of the query parameter to get.
|
|
623
|
+
* @returns {string | undefined} The value of the query parameter, or undefined if it does not exist.
|
|
624
|
+
*/
|
|
220
625
|
getQueryParam: (key: string) => string | undefined;
|
|
626
|
+
/**
|
|
627
|
+
* Returns an object containing the current state of the URL.
|
|
628
|
+
* @returns {{
|
|
629
|
+
* queryParams: QueryParams,
|
|
630
|
+
* path: string,
|
|
631
|
+
* viewMode?: string,
|
|
632
|
+
* storyId?: string,
|
|
633
|
+
* url: string
|
|
634
|
+
* }} An object containing the current state of the URL.
|
|
635
|
+
*/
|
|
221
636
|
getUrlState: () => {
|
|
222
637
|
queryParams: QueryParams;
|
|
223
638
|
path: string;
|
|
@@ -225,6 +640,11 @@ interface SubAPI$2 {
|
|
|
225
640
|
storyId?: string;
|
|
226
641
|
url: string;
|
|
227
642
|
};
|
|
643
|
+
/**
|
|
644
|
+
* Set the query parameters for the current URL.
|
|
645
|
+
* @param {QueryParams} input - An object containing the query parameters to set.
|
|
646
|
+
* @returns {void}
|
|
647
|
+
*/
|
|
228
648
|
setQueryParams: (input: QueryParams) => void;
|
|
229
649
|
}
|
|
230
650
|
|
|
@@ -234,8 +654,23 @@ interface SubState$1 {
|
|
|
234
654
|
dismissedVersionNotification: undefined | string;
|
|
235
655
|
}
|
|
236
656
|
interface SubAPI$1 {
|
|
657
|
+
/**
|
|
658
|
+
* Returns the current version of the Storybook Manager.
|
|
659
|
+
*
|
|
660
|
+
* @returns {API_Version} The current version of the Storybook Manager.
|
|
661
|
+
*/
|
|
237
662
|
getCurrentVersion: () => API_Version;
|
|
663
|
+
/**
|
|
664
|
+
* Returns the latest version of the Storybook Manager.
|
|
665
|
+
*
|
|
666
|
+
* @returns {API_Version} The latest version of the Storybook Manager.
|
|
667
|
+
*/
|
|
238
668
|
getLatestVersion: () => API_Version;
|
|
669
|
+
/**
|
|
670
|
+
* Checks if an update is available for the Storybook Manager.
|
|
671
|
+
*
|
|
672
|
+
* @returns {boolean} True if an update is available, false otherwise.
|
|
673
|
+
*/
|
|
239
674
|
versionUpdateAvailable: () => boolean;
|
|
240
675
|
}
|
|
241
676
|
|
|
@@ -244,8 +679,21 @@ interface SubState {
|
|
|
244
679
|
globalTypes?: GlobalTypes;
|
|
245
680
|
}
|
|
246
681
|
interface SubAPI {
|
|
682
|
+
/**
|
|
683
|
+
* Returns the current global data object.
|
|
684
|
+
* @returns {Globals} The current global data object.
|
|
685
|
+
*/
|
|
247
686
|
getGlobals: () => Globals;
|
|
687
|
+
/**
|
|
688
|
+
* Returns the current global types object.
|
|
689
|
+
* @returns {GlobalTypes} The current global types object.
|
|
690
|
+
*/
|
|
248
691
|
getGlobalTypes: () => GlobalTypes;
|
|
692
|
+
/**
|
|
693
|
+
* Updates the current global data object with the provided new global data object.
|
|
694
|
+
* @param {Globals} newGlobals - The new global data object to update with.
|
|
695
|
+
* @returns {void}
|
|
696
|
+
*/
|
|
249
697
|
updateGlobals: (newGlobals: Globals) => void;
|
|
250
698
|
}
|
|
251
699
|
|
|
@@ -259,15 +707,27 @@ declare class AddonStore {
|
|
|
259
707
|
private elements;
|
|
260
708
|
private config;
|
|
261
709
|
private channel;
|
|
710
|
+
/**
|
|
711
|
+
* @deprecated will be removed in 8.0
|
|
712
|
+
*/
|
|
262
713
|
private serverChannel;
|
|
263
714
|
private promise;
|
|
264
715
|
private resolve;
|
|
265
716
|
getChannel: () => Channel;
|
|
717
|
+
/**
|
|
718
|
+
* @deprecated will be removed in 8.0, use getChannel instead
|
|
719
|
+
*/
|
|
266
720
|
getServerChannel: () => Channel;
|
|
267
721
|
ready: () => Promise<Channel>;
|
|
268
722
|
hasChannel: () => boolean;
|
|
723
|
+
/**
|
|
724
|
+
* @deprecated will be removed in 8.0, please use the normal channel instead
|
|
725
|
+
*/
|
|
269
726
|
hasServerChannel: () => boolean;
|
|
270
727
|
setChannel: (channel: Channel) => void;
|
|
728
|
+
/**
|
|
729
|
+
* @deprecated will be removed in 8.0, please use the normal channel instead
|
|
730
|
+
*/
|
|
271
731
|
setServerChannel: (channel: Channel) => void;
|
|
272
732
|
getElements: (type: Addon_Types) => Addon_Collection;
|
|
273
733
|
addPanel: (name: string, options: Addon_Type) => void;
|
|
@@ -337,7 +797,7 @@ declare class ManagerProvider extends Component<ManagerProviderProps, State> {
|
|
|
337
797
|
static getDerivedStateFromProps(props: ManagerProviderProps, state: State): State;
|
|
338
798
|
shouldComponentUpdate(nextProps: ManagerProviderProps, nextState: State): boolean;
|
|
339
799
|
initModules: () => void;
|
|
340
|
-
render(): JSX.Element;
|
|
800
|
+
render(): React.JSX.Element;
|
|
341
801
|
}
|
|
342
802
|
interface ManagerConsumerProps<P = unknown> {
|
|
343
803
|
filter?: (combo: Combo) => P;
|