@storybook/nextjs 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.
@@ -850,6 +850,8 @@ type ArgsStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (args: T
850
850
  type StoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = LegacyStoryFn<TRenderer, TArgs> | ArgsStoryFn<TRenderer, TArgs>;
851
851
  type DecoratorFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (fn: PartialStoryFn<TRenderer, TArgs>, c: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
852
852
 
853
+ type ExportName = string;
854
+ type MetaId = string;
853
855
  interface StoriesSpecifier {
854
856
  /**
855
857
  * When auto-titling, what to prefix all generated titles with (default: '')
@@ -878,21 +880,95 @@ interface IndexedStory {
878
880
  }
879
881
  interface IndexedCSFFile {
880
882
  meta: {
883
+ id?: string;
881
884
  title?: string;
882
885
  tags?: Tag[];
883
886
  };
884
887
  stories: IndexedStory[];
885
888
  }
886
- interface StoryIndexer {
889
+ /**
890
+ * FIXME: This is a temporary type to allow us to deprecate the old indexer API.
891
+ * We should remove this type and the deprecated indexer API in 8.0.
892
+ */
893
+ type BaseIndexer = {
894
+ /**
895
+ * A regular expression that should match all files to be handled by this indexer
896
+ */
887
897
  test: RegExp;
898
+ };
899
+ /**
900
+ * An indexer describes which filenames it handles, and how to index each individual file - turning it into an entry in the index.
901
+ */
902
+ type Indexer = BaseIndexer & {
903
+ /**
904
+ * Indexes a file containing stories or docs.
905
+ * @param fileName The name of the file to index.
906
+ * @param options {@link IndexerOptions} for indexing the file.
907
+ * @returns A promise that resolves to an array of {@link IndexInput} objects.
908
+ */
909
+ index: (fileName: string, options: IndexerOptions) => Promise<IndexInput[]>;
910
+ /**
911
+ * @soonDeprecated Use {@link index} instead
912
+ */
913
+ indexer?: never;
914
+ };
915
+ type DeprecatedIndexer = BaseIndexer & {
888
916
  indexer: (fileName: string, options: IndexerOptions) => Promise<IndexedCSFFile>;
889
- }
917
+ index?: never;
918
+ };
919
+ /**
920
+ * @soonDeprecated Use {@link Indexer} instead
921
+ */
922
+ type StoryIndexer = Indexer | DeprecatedIndexer;
923
+ /**
924
+ * The base input for indexing a story or docs entry.
925
+ */
926
+ type BaseIndexInput = {
927
+ /** The file to import from e.g. the story file. */
928
+ importPath: Path;
929
+ /** The name of the export to import. */
930
+ exportName: ExportName;
931
+ /** The name of the entry, auto-generated from {@link exportName} if unspecified. */
932
+ name?: StoryName;
933
+ /** The location in the sidebar, auto-generated from {@link importPath} if unspecified. */
934
+ title?: ComponentTitle;
935
+ /**
936
+ * The custom id optionally set at `meta.id` if it needs to differ from the id generated via {@link title}.
937
+ * If unspecified, the meta id will be auto-generated from {@link title}.
938
+ * If specified, the meta in the CSF file _must_ have a matching id set at `meta.id`, to be correctly matched.
939
+ */
940
+ metaId?: MetaId;
941
+ /** Tags for filtering entries in Storybook and its tools. */
942
+ tags?: Tag[];
943
+ /**
944
+ * The id of the entry, auto-generated from {@link title}/{@link metaId} and {@link exportName} if unspecified.
945
+ * If specified, the story in the CSF file _must_ have a matching id set at `parameters.__id`, to be correctly matched.
946
+ * Only use this if you need to override the auto-generated id.
947
+ */
948
+ __id?: StoryId;
949
+ };
950
+ /**
951
+ * The input for indexing a story entry.
952
+ */
953
+ type StoryIndexInput = BaseIndexInput & {
954
+ type: 'story';
955
+ };
956
+ /**
957
+ * The input for indexing a docs entry.
958
+ */
959
+ type DocsIndexInput = BaseIndexInput & {
960
+ type: 'docs';
961
+ /** Paths to story files that must be pre-loaded for this docs entry. */
962
+ storiesImports?: Path[];
963
+ };
964
+ type IndexInput = StoryIndexInput | DocsIndexInput;
890
965
  type Addon_ReturnTypeFramework<ReturnType> = {
891
966
  component: any;
892
967
  storyResult: ReturnType;
893
968
  canvasElement: any;
894
969
  };
895
970
  type Addon_DecoratorFunction<StoryFnReturnType = unknown> = DecoratorFunction<Addon_ReturnTypeFramework<StoryFnReturnType>>;
971
+ type Path = string;
896
972
 
897
973
  interface Options$1 {
898
974
  allowRegExp: boolean;
@@ -1168,8 +1244,13 @@ interface StorybookConfig {
1168
1244
  previewAnnotations?: PresetValue<Entry[]>;
1169
1245
  /**
1170
1246
  * Process CSF files for the story index.
1247
+ * @soonDeprecated use {@link experimental_indexers} instead
1171
1248
  */
1172
1249
  storyIndexers?: PresetValue<StoryIndexer[]>;
1250
+ /**
1251
+ * Process CSF files for the story index.
1252
+ */
1253
+ experimental_indexers?: PresetValue<Indexer[]>;
1173
1254
  /**
1174
1255
  * Docs related features in index generation
1175
1256
  */
package/dist/preset.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { P as PresetProperty, O as Options } from './index.d-d29054be.js';
1
+ import { P as PresetProperty, O as Options } from './index.d-62173427.js';
2
2
  import { TransformOptions } from '@babel/core';
3
3
  import { StorybookConfig } from './index.js';
4
4
  import 'file-system-cache';
package/dist/preview.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as Addon_DecoratorFunction } from './index.d-d29054be.js';
1
+ import { A as Addon_DecoratorFunction } from './index.d-62173427.js';
2
2
  import 'file-system-cache';
3
3
  import '@babel/core';
4
4
  import 'http';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/nextjs",
3
- "version": "7.2.0",
3
+ "version": "7.2.2-alpha.0",
4
4
  "description": "Storybook for Next.js",
5
5
  "keywords": [
6
6
  "storybook",
@@ -71,13 +71,13 @@
71
71
  "@babel/preset-react": "^7.22.5",
72
72
  "@babel/preset-typescript": "^7.22.5",
73
73
  "@babel/runtime": "^7.22.6",
74
- "@storybook/addon-actions": "7.2.0",
75
- "@storybook/builder-webpack5": "7.2.0",
76
- "@storybook/core-common": "7.2.0",
77
- "@storybook/node-logger": "7.2.0",
78
- "@storybook/preset-react-webpack": "7.2.0",
79
- "@storybook/preview-api": "7.2.0",
80
- "@storybook/react": "7.2.0",
74
+ "@storybook/addon-actions": "7.2.2-alpha.0",
75
+ "@storybook/builder-webpack5": "7.2.2-alpha.0",
76
+ "@storybook/core-common": "7.2.2-alpha.0",
77
+ "@storybook/node-logger": "7.2.2-alpha.0",
78
+ "@storybook/preset-react-webpack": "7.2.2-alpha.0",
79
+ "@storybook/preview-api": "7.2.2-alpha.0",
80
+ "@storybook/react": "7.2.2-alpha.0",
81
81
  "@types/node": "^16.0.0",
82
82
  "css-loader": "^6.7.3",
83
83
  "find-up": "^5.0.0",