@storybook/types 7.2.3 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.d.ts +115 -18
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
Storybook types exports only typescript types for storybook usage.
|
|
4
4
|
|
|
5
5
|
It exports typescript enums, which do have a runtime implementation.
|
|
6
|
-
But it should not export any implementation such as classes,
|
|
6
|
+
But it should not export any implementation such as classes, methods, functions or constants.
|
|
7
7
|
|
|
8
8
|
It also has no dependencies, all the types it exports are bundled in.
|
package/dist/index.d.ts
CHANGED
|
@@ -1430,6 +1430,8 @@ interface ThemeVarsColors {
|
|
|
1430
1430
|
gridCellSize?: number;
|
|
1431
1431
|
}
|
|
1432
1432
|
|
|
1433
|
+
type ExportName = string;
|
|
1434
|
+
type MetaId = string;
|
|
1433
1435
|
interface StoriesSpecifier {
|
|
1434
1436
|
/**
|
|
1435
1437
|
* When auto-titling, what to prefix all generated titles with (default: '')
|
|
@@ -1467,10 +1469,40 @@ interface IndexedCSFFile {
|
|
|
1467
1469
|
};
|
|
1468
1470
|
stories: IndexedStory[];
|
|
1469
1471
|
}
|
|
1470
|
-
|
|
1472
|
+
/**
|
|
1473
|
+
* FIXME: This is a temporary type to allow us to deprecate the old indexer API.
|
|
1474
|
+
* We should remove this type and the deprecated indexer API in 8.0.
|
|
1475
|
+
*/
|
|
1476
|
+
type BaseIndexer = {
|
|
1477
|
+
/**
|
|
1478
|
+
* A regular expression that should match all files to be handled by this indexer
|
|
1479
|
+
*/
|
|
1471
1480
|
test: RegExp;
|
|
1481
|
+
};
|
|
1482
|
+
/**
|
|
1483
|
+
* An indexer describes which filenames it handles, and how to index each individual file - turning it into an entry in the index.
|
|
1484
|
+
*/
|
|
1485
|
+
type Indexer = BaseIndexer & {
|
|
1486
|
+
/**
|
|
1487
|
+
* Indexes a file containing stories or docs.
|
|
1488
|
+
* @param fileName The name of the file to index.
|
|
1489
|
+
* @param options {@link IndexerOptions} for indexing the file.
|
|
1490
|
+
* @returns A promise that resolves to an array of {@link IndexInput} objects.
|
|
1491
|
+
*/
|
|
1492
|
+
index: (fileName: string, options: IndexerOptions) => Promise<IndexInput[]>;
|
|
1493
|
+
/**
|
|
1494
|
+
* @soonDeprecated Use {@link index} instead
|
|
1495
|
+
*/
|
|
1496
|
+
indexer?: never;
|
|
1497
|
+
};
|
|
1498
|
+
type DeprecatedIndexer = BaseIndexer & {
|
|
1472
1499
|
indexer: (fileName: string, options: IndexerOptions) => Promise<IndexedCSFFile>;
|
|
1473
|
-
|
|
1500
|
+
index?: never;
|
|
1501
|
+
};
|
|
1502
|
+
/**
|
|
1503
|
+
* @soonDeprecated Use {@link Indexer} instead
|
|
1504
|
+
*/
|
|
1505
|
+
type StoryIndexer = Indexer | DeprecatedIndexer;
|
|
1474
1506
|
interface BaseIndexEntry {
|
|
1475
1507
|
id: StoryId;
|
|
1476
1508
|
name: StoryName;
|
|
@@ -1486,6 +1518,48 @@ type DocsIndexEntry = BaseIndexEntry & {
|
|
|
1486
1518
|
type: 'docs';
|
|
1487
1519
|
};
|
|
1488
1520
|
type IndexEntry = StoryIndexEntry | DocsIndexEntry;
|
|
1521
|
+
/**
|
|
1522
|
+
* The base input for indexing a story or docs entry.
|
|
1523
|
+
*/
|
|
1524
|
+
type BaseIndexInput = {
|
|
1525
|
+
/** The file to import from e.g. the story file. */
|
|
1526
|
+
importPath: Path;
|
|
1527
|
+
/** The name of the export to import. */
|
|
1528
|
+
exportName: ExportName;
|
|
1529
|
+
/** The name of the entry, auto-generated from {@link exportName} if unspecified. */
|
|
1530
|
+
name?: StoryName;
|
|
1531
|
+
/** The location in the sidebar, auto-generated from {@link importPath} if unspecified. */
|
|
1532
|
+
title?: ComponentTitle;
|
|
1533
|
+
/**
|
|
1534
|
+
* The custom id optionally set at `meta.id` if it needs to differ from the id generated via {@link title}.
|
|
1535
|
+
* If unspecified, the meta id will be auto-generated from {@link title}.
|
|
1536
|
+
* If specified, the meta in the CSF file _must_ have a matching id set at `meta.id`, to be correctly matched.
|
|
1537
|
+
*/
|
|
1538
|
+
metaId?: MetaId;
|
|
1539
|
+
/** Tags for filtering entries in Storybook and its tools. */
|
|
1540
|
+
tags?: Tag[];
|
|
1541
|
+
/**
|
|
1542
|
+
* The id of the entry, auto-generated from {@link title}/{@link metaId} and {@link exportName} if unspecified.
|
|
1543
|
+
* If specified, the story in the CSF file _must_ have a matching id set at `parameters.__id`, to be correctly matched.
|
|
1544
|
+
* Only use this if you need to override the auto-generated id.
|
|
1545
|
+
*/
|
|
1546
|
+
__id?: StoryId;
|
|
1547
|
+
};
|
|
1548
|
+
/**
|
|
1549
|
+
* The input for indexing a story entry.
|
|
1550
|
+
*/
|
|
1551
|
+
type StoryIndexInput = BaseIndexInput & {
|
|
1552
|
+
type: 'story';
|
|
1553
|
+
};
|
|
1554
|
+
/**
|
|
1555
|
+
* The input for indexing a docs entry.
|
|
1556
|
+
*/
|
|
1557
|
+
type DocsIndexInput = BaseIndexInput & {
|
|
1558
|
+
type: 'docs';
|
|
1559
|
+
/** Paths to story files that must be pre-loaded for this docs entry. */
|
|
1560
|
+
storiesImports?: Path[];
|
|
1561
|
+
};
|
|
1562
|
+
type IndexInput = StoryIndexInput | DocsIndexInput;
|
|
1489
1563
|
interface V3CompatIndexEntry extends Omit<StoryIndexEntry, 'type' | 'tags'> {
|
|
1490
1564
|
kind: ComponentTitle;
|
|
1491
1565
|
story: StoryName;
|
|
@@ -1708,7 +1782,11 @@ type Addon_BaseStoryFn<TArgs, StoryFnReturnType> = {
|
|
|
1708
1782
|
type BaseStory<TArgs, StoryFnReturnType> = Addon_BaseStoryFn<TArgs, StoryFnReturnType> | Addon_BaseStoryObject<TArgs, StoryFnReturnType>;
|
|
1709
1783
|
interface Addon_RenderOptions {
|
|
1710
1784
|
active: boolean;
|
|
1711
|
-
|
|
1785
|
+
/**
|
|
1786
|
+
* @deprecated You should not use key anymore as of Storybook 7.2 this render method is invoked as a React component.
|
|
1787
|
+
* This property will be removed in 8.0.
|
|
1788
|
+
* */
|
|
1789
|
+
key?: unknown;
|
|
1712
1790
|
}
|
|
1713
1791
|
/**
|
|
1714
1792
|
* @deprecated This type is deprecated and will be removed in 8.0.
|
|
@@ -2294,8 +2372,13 @@ interface StorybookConfig {
|
|
|
2294
2372
|
previewAnnotations?: PresetValue<Entry[]>;
|
|
2295
2373
|
/**
|
|
2296
2374
|
* Process CSF files for the story index.
|
|
2375
|
+
* @soonDeprecated use {@link experimental_indexers} instead
|
|
2297
2376
|
*/
|
|
2298
2377
|
storyIndexers?: PresetValue<StoryIndexer[]>;
|
|
2378
|
+
/**
|
|
2379
|
+
* Process CSF files for the story index.
|
|
2380
|
+
*/
|
|
2381
|
+
experimental_indexers?: PresetValue<Indexer[]>;
|
|
2299
2382
|
/**
|
|
2300
2383
|
* Docs related features in index generation
|
|
2301
2384
|
*/
|
|
@@ -2833,31 +2916,45 @@ type Store_CSFExports<TRenderer extends Renderer = Renderer, TArgs extends Args
|
|
|
2833
2916
|
__esModule?: boolean;
|
|
2834
2917
|
__namedExportsOrder?: string[];
|
|
2835
2918
|
};
|
|
2919
|
+
/**
|
|
2920
|
+
* Type for the play function returned by a composed story, which will contain everything needed in the context,
|
|
2921
|
+
* except the canvasElement, which should be passed by the user.
|
|
2922
|
+
* It's useful for scenarios where the user wants to execute the play function in test environments, e.g.
|
|
2923
|
+
*
|
|
2924
|
+
* const { PrimaryButton } = composeStories(stories)
|
|
2925
|
+
* const { container } = render(<PrimaryButton />) // or PrimaryButton()
|
|
2926
|
+
* PrimaryButton.play({ canvasElement: container })
|
|
2927
|
+
*/
|
|
2836
2928
|
type ComposedStoryPlayContext<TRenderer extends Renderer = Renderer, TArgs = Args> = Partial<StoryContext<TRenderer, TArgs> & Pick<StoryContext<TRenderer, TArgs>, 'canvasElement'>>;
|
|
2837
2929
|
type ComposedStoryPlayFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: ComposedStoryPlayContext<TRenderer, TArgs>) => Promise<void> | void;
|
|
2838
|
-
|
|
2930
|
+
/**
|
|
2931
|
+
* A story function with partial args, used internally by composeStory
|
|
2932
|
+
*/
|
|
2933
|
+
type PartialArgsStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (args?: TArgs) => (TRenderer & {
|
|
2934
|
+
T: TArgs;
|
|
2935
|
+
})['storyResult'];
|
|
2936
|
+
/**
|
|
2937
|
+
* A story that got recomposed for portable stories, containing all the necessary data to be rendered in external environments
|
|
2938
|
+
*/
|
|
2939
|
+
type ComposedStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = PartialArgsStoryFn<TRenderer, TArgs> & {
|
|
2839
2940
|
play: ComposedStoryPlayFn<TRenderer, TArgs>;
|
|
2840
2941
|
args: TArgs;
|
|
2841
2942
|
id: StoryId;
|
|
2943
|
+
storyName: string;
|
|
2944
|
+
parameters: Parameters;
|
|
2842
2945
|
};
|
|
2843
|
-
type ComposedStory<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryFn<TRenderer, TArgs> | StoryAnnotations<TRenderer, TArgs>;
|
|
2844
2946
|
/**
|
|
2845
|
-
*
|
|
2846
|
-
*
|
|
2847
|
-
* 2. infer the actual prop type for each Story
|
|
2848
|
-
* 3. reconstruct Story with Partial. Story<Props> -> Story<Partial<Props>>
|
|
2947
|
+
* Based on a module of stories, it returns all stories within it, filtering non-stories
|
|
2948
|
+
* Each story will have partial props, as their props should be handled when composing stories
|
|
2849
2949
|
*/
|
|
2850
2950
|
type StoriesWithPartialProps<TRenderer extends Renderer, TModule> = {
|
|
2851
|
-
[K in keyof TModule]: TModule[K] extends
|
|
2951
|
+
[K in keyof TModule as TModule[K] extends StoryAnnotationsOrFn<infer _, infer _TProps> ? K : never]: TModule[K] extends StoryAnnotationsOrFn<infer _, infer TProps> ? ComposedStoryFn<TRenderer, Partial<TProps>> : unknown;
|
|
2852
2952
|
};
|
|
2953
|
+
/**
|
|
2954
|
+
* Type used for integrators of portable stories, as reference when creating their own composeStory function
|
|
2955
|
+
*/
|
|
2853
2956
|
interface ComposeStoryFn<TRenderer extends Renderer = Renderer, TArgs extends Args = Args> {
|
|
2854
|
-
(storyAnnotations: AnnotatedStoryFn<TRenderer, TArgs> | StoryAnnotations<TRenderer, TArgs>, componentAnnotations: ComponentAnnotations<TRenderer, TArgs>, projectAnnotations: ProjectAnnotations<TRenderer>, exportsName?: string):
|
|
2855
|
-
(extraArgs: Partial<TArgs>): TRenderer['storyResult'];
|
|
2856
|
-
storyName: string;
|
|
2857
|
-
args: Args;
|
|
2858
|
-
play: ComposedStoryPlayFn<TRenderer, TArgs>;
|
|
2859
|
-
parameters: Parameters;
|
|
2860
|
-
};
|
|
2957
|
+
(storyAnnotations: AnnotatedStoryFn<TRenderer, TArgs> | StoryAnnotations<TRenderer, TArgs>, componentAnnotations: ComponentAnnotations<TRenderer, TArgs>, projectAnnotations: ProjectAnnotations<TRenderer>, exportsName?: string): ComposedStoryFn;
|
|
2861
2958
|
}
|
|
2862
2959
|
|
|
2863
|
-
export { API_ActiveTabsType, API_Addon, API_BaseEntry, API_Collection, API_ComponentEntry, API_ComposedRef, API_ComposedRefUpdate, API_DocsEntry, API_Group, API_GroupEntry, API_HashEntry, API_IframeRenderer, API_IndexHash, API_Layout, API_LeafEntry, API_LoadedRefData, API_MatchOptions, API_Notification, API_OptionsData, API_PanelPositions, API_Panels, API_PreparedStoryIndex, API_Provider, API_ProviderData, API_RefId, API_RefUrl, API_Refs, API_ReleaseNotes, API_RenderOptions, API_Root, API_RootEntry, API_RouteOptions, API_SetRefData, API_Settings, API_SidebarOptions, API_StateMerger, API_StatusObject, API_StatusState, API_StatusUpdate, API_StatusValue, API_Story, API_StoryEntry, API_StoryMapper, API_UI, API_UIOptions, API_UnknownEntries, API_Version, API_Versions$1 as API_Versions, API_ViewMode, Addon_AddStoryArgs, Addon_Annotations, Addon_ArgType, Addon_ArgsStoryFn, Addon_BaseAnnotations, Addon_BaseDecorators, Addon_BaseMeta, Addon_BaseStoryFn, Addon_BaseStoryObject, Addon_BaseType, Addon_ClientApiAddon, Addon_ClientApiAddons, Addon_ClientApiReturnFn, Addon_ClientStoryApi, Addon_Collection, Addon_Comparator, Addon_Config, Addon_DecoratorFunction, Addon_Elements, Addon_LegacyStoryFn, Addon_LoadFn, Addon_Loadable, Addon_Loader, Addon_LoaderFunction, Addon_Loaders, Addon_MakeDecoratorResult, Addon_OptionsParameter, Addon_OptionsParameterV7, Addon_PageType, Addon_PartialStoryFn, Addon_RenderOptions, Addon_RequireContext, Addon_StoryApi, Addon_StoryContext, Addon_StoryContextUpdate, Addon_StoryFn, Addon_StorySortComparator, Addon_StorySortComparatorV7, Addon_StorySortMethod, Addon_StorySortObjectParameter, Addon_StorySortParameter, Addon_StorySortParameterV7, Addon_StoryWrapper, Addon_ToolbarConfig, Addon_Type, Addon_Types, Addon_TypesEnum, Addon_TypesMapping, Addon_WrapperSettings, Addon_WrapperType, Addons_ArgTypes, AnnotatedStoryFn, ArgTypes, ArgTypesEnhancer, Args, ArgsEnhancer, ArgsFromMeta, ArgsStoryFn, BaseAnnotations, BaseIndexEntry, BaseStory, BoundStory, Builder, BuilderName, BuilderOptions, BuilderResult, BuilderStats, Builder_EnvsRaw, Builder_Unpromise, Builder_WithRequiredProperty, CLIOptions, CSFFile, ComponentAnnotations, ComponentId, ComponentTitle, ComposeStoryFn,
|
|
2960
|
+
export { API_ActiveTabsType, API_Addon, API_BaseEntry, API_Collection, API_ComponentEntry, API_ComposedRef, API_ComposedRefUpdate, API_DocsEntry, API_Group, API_GroupEntry, API_HashEntry, API_IframeRenderer, API_IndexHash, API_Layout, API_LeafEntry, API_LoadedRefData, API_MatchOptions, API_Notification, API_OptionsData, API_PanelPositions, API_Panels, API_PreparedStoryIndex, API_Provider, API_ProviderData, API_RefId, API_RefUrl, API_Refs, API_ReleaseNotes, API_RenderOptions, API_Root, API_RootEntry, API_RouteOptions, API_SetRefData, API_Settings, API_SidebarOptions, API_StateMerger, API_StatusObject, API_StatusState, API_StatusUpdate, API_StatusValue, API_Story, API_StoryEntry, API_StoryMapper, API_UI, API_UIOptions, API_UnknownEntries, API_Version, API_Versions$1 as API_Versions, API_ViewMode, Addon_AddStoryArgs, Addon_Annotations, Addon_ArgType, Addon_ArgsStoryFn, Addon_BaseAnnotations, Addon_BaseDecorators, Addon_BaseMeta, Addon_BaseStoryFn, Addon_BaseStoryObject, Addon_BaseType, Addon_ClientApiAddon, Addon_ClientApiAddons, Addon_ClientApiReturnFn, Addon_ClientStoryApi, Addon_Collection, Addon_Comparator, Addon_Config, Addon_DecoratorFunction, Addon_Elements, Addon_LegacyStoryFn, Addon_LoadFn, Addon_Loadable, Addon_Loader, Addon_LoaderFunction, Addon_Loaders, Addon_MakeDecoratorResult, Addon_OptionsParameter, Addon_OptionsParameterV7, Addon_PageType, Addon_PartialStoryFn, Addon_RenderOptions, Addon_RequireContext, Addon_StoryApi, Addon_StoryContext, Addon_StoryContextUpdate, Addon_StoryFn, Addon_StorySortComparator, Addon_StorySortComparatorV7, Addon_StorySortMethod, Addon_StorySortObjectParameter, Addon_StorySortParameter, Addon_StorySortParameterV7, Addon_StoryWrapper, Addon_ToolbarConfig, Addon_Type, Addon_Types, Addon_TypesEnum, Addon_TypesMapping, Addon_WrapperSettings, Addon_WrapperType, Addons_ArgTypes, AnnotatedStoryFn, ArgTypes, ArgTypesEnhancer, Args, ArgsEnhancer, ArgsFromMeta, ArgsStoryFn, BaseAnnotations, BaseIndexEntry, BaseIndexInput, BaseStory, BoundStory, Builder, BuilderName, BuilderOptions, BuilderResult, BuilderStats, Builder_EnvsRaw, Builder_Unpromise, Builder_WithRequiredProperty, CLIOptions, CSFFile, ComponentAnnotations, ComponentId, ComponentTitle, ComposeStoryFn, ComposedStoryFn, ComposedStoryPlayContext, ComposedStoryPlayFn, Conditional, CoreCommon_AddonEntry, CoreCommon_AddonInfo, CoreCommon_OptionsEntry, CoreCommon_ResolvedAddonPreset, CoreCommon_ResolvedAddonVirtual, CoreCommon_StorybookInfo, CoreConfig, DecoratorApplicator, DecoratorFunction, DeprecatedIndexer, DocsContextProps, DocsIndexEntry, DocsIndexInput, DocsOptions, DocsPreparedPayload, DocsRenderFunction, Entry, GlobalTypes, Globals, IncludeExcludeOptions, IndexEntry, IndexEntryLegacy, IndexInput, IndexedCSFFile, IndexedStory, Indexer, IndexerOptions, InputType, LegacyAnnotatedStoryFn, LegacyStoryAnnotationsOrFn, LegacyStoryFn, LoadOptions, LoadedPreset, LoaderFunction, ModuleExport, ModuleExports, ModuleImportFn, NormalizedComponentAnnotations, NormalizedProjectAnnotations, NormalizedStoriesSpecifier, NormalizedStoryAnnotations, Options, PackageJson, Parameters, PartialArgsStoryFn, PartialStoryFn, Path, PlayFunction, PlayFunctionContext, PreparedMeta, PreparedStory, Preset, PresetConfig, PresetProperty, PresetPropertyFn, PresetValue, Presets, PreviewAnnotation, ProjectAnnotations, ReactJSXElement, Ref, RenderContext, RenderContextCallbacks, RenderToCanvas, Renderer, RendererName, ResolvedModuleExport, ResolvedModuleExportFromType, ResolvedModuleExportType, SBArrayType, SBEnumType, SBIntersectionType, SBObjectType, SBOtherType, SBScalarType, SBType, SBUnionType, SeparatorOptions, SetGlobalsPayload, SetStoriesPayload, SetStoriesStory, SetStoriesStoryData, Stats, StepFunction, StepLabel, StepRunner, Store_CSFExports, StoriesEntry, StoriesWithPartialProps, StoryAnnotations, StoryAnnotationsOrFn, StoryContext, StoryContextForEnhancers, StoryContextForLoaders, StoryContextUpdate, StoryFn, StoryId, StoryIdentifier, StoryIndex, StoryIndexEntry, StoryIndexInput, StoryIndexV2, StoryIndexV3, StoryIndexer, StoryKind, StoryName, StoryPreparedPayload, StoryRenderOptions, StorybookConfig, StorybookConfigOptions, StorybookInternalParameters, StorybookParameters, StrictArgTypes, StrictArgs, StrictGlobalTypes, StrictInputType, Tag, TeardownRenderToCanvas, TypescriptOptions, V3CompatIndexEntry, VersionCheck, ViewMode, WebRenderer };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/types",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"description": "Core Storybook TS Types",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"prep": "../../../scripts/prepare/bundle.ts"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@storybook/channels": "7.
|
|
46
|
+
"@storybook/channels": "7.3.0",
|
|
47
47
|
"@types/babel__core": "^7.0.0",
|
|
48
48
|
"@types/express": "^4.7.0",
|
|
49
49
|
"file-system-cache": "2.3.0"
|