@storybook/types 8.1.0-alpha.6 → 8.1.0-alpha.8

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 +129 -4
  2. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -1024,6 +1024,7 @@ interface StoryIdentifier {
1024
1024
  interface Parameters {
1025
1025
  [name: string]: any;
1026
1026
  }
1027
+ type ControlType = 'object' | 'boolean' | 'check' | 'inline-check' | 'radio' | 'inline-radio' | 'select' | 'multi-select' | 'number' | 'range' | 'file' | 'color' | 'date' | 'text';
1027
1028
  type ConditionalTest = {
1028
1029
  truthy?: boolean;
1029
1030
  } | {
@@ -1039,12 +1040,118 @@ type ConditionalValue = {
1039
1040
  global: string;
1040
1041
  };
1041
1042
  type Conditional = ConditionalValue & ConditionalTest;
1043
+ interface ControlBase {
1044
+ [key: string]: any;
1045
+ /**
1046
+ * @see https://storybook.js.org/docs/api/arg-types#controltype
1047
+ */
1048
+ type?: ControlType;
1049
+ disable?: boolean;
1050
+ }
1051
+ type Control = ControlType | false | (ControlBase & (ControlBase | {
1052
+ type: 'color';
1053
+ /**
1054
+ * @see https://storybook.js.org/docs/api/arg-types#controlpresetcolors
1055
+ */
1056
+ presetColors?: string[];
1057
+ } | {
1058
+ type: 'file';
1059
+ /**
1060
+ * @see https://storybook.js.org/docs/api/arg-types#controlaccept
1061
+ */
1062
+ accept?: string;
1063
+ } | {
1064
+ type: 'inline-check' | 'radio' | 'inline-radio' | 'select' | 'multi-select';
1065
+ /**
1066
+ * @see https://storybook.js.org/docs/api/arg-types#controllabels
1067
+ */
1068
+ labels?: {
1069
+ [options: string]: string;
1070
+ };
1071
+ } | {
1072
+ type: 'number' | 'range';
1073
+ /**
1074
+ * @see https://storybook.js.org/docs/api/arg-types#controlmax
1075
+ */
1076
+ max?: number;
1077
+ /**
1078
+ * @see https://storybook.js.org/docs/api/arg-types#controlmin
1079
+ */
1080
+ min?: number;
1081
+ /**
1082
+ * @see https://storybook.js.org/docs/api/arg-types#controlstep
1083
+ */
1084
+ step?: number;
1085
+ }));
1042
1086
  interface InputType {
1043
- name?: string;
1087
+ /**
1088
+ * @see https://storybook.js.org/docs/api/arg-types#control
1089
+ */
1090
+ control?: Control;
1091
+ /**
1092
+ * @see https://storybook.js.org/docs/api/arg-types#description
1093
+ */
1044
1094
  description?: string;
1045
- defaultValue?: any;
1046
- type?: SBType | SBScalarType['name'];
1095
+ /**
1096
+ * @see https://storybook.js.org/docs/api/arg-types#if
1097
+ */
1047
1098
  if?: Conditional;
1099
+ /**
1100
+ * @see https://storybook.js.org/docs/api/arg-types#mapping
1101
+ */
1102
+ mapping?: {
1103
+ [key: string]: any;
1104
+ };
1105
+ /**
1106
+ * @see https://storybook.js.org/docs/api/arg-types#name
1107
+ */
1108
+ name?: string;
1109
+ /**
1110
+ * @see https://storybook.js.org/docs/api/arg-types#options
1111
+ */
1112
+ options?: readonly any[];
1113
+ /**
1114
+ * @see https://storybook.js.org/docs/api/arg-types#table
1115
+ */
1116
+ table?: {
1117
+ [key: string]: unknown;
1118
+ /**
1119
+ * @see https://storybook.js.org/docs/api/arg-types#tablecategory
1120
+ */
1121
+ category?: string;
1122
+ /**
1123
+ * @see https://storybook.js.org/docs/api/arg-types#tabledefaultvalue
1124
+ */
1125
+ defaultValue?: {
1126
+ summary?: string;
1127
+ detail?: string;
1128
+ };
1129
+ /**
1130
+ * @see https://storybook.js.org/docs/api/arg-types#tabledisable
1131
+ */
1132
+ disable?: boolean;
1133
+ /**
1134
+ * @see https://storybook.js.org/docs/api/arg-types#tablesubcategory
1135
+ */
1136
+ subcategory?: string;
1137
+ /**
1138
+ * @see https://storybook.js.org/docs/api/arg-types#tabletype
1139
+ */
1140
+ type?: {
1141
+ summary?: string;
1142
+ detail?: string;
1143
+ };
1144
+ };
1145
+ /**
1146
+ * @see https://storybook.js.org/docs/api/arg-types#type
1147
+ */
1148
+ type?: SBType | SBScalarType['name'];
1149
+ /**
1150
+ * @see https://storybook.js.org/docs/api/arg-types#defaultvalue
1151
+ *
1152
+ * @deprecated Use `table.defaultValue.summary` instead.
1153
+ */
1154
+ defaultValue?: any;
1048
1155
  [key: string]: any;
1049
1156
  }
1050
1157
  interface StrictInputType extends InputType {
@@ -1057,6 +1164,9 @@ interface Args {
1057
1164
  interface StrictArgs {
1058
1165
  [name: string]: unknown;
1059
1166
  }
1167
+ /**
1168
+ * @see https://storybook.js.org/docs/api/arg-types#argtypes
1169
+ */
1060
1170
  type ArgTypes<TArgs = Args> = {
1061
1171
  [name in keyof TArgs]: InputType;
1062
1172
  };
@@ -1108,6 +1218,9 @@ interface StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs =
1108
1218
  originalStoryFn: StoryFn<TRenderer>;
1109
1219
  }
1110
1220
  type LoaderFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContextForLoaders<TRenderer, TArgs>) => Promise<Record<string, any> | void> | Record<string, any> | void;
1221
+ type Awaitable<T> = T | PromiseLike<T>;
1222
+ type CleanupCallback = () => Awaitable<unknown>;
1223
+ type BeforeEach<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContext<TRenderer, TArgs>) => Awaitable<CleanupCallback | void>;
1111
1224
  interface StoryContext<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryContextForLoaders<TRenderer, TArgs> {
1112
1225
  loaded: Record<string, any>;
1113
1226
  abortSignal: AbortSignal;
@@ -1156,6 +1269,15 @@ type BaseAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> = {
1156
1269
  * @see [Loaders](https://storybook.js.org/docs/react/writing-stories/loaders)
1157
1270
  */
1158
1271
  loaders?: LoaderFunction<TRenderer, TArgs>[] | LoaderFunction<TRenderer, TArgs>;
1272
+ /**
1273
+ * Function to be called before each story. When the function is async, it will be awaited.
1274
+ *
1275
+ * `beforeEach` can be added to preview, the default export and to a specific story.
1276
+ * They are run (and awaited) in the order: preview, default export, story
1277
+ *
1278
+ * A cleanup function can be returned.
1279
+ */
1280
+ beforeEach?: BeforeEach<TRenderer, TArgs>[] | BeforeEach<TRenderer, TArgs>;
1159
1281
  /**
1160
1282
  * Define a custom render function for the story(ies). If not passed, a default render function by the renderer will be used.
1161
1283
  */
@@ -2857,6 +2979,7 @@ type PreparedStory<TRenderer extends Renderer = Renderer> = StoryContextForEnhan
2857
2979
  applyLoaders: (context: StoryContextForLoaders<TRenderer>) => Promise<StoryContextForLoaders<TRenderer> & {
2858
2980
  loaded: StoryContext<TRenderer>['loaded'];
2859
2981
  }>;
2982
+ applyBeforeEach: (context: StoryContext<TRenderer>) => Promise<CleanupCallback[]>;
2860
2983
  playFunction?: (context: StoryContext<TRenderer>) => Promise<void> | void;
2861
2984
  };
2862
2985
  type PreparedMeta<TRenderer extends Renderer = Renderer> = Omit<StoryContextForEnhancers<TRenderer>, 'name' | 'story'> & {
@@ -3012,4 +3135,6 @@ interface ComposeStoryFn<TRenderer extends Renderer = Renderer, TArgs extends Ar
3012
3135
 
3013
3136
  type SupportedFrameworks = 'angular' | 'ember' | 'html-vite' | 'html-webpack5' | 'nextjs' | 'preact-vite' | 'preact-webpack5' | 'react-vite' | 'react-webpack5' | 'server-webpack5' | 'svelte-vite' | 'svelte-webpack5' | 'sveltekit' | 'vue3-vite' | 'vue3-webpack5' | 'web-components-vite' | 'web-components-webpack5' | 'qwik' | 'solid';
3014
3137
 
3015
- export { API_ActiveTabsType, API_BaseEntry, API_ComponentEntry, API_ComposedRef, API_ComposedRefUpdate, API_DocsEntry, API_FilterFunction, API_GroupEntry, API_HashEntry, API_IframeRenderer, API_IndexHash, API_Layout, API_LeafEntry, API_LoadedRefData, API_MatchOptions, API_Notification, API_OptionsData, API_PanelPositions, API_PreparedIndexEntry, API_PreparedStoryIndex, API_Provider, API_ProviderData, API_RefId, API_RefUrl, API_Refs, API_ReleaseNotes, API_RenderOptions, API_RootEntry, API_RouteOptions, API_SetRefData, API_Settings, API_SidebarOptions, API_StateMerger, API_StatusObject, API_StatusState, API_StatusUpdate, API_StatusValue, 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_SidebarBottomType, Addon_SidebarTopType, 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, ComposedStoryPlayFn, Conditional, CoreCommon_AddonEntry, CoreCommon_AddonInfo, CoreCommon_OptionsEntry, CoreCommon_ResolvedAddonPreset, CoreCommon_ResolvedAddonVirtual, CoreCommon_StorybookInfo, CoreConfig, DecoratorApplicator, DecoratorFunction, 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, NamedOrDefaultProjectAnnotations, NormalizedComponentAnnotations, NormalizedProjectAnnotations, NormalizedStoriesSpecifier, NormalizedStoryAnnotations, Options, PackageJson, Parameters, PartialArgsStoryFn, PartialStoryFn, Path, PlayFunction, PlayFunctionContext, PreparedMeta, PreparedStory, Preset, PresetConfig, PresetProperty, PresetPropertyFn, PresetValue, Presets, PreviewAnnotation, ProjectAnnotations, 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, StoryKind, StoryName, StoryPreparedPayload, StoryRenderOptions, StorybookConfig, StorybookConfigOptions, StorybookConfigRaw, StorybookInternalParameters, StorybookParameters, StrictArgTypes, StrictArgs, StrictGlobalTypes, StrictInputType, SupportedFrameworks, Tag$1 as Tag, TagOptions, TagsOptions, TeardownRenderToCanvas, TestBuildConfig, TestBuildFlags, TypescriptOptions, V3CompatIndexEntry, VersionCheck, ViewMode, WebRenderer };
3138
+ type SupportedRenderers = 'react' | 'react-native' | 'vue3' | 'angular' | 'ember' | 'preact' | 'svelte' | 'qwik' | 'html' | 'web-components' | 'server' | 'solid';
3139
+
3140
+ export { API_ActiveTabsType, API_BaseEntry, API_ComponentEntry, API_ComposedRef, API_ComposedRefUpdate, API_DocsEntry, API_FilterFunction, API_GroupEntry, API_HashEntry, API_IframeRenderer, API_IndexHash, API_Layout, API_LeafEntry, API_LoadedRefData, API_MatchOptions, API_Notification, API_OptionsData, API_PanelPositions, API_PreparedIndexEntry, API_PreparedStoryIndex, API_Provider, API_ProviderData, API_RefId, API_RefUrl, API_Refs, API_ReleaseNotes, API_RenderOptions, API_RootEntry, API_RouteOptions, API_SetRefData, API_Settings, API_SidebarOptions, API_StateMerger, API_StatusObject, API_StatusState, API_StatusUpdate, API_StatusValue, 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_SidebarBottomType, Addon_SidebarTopType, 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, ComposedStoryPlayFn, Conditional, CoreCommon_AddonEntry, CoreCommon_AddonInfo, CoreCommon_OptionsEntry, CoreCommon_ResolvedAddonPreset, CoreCommon_ResolvedAddonVirtual, CoreCommon_StorybookInfo, CoreConfig, DecoratorApplicator, DecoratorFunction, 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, NamedOrDefaultProjectAnnotations, NormalizedComponentAnnotations, NormalizedProjectAnnotations, NormalizedStoriesSpecifier, NormalizedStoryAnnotations, Options, PackageJson, Parameters, PartialArgsStoryFn, PartialStoryFn, Path, PlayFunction, PlayFunctionContext, PreparedMeta, PreparedStory, Preset, PresetConfig, PresetProperty, PresetPropertyFn, PresetValue, Presets, PreviewAnnotation, ProjectAnnotations, 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, StoryKind, StoryName, StoryPreparedPayload, StoryRenderOptions, StorybookConfig, StorybookConfigOptions, StorybookConfigRaw, StorybookInternalParameters, StorybookParameters, StrictArgTypes, StrictArgs, StrictGlobalTypes, StrictInputType, SupportedFrameworks, SupportedRenderers, Tag$1 as Tag, TagOptions, TagsOptions, TeardownRenderToCanvas, TestBuildConfig, TestBuildFlags, TypescriptOptions, V3CompatIndexEntry, VersionCheck, ViewMode, WebRenderer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/types",
3
- "version": "8.1.0-alpha.6",
3
+ "version": "8.1.0-alpha.8",
4
4
  "description": "Core Storybook TS Types",
5
5
  "keywords": [
6
6
  "storybook"
@@ -44,12 +44,12 @@
44
44
  "prep": "node --loader ../../../scripts/node_modules/esbuild-register/loader.js -r ../../../scripts/node_modules/esbuild-register/register.js ../../../scripts/prepare/bundle.ts"
45
45
  },
46
46
  "dependencies": {
47
- "@storybook/channels": "8.1.0-alpha.6",
47
+ "@storybook/channels": "8.1.0-alpha.8",
48
48
  "@types/express": "^4.7.0",
49
49
  "file-system-cache": "2.3.0"
50
50
  },
51
51
  "devDependencies": {
52
- "@storybook/csf": "^0.1.2",
52
+ "@storybook/csf": "^0.1.6",
53
53
  "@types/fs-extra": "^11.0.1",
54
54
  "@types/node": "^18.0.0",
55
55
  "typescript": "^5.3.2"