@storybook/react-webpack5 7.2.3 → 7.3.0-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/dist/preset.d.ts +86 -2
  2. package/package.json +4 -4
package/dist/preset.d.ts CHANGED
@@ -720,11 +720,17 @@ PackageJson$1.NonStandardEntryPoints &
720
720
  PackageJson$1.TypeScriptConfiguration &
721
721
  PackageJson$1.YarnConfiguration &
722
722
  PackageJson$1.JSPMConfiguration;
723
+
724
+ type StoryId = string;
725
+ type ComponentTitle = string;
726
+ type StoryName = string;
723
727
  type Tag = string;
724
728
  interface Parameters {
725
729
  [name: string]: any;
726
730
  }
727
731
 
732
+ type ExportName = string;
733
+ type MetaId = string;
728
734
  interface StoriesSpecifier {
729
735
  /**
730
736
  * When auto-titling, what to prefix all generated titles with (default: '')
@@ -759,10 +765,83 @@ interface IndexedCSFFile {
759
765
  };
760
766
  stories: IndexedStory[];
761
767
  }
762
- interface StoryIndexer {
768
+ /**
769
+ * FIXME: This is a temporary type to allow us to deprecate the old indexer API.
770
+ * We should remove this type and the deprecated indexer API in 8.0.
771
+ */
772
+ type BaseIndexer = {
773
+ /**
774
+ * A regular expression that should match all files to be handled by this indexer
775
+ */
763
776
  test: RegExp;
777
+ };
778
+ /**
779
+ * An indexer describes which filenames it handles, and how to index each individual file - turning it into an entry in the index.
780
+ */
781
+ type Indexer = BaseIndexer & {
782
+ /**
783
+ * Indexes a file containing stories or docs.
784
+ * @param fileName The name of the file to index.
785
+ * @param options {@link IndexerOptions} for indexing the file.
786
+ * @returns A promise that resolves to an array of {@link IndexInput} objects.
787
+ */
788
+ index: (fileName: string, options: IndexerOptions) => Promise<IndexInput[]>;
789
+ /**
790
+ * @soonDeprecated Use {@link index} instead
791
+ */
792
+ indexer?: never;
793
+ };
794
+ type DeprecatedIndexer = BaseIndexer & {
764
795
  indexer: (fileName: string, options: IndexerOptions) => Promise<IndexedCSFFile>;
765
- }
796
+ index?: never;
797
+ };
798
+ /**
799
+ * @soonDeprecated Use {@link Indexer} instead
800
+ */
801
+ type StoryIndexer = Indexer | DeprecatedIndexer;
802
+ /**
803
+ * The base input for indexing a story or docs entry.
804
+ */
805
+ type BaseIndexInput = {
806
+ /** The file to import from e.g. the story file. */
807
+ importPath: Path;
808
+ /** The name of the export to import. */
809
+ exportName: ExportName;
810
+ /** The name of the entry, auto-generated from {@link exportName} if unspecified. */
811
+ name?: StoryName;
812
+ /** The location in the sidebar, auto-generated from {@link importPath} if unspecified. */
813
+ title?: ComponentTitle;
814
+ /**
815
+ * The custom id optionally set at `meta.id` if it needs to differ from the id generated via {@link title}.
816
+ * If unspecified, the meta id will be auto-generated from {@link title}.
817
+ * If specified, the meta in the CSF file _must_ have a matching id set at `meta.id`, to be correctly matched.
818
+ */
819
+ metaId?: MetaId;
820
+ /** Tags for filtering entries in Storybook and its tools. */
821
+ tags?: Tag[];
822
+ /**
823
+ * The id of the entry, auto-generated from {@link title}/{@link metaId} and {@link exportName} if unspecified.
824
+ * If specified, the story in the CSF file _must_ have a matching id set at `parameters.__id`, to be correctly matched.
825
+ * Only use this if you need to override the auto-generated id.
826
+ */
827
+ __id?: StoryId;
828
+ };
829
+ /**
830
+ * The input for indexing a story entry.
831
+ */
832
+ type StoryIndexInput = BaseIndexInput & {
833
+ type: 'story';
834
+ };
835
+ /**
836
+ * The input for indexing a docs entry.
837
+ */
838
+ type DocsIndexInput = BaseIndexInput & {
839
+ type: 'docs';
840
+ /** Paths to story files that must be pre-loaded for this docs entry. */
841
+ storiesImports?: Path[];
842
+ };
843
+ type IndexInput = StoryIndexInput | DocsIndexInput;
844
+ type Path = string;
766
845
 
767
846
  interface Options$1 {
768
847
  allowRegExp: boolean;
@@ -1038,8 +1117,13 @@ interface StorybookConfig {
1038
1117
  previewAnnotations?: PresetValue<Entry[]>;
1039
1118
  /**
1040
1119
  * Process CSF files for the story index.
1120
+ * @soonDeprecated use {@link experimental_indexers} instead
1041
1121
  */
1042
1122
  storyIndexers?: PresetValue<StoryIndexer[]>;
1123
+ /**
1124
+ * Process CSF files for the story index.
1125
+ */
1126
+ experimental_indexers?: PresetValue<Indexer[]>;
1043
1127
  /**
1044
1128
  * Docs related features in index generation
1045
1129
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react-webpack5",
3
- "version": "7.2.3",
3
+ "version": "7.3.0-alpha.0",
4
4
  "description": "Storybook for React: Develop React Component in isolation with Hot Reloading.",
5
5
  "keywords": [
6
6
  "storybook"
@@ -47,9 +47,9 @@
47
47
  "prep": "../../../scripts/prepare/bundle.ts"
48
48
  },
49
49
  "dependencies": {
50
- "@storybook/builder-webpack5": "7.2.3",
51
- "@storybook/preset-react-webpack": "7.2.3",
52
- "@storybook/react": "7.2.3",
50
+ "@storybook/builder-webpack5": "7.3.0-alpha.0",
51
+ "@storybook/preset-react-webpack": "7.3.0-alpha.0",
52
+ "@storybook/react": "7.3.0-alpha.0",
53
53
  "@types/node": "^16.0.0"
54
54
  },
55
55
  "devDependencies": {