@storybook/types 7.2.0 → 7.2.2-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.d.ts +83 -3
  2. package/package.json +2 -2
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: '')
@@ -1461,15 +1463,46 @@ interface IndexedStory {
1461
1463
  }
1462
1464
  interface IndexedCSFFile {
1463
1465
  meta: {
1466
+ id?: string;
1464
1467
  title?: string;
1465
1468
  tags?: Tag[];
1466
1469
  };
1467
1470
  stories: IndexedStory[];
1468
1471
  }
1469
- interface StoryIndexer {
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
+ */
1470
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 & {
1471
1499
  indexer: (fileName: string, options: IndexerOptions) => Promise<IndexedCSFFile>;
1472
- }
1500
+ index?: never;
1501
+ };
1502
+ /**
1503
+ * @soonDeprecated Use {@link Indexer} instead
1504
+ */
1505
+ type StoryIndexer = Indexer | DeprecatedIndexer;
1473
1506
  interface BaseIndexEntry {
1474
1507
  id: StoryId;
1475
1508
  name: StoryName;
@@ -1485,6 +1518,48 @@ type DocsIndexEntry = BaseIndexEntry & {
1485
1518
  type: 'docs';
1486
1519
  };
1487
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;
1488
1563
  interface V3CompatIndexEntry extends Omit<StoryIndexEntry, 'type' | 'tags'> {
1489
1564
  kind: ComponentTitle;
1490
1565
  story: StoryName;
@@ -2293,8 +2368,13 @@ interface StorybookConfig {
2293
2368
  previewAnnotations?: PresetValue<Entry[]>;
2294
2369
  /**
2295
2370
  * Process CSF files for the story index.
2371
+ * @soonDeprecated use {@link experimental_indexers} instead
2296
2372
  */
2297
2373
  storyIndexers?: PresetValue<StoryIndexer[]>;
2374
+ /**
2375
+ * Process CSF files for the story index.
2376
+ */
2377
+ experimental_indexers?: PresetValue<Indexer[]>;
2298
2378
  /**
2299
2379
  * Docs related features in index generation
2300
2380
  */
@@ -2859,4 +2939,4 @@ interface ComposeStoryFn<TRenderer extends Renderer = Renderer, TArgs extends Ar
2859
2939
  };
2860
2940
  }
2861
2941
 
2862
- 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, ComposedStory, ComposedStoryPlayContext, ComposedStoryPlayFn, Conditional, CoreCommon_AddonEntry, CoreCommon_AddonInfo, CoreCommon_OptionsEntry, CoreCommon_ResolvedAddonPreset, CoreCommon_ResolvedAddonVirtual, CoreCommon_StorybookInfo, CoreConfig, DecoratorApplicator, DecoratorFunction, DocsContextProps, DocsIndexEntry, DocsOptions, DocsPreparedPayload, DocsRenderFunction, Entry, GlobalTypes, Globals, IncludeExcludeOptions, IndexEntry, IndexEntryLegacy, IndexedCSFFile, IndexedStory, IndexerOptions, InputType, LegacyAnnotatedStoryFn, LegacyStoryAnnotationsOrFn, LegacyStoryFn, LoadOptions, LoadedPreset, LoaderFunction, ModuleExport, ModuleExports, ModuleImportFn, NormalizedComponentAnnotations, NormalizedProjectAnnotations, NormalizedStoriesSpecifier, NormalizedStoryAnnotations, Options, PackageJson, Parameters, PartialStoryFn, Path, PlayFunction, PlayFunctionContext, PreparedMeta, PreparedStory, PreparedStoryFn, 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, StoryIndexV2, StoryIndexV3, StoryIndexer, StoryKind, StoryName, StoryPreparedPayload, StoryRenderOptions, StorybookConfig, StorybookConfigOptions, StorybookInternalParameters, StorybookParameters, StrictArgTypes, StrictArgs, StrictGlobalTypes, StrictInputType, Tag, TeardownRenderToCanvas, TypescriptOptions, V3CompatIndexEntry, VersionCheck, ViewMode, WebRenderer };
2942
+ 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, ComposedStory, 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, PartialStoryFn, Path, PlayFunction, PlayFunctionContext, PreparedMeta, PreparedStory, PreparedStoryFn, 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.2.0",
3
+ "version": "7.2.2-alpha.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.2.0",
46
+ "@storybook/channels": "7.2.2-alpha.0",
47
47
  "@types/babel__core": "^7.0.0",
48
48
  "@types/express": "^4.7.0",
49
49
  "file-system-cache": "2.3.0"