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