Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@storybook/preview-api

Package Overview
Dependencies
Maintainers
31
Versions
811
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storybook/preview-api - npm Package Compare versions

Comparing version 7.1.0-alpha.25 to 7.1.0-alpha.26

dist/chunk-LM32OG2X.mjs

34

dist/addons.d.ts

@@ -1,4 +0,32 @@

export { A as AddonStore, c as MakeDecoratorOptions, M as MakeDecoratorResult, a as addons, m as makeDecorator, b as mockChannel } from './storybook-channel-mock-a19cd233.js';
import { Channel } from '@storybook/channels';
export { E as EventMap, H as HooksContext, L as Listener, k as applyHooks, u as useArgs, a as useCallback, b as useChannel, c as useEffect, d as useGlobals, e as useMemo, f as useParameter, g as useReducer, h as useRef, i as useState, j as useStoryContext } from './hooks-54408da1.js';
import '@storybook/channels';
import '@storybook/types';
import { Addon_StoryWrapper } from '@storybook/types';
declare class AddonStore {
constructor();
private channel;
private serverChannel;
private promise;
private resolve;
getChannel: () => Channel;
getServerChannel: () => Channel;
ready: () => Promise<Channel>;
hasChannel: () => boolean;
hasServerChannel: () => boolean;
setChannel: (channel: Channel) => void;
setServerChannel: (channel: Channel) => void;
}
declare const addons: AddonStore;
type MakeDecoratorResult = (...args: any) => any;
interface MakeDecoratorOptions {
name: string;
parameterName: string;
skipIfNoParametersOrOptions?: boolean;
wrapper: Addon_StoryWrapper;
}
declare const makeDecorator: ({ name, parameterName, wrapper, skipIfNoParametersOrOptions, }: MakeDecoratorOptions) => MakeDecoratorResult;
declare function mockChannel(): Channel;
export { AddonStore, MakeDecoratorOptions, MakeDecoratorResult, addons, makeDecorator, mockChannel };

2

dist/client-api.d.ts
export { C as ClientApi, a as addArgTypes, b as addArgTypesEnhancer, c as addArgs, d as addArgsEnhancer, e as addDecorator, f as addLoader, g as addParameters, h as addStepRunner, s as setGlobalRender } from './ClientApi-f0ab636b.js';
export { S as StoryStore, c as prepareContext, a as prepareMeta, p as prepareStory, b as processCSFFile } from './StoryStore-7c60406e.js';
export { D as DEEPLY_EQUAL, P as PropDescriptor, U as UNTARGETED, c as combineArgs, a as combineParameters, b as composeStepRunners, d as composeStories, e as composeStory, f as decorateStory, o as deepDiff, g as defaultDecorateStory, h as filterArgTypes, p as groupArgsByTarget, j as inferControls, m as mapArgsToTypes, q as noTargetArgs, n as normalizeStory, s as sanitizeStoryContextUpdate, i as setProjectAnnotations, r as sortStoriesV6, l as sortStoriesV7, k as userOrAutoTitle, u as userOrAutoTitleFromSpecifier, v as validateOptions } from './sortStories-243da0ce.js';
export { g as getValuesFromArgTypes, b as normalizeComponentAnnotations, n as normalizeInputType, a as normalizeInputTypes, c as normalizeProjectAnnotations, d as useAddonState, u as useSharedState } from './hooks-0a0ec0e3.js';
export { getValuesFromArgTypes, normalizeComponentAnnotations, normalizeInputType, normalizeInputTypes, normalizeProjectAnnotations, useAddonState, useSharedState } from './store.js';
export { c as composeConfigs, a as getArrayField, g as getField, b as getObjectField, d as getSingletonField } from './composeConfigs-62a04721.js';

@@ -6,0 +6,0 @@ export { g as getQueryParam, a as getQueryParams } from './queryparams-d12445b8.js';

@@ -1,6 +0,22 @@

export { C as ClientApi } from './ClientApi-f0ab636b.js';
import { C as ClientApi } from './ClientApi-f0ab636b.js';
export { S as StoryStore } from './StoryStore-7c60406e.js';
export { s as start } from './start-94318c67.js';
import '@storybook/types';
import { Renderer, ProjectAnnotations, ArgsStoryFn } from '@storybook/types';
import 'synchronous-promise';
import './hooks-54408da1.js';
interface CoreClient_RendererImplementation<TRenderer extends Renderer> {
decorateStory?: ProjectAnnotations<TRenderer>['applyDecorators'];
render?: ArgsStoryFn<TRenderer>;
}
interface CoreClient_ClientAPIFacade {
storiesOf: (...args: any[]) => never;
raw: (...args: any[]) => never;
}
interface CoreClient_StartReturnValue<TRenderer extends Renderer> {
forceReRender: () => void;
configure: any;
clientApi: ClientApi<TRenderer> | CoreClient_ClientAPIFacade;
}
declare function start<TRenderer extends Renderer>(renderToCanvas: ProjectAnnotations<TRenderer>['renderToCanvas'], { decorateStory, render }?: CoreClient_RendererImplementation<TRenderer>): CoreClient_StartReturnValue<TRenderer>;
export { ClientApi, start };

@@ -1,2 +0,2 @@

export { a as addons, m as makeDecorator, b as mockChannel } from './storybook-channel-mock-a19cd233.js';
export { addons, makeDecorator, mockChannel } from './addons.js';
export { H as HooksContext, k as applyHooks, u as useArgs, a as useCallback, b as useChannel, c as useEffect, d as useGlobals, e as useMemo, f as useParameter, g as useReducer, h as useRef, i as useState, j as useStoryContext } from './hooks-54408da1.js';

@@ -6,6 +6,6 @@ export { S as StoryStore, a as prepareMeta, p as prepareStory } from './StoryStore-7c60406e.js';

export { c as composeConfigs } from './composeConfigs-62a04721.js';
export { D as DocsContext, P as Preview, b as PreviewWeb, a as simulateDOMContentLoaded, s as simulatePageLoad } from './simulate-pageload-b0ec9a10.js';
export { DocsContext, Preview, PreviewWeb, simulateDOMContentLoaded, simulatePageLoad } from './preview-web.js';
export { C as ClientApi, a as addArgTypes, b as addArgTypesEnhancer, c as addArgs, d as addArgsEnhancer, e as addDecorator, f as addLoader, g as addParameters, h as addStepRunner, s as setGlobalRender } from './ClientApi-f0ab636b.js';
export { g as getQueryParam, a as getQueryParams } from './queryparams-d12445b8.js';
export { s as start } from './start-94318c67.js';
export { start } from './core-client.js';
import '@storybook/channels';

@@ -12,0 +12,0 @@ import '@storybook/types';

@@ -0,7 +1,333 @@

import * as _storybook_types from '@storybook/types';
import { Renderer, StoryId, StoryRenderOptions, ViewMode, PreparedStory, RenderToCanvas, RenderContextCallbacks, DocsContextProps, CSFFile, ModuleExports, ResolvedModuleExportType, ModuleExport, ResolvedModuleExportFromType, StoryName, StoryContextForLoaders, IndexEntry, StoryIndex, ModuleImportFn, ProjectAnnotations, Globals, Args } from '@storybook/types';
export { DocsContextProps, DocsRenderFunction, ProjectAnnotations as WebProjectAnnotations } from '@storybook/types';
export { c as composeConfigs } from './composeConfigs-62a04721.js';
export { D as DocsContext, P as Preview, b as PreviewWeb, c as PreviewWithSelection, a as simulateDOMContentLoaded, s as simulatePageLoad } from './simulate-pageload-b0ec9a10.js';
import '@storybook/channels';
import './StoryStore-7c60406e.js';
import { Channel } from '@storybook/channels';
import { S as StoryStore, d as StorySpecifier } from './StoryStore-7c60406e.js';
import 'synchronous-promise';
import './hooks-54408da1.js';
type RenderType = 'story' | 'docs';
/**
* A "Render" represents the rendering of a single entry to a single location
*
* The implemenations of render are used for two key purposes:
* - Tracking the state of the rendering as it moves between preparing, rendering and tearing down.
* - Tracking what is rendered to know if a change requires re-rendering or teardown + recreation.
*/
interface Render<TRenderer extends Renderer> {
type: RenderType;
id: StoryId;
isPreparing: () => boolean;
isEqual: (other: Render<TRenderer>) => boolean;
disableKeyListeners: boolean;
teardown?: (options: {
viewModeChanged: boolean;
}) => Promise<void>;
torndown: boolean;
renderToElement: (canvasElement: TRenderer['canvasElement'], renderStoryToElement?: any, options?: StoryRenderOptions) => Promise<void>;
}
type RenderPhase = 'preparing' | 'loading' | 'rendering' | 'playing' | 'played' | 'completed' | 'aborted' | 'errored';
declare class StoryRender<TRenderer extends Renderer> implements Render<TRenderer> {
channel: Channel;
store: StoryStore<TRenderer>;
private renderToScreen;
private callbacks;
id: StoryId;
viewMode: ViewMode;
renderOptions: StoryRenderOptions;
type: RenderType;
story?: PreparedStory<TRenderer>;
phase?: RenderPhase;
private abortController?;
private canvasElement?;
private notYetRendered;
disableKeyListeners: boolean;
private teardownRender;
torndown: boolean;
constructor(channel: Channel, store: StoryStore<TRenderer>, renderToScreen: RenderToCanvas<TRenderer>, callbacks: RenderContextCallbacks<TRenderer>, id: StoryId, viewMode: ViewMode, renderOptions?: StoryRenderOptions, story?: PreparedStory<TRenderer>);
private runPhase;
prepare(): Promise<void>;
isEqual(other: Render<TRenderer>): boolean;
isPreparing(): boolean;
isPending(): boolean;
renderToElement(canvasElement: TRenderer['canvasElement']): Promise<void>;
private storyContext;
render({ initial, forceRemount, }?: {
initial?: boolean;
forceRemount?: boolean;
}): Promise<void>;
rerender(): Promise<void>;
remount(): Promise<void>;
cancelRender(): void;
teardown(): Promise<void>;
}
declare class DocsContext<TRenderer extends Renderer> implements DocsContextProps<TRenderer> {
channel: Channel;
protected store: StoryStore<TRenderer>;
renderStoryToElement: DocsContextProps['renderStoryToElement'];
private componentStoriesValue;
private storyIdToCSFFile;
private exportToStory;
private exportsToCSFFile;
private nameToStoryId;
private attachedCSFFile?;
private primaryStory?;
constructor(channel: Channel, store: StoryStore<TRenderer>, renderStoryToElement: DocsContextProps['renderStoryToElement'],
/** The CSF files known (via the index) to be refererenced by this docs file */
csfFiles: CSFFile<TRenderer>[]);
referenceCSFFile(csfFile: CSFFile<TRenderer>): void;
attachCSFFile(csfFile: CSFFile<TRenderer>): void;
referenceMeta(metaExports: ModuleExports, attach: boolean): void;
get projectAnnotations(): _storybook_types.NormalizedProjectAnnotations<TRenderer>;
private resolveAttachedModuleExportType;
private resolveModuleExport;
resolveOf<TType extends ResolvedModuleExportType>(moduleExportOrType: ModuleExport | TType, validTypes?: TType[]): ResolvedModuleExportFromType<TType, TRenderer>;
storyIdByName: (storyName: StoryName) => string;
componentStories: () => PreparedStory<TRenderer>[];
storyById: (storyId?: StoryId) => PreparedStory<TRenderer>;
getStoryContext: (story: PreparedStory<TRenderer>) => StoryContextForLoaders<TRenderer>;
loadStory: (id: StoryId) => Promise<PreparedStory<TRenderer>>;
}
/**
* A CsfDocsRender is a render of a docs entry that is rendered based on a CSF file.
*
* The expectation is the primary CSF file which is the `importPath` for the entry will
* define a story which may contain the actual rendered JSX code for the template in the
* `docs.page` parameter.
*
* Use cases:
* - Autodocs, where there is no story, and we fall back to the globally defined template.
* - *.stories.mdx files, where the MDX compiler produces a CSF file with a `.parameter.docs.page`
* parameter containing the compiled content of the MDX file.
*/
declare class CsfDocsRender<TRenderer extends Renderer> implements Render<TRenderer> {
protected channel: Channel;
protected store: StoryStore<TRenderer>;
entry: IndexEntry;
private callbacks;
readonly type: RenderType;
readonly subtype = "csf";
readonly id: StoryId;
story?: PreparedStory<TRenderer>;
rerender?: () => Promise<void>;
teardownRender?: (options: {
viewModeChanged?: boolean;
}) => Promise<void>;
torndown: boolean;
readonly disableKeyListeners = false;
preparing: boolean;
csfFiles?: CSFFile<TRenderer>[];
constructor(channel: Channel, store: StoryStore<TRenderer>, entry: IndexEntry, callbacks: RenderContextCallbacks<TRenderer>);
isPreparing(): boolean;
prepare(): Promise<void>;
isEqual(other: Render<TRenderer>): boolean;
docsContext(renderStoryToElement: DocsContextProps['renderStoryToElement']): DocsContext<TRenderer>;
renderToElement(canvasElement: TRenderer['canvasElement'], renderStoryToElement: DocsContextProps['renderStoryToElement']): Promise<void>;
teardown({ viewModeChanged }?: {
viewModeChanged?: boolean;
}): Promise<void>;
}
/**
* A MdxDocsRender is a render of a docs entry that comes from a true MDX file,
* that is a `.mdx` file that doesn't get compiled to a CSF file.
*
* A MDX render can reference (import) zero or more CSF files that contain stories.
*
* Use cases:
* - *.mdx file that may or may not reference a specific CSF file with `<Meta of={} />`
*/
declare class MdxDocsRender<TRenderer extends Renderer> implements Render<TRenderer> {
protected channel: Channel;
protected store: StoryStore<TRenderer>;
entry: IndexEntry;
private callbacks;
readonly type: RenderType;
readonly subtype = "mdx";
readonly id: StoryId;
private exports?;
rerender?: () => Promise<void>;
teardownRender?: (options: {
viewModeChanged?: boolean;
}) => Promise<void>;
torndown: boolean;
readonly disableKeyListeners = false;
preparing: boolean;
csfFiles?: CSFFile<TRenderer>[];
constructor(channel: Channel, store: StoryStore<TRenderer>, entry: IndexEntry, callbacks: RenderContextCallbacks<TRenderer>);
isPreparing(): boolean;
prepare(): Promise<void>;
isEqual(other: Render<TRenderer>): boolean;
docsContext(renderStoryToElement: DocsContextProps['renderStoryToElement']): DocsContext<TRenderer>;
renderToElement(canvasElement: TRenderer['canvasElement'], renderStoryToElement: DocsContextProps['renderStoryToElement']): Promise<void>;
teardown({ viewModeChanged }?: {
viewModeChanged?: boolean;
}): Promise<void>;
}
type MaybePromise<T> = Promise<T> | T;
declare class Preview<TRenderer extends Renderer> {
protected channel: Channel;
serverChannel?: Channel;
storyStore: StoryStore<TRenderer>;
getStoryIndex?: () => StoryIndex;
importFn?: ModuleImportFn;
renderToCanvas?: RenderToCanvas<TRenderer>;
storyRenders: StoryRender<TRenderer>[];
previewEntryError?: Error;
constructor(channel?: Channel);
initialize({ getStoryIndex, importFn, getProjectAnnotations, }: {
getStoryIndex?: () => StoryIndex;
importFn: ModuleImportFn;
getProjectAnnotations: () => MaybePromise<ProjectAnnotations<TRenderer>>;
}): Promise<void>;
setupListeners(): void;
getProjectAnnotationsOrRenderError(getProjectAnnotations: () => MaybePromise<ProjectAnnotations<TRenderer>>): Promise<ProjectAnnotations<TRenderer>>;
initializeWithProjectAnnotations(projectAnnotations: ProjectAnnotations<TRenderer>): Promise<void>;
setInitialGlobals(): Promise<void>;
emitGlobals(): void;
getStoryIndexFromServer(): Promise<StoryIndex>;
initializeWithStoryIndex(storyIndex: StoryIndex): PromiseLike<void>;
onGetProjectAnnotationsChanged({ getProjectAnnotations, }: {
getProjectAnnotations: () => MaybePromise<ProjectAnnotations<TRenderer>>;
}): Promise<void>;
onStoryIndexChanged(): Promise<void>;
onStoriesChanged({ importFn, storyIndex, }: {
importFn?: ModuleImportFn;
storyIndex?: StoryIndex;
}): Promise<void>;
onUpdateGlobals({ globals }: {
globals: Globals;
}): Promise<void>;
onUpdateArgs({ storyId, updatedArgs }: {
storyId: StoryId;
updatedArgs: Args;
}): Promise<void>;
onResetArgs({ storyId, argNames }: {
storyId: string;
argNames?: string[];
}): Promise<void>;
onForceReRender(): Promise<void>;
onForceRemount({ storyId }: {
storyId: StoryId;
}): Promise<void>;
renderStoryToElement(story: PreparedStory<TRenderer>, element: TRenderer['canvasElement'], callbacks: RenderContextCallbacks<TRenderer>, options: StoryRenderOptions): () => Promise<void>;
teardownRender(render: StoryRender<TRenderer> | CsfDocsRender<TRenderer> | MdxDocsRender<TRenderer>, { viewModeChanged }?: {
viewModeChanged?: boolean;
}): Promise<void>;
extract(options?: {
includeDocsOnly: boolean;
}): Promise<Record<string, _storybook_types.StoryContextForEnhancers<TRenderer>>>;
renderPreviewEntryError(reason: string, err: Error): void;
}
interface SelectionSpecifier {
storySpecifier: StorySpecifier;
viewMode: ViewMode;
args?: Args;
globals?: Args;
}
interface Selection {
storyId: StoryId;
viewMode: ViewMode;
}
interface SelectionStore {
selectionSpecifier: SelectionSpecifier | null;
selection?: Selection;
setSelection(selection: Selection): void;
setQueryParams(queryParams: qs.ParsedQs): void;
}
interface View<TStorybookRoot> {
prepareForStory(story: PreparedStory<any>): TStorybookRoot;
prepareForDocs(): TStorybookRoot;
showErrorDisplay(err: {
message?: string;
stack?: string;
}): void;
showNoPreview(): void;
showPreparingStory(options?: {
immediate: boolean;
}): void;
showPreparingDocs(options?: {
immediate: boolean;
}): void;
showMain(): void;
showDocs(): void;
showStory(): void;
showStoryDuringRender(): void;
}
type PossibleRender<TFramework extends Renderer> = StoryRender<TFramework> | CsfDocsRender<TFramework> | MdxDocsRender<TFramework>;
declare class PreviewWithSelection<TFramework extends Renderer> extends Preview<TFramework> {
selectionStore: SelectionStore;
view: View<TFramework['canvasElement']>;
currentSelection?: Selection;
currentRender?: PossibleRender<TFramework>;
constructor(selectionStore: SelectionStore, view: View<TFramework['canvasElement']>);
setupListeners(): void;
setInitialGlobals(): Promise<void>;
initializeWithStoryIndex(storyIndex: StoryIndex): PromiseLike<void>;
selectSpecifiedStory(): Promise<void>;
onGetProjectAnnotationsChanged({ getProjectAnnotations, }: {
getProjectAnnotations: () => MaybePromise<ProjectAnnotations<TFramework>>;
}): Promise<void>;
onStoriesChanged({ importFn, storyIndex, }: {
importFn?: ModuleImportFn;
storyIndex?: StoryIndex;
}): Promise<void>;
onKeydown(event: KeyboardEvent): void;
onSetCurrentStory(selection: {
storyId: StoryId;
viewMode?: ViewMode;
}): Promise<void>;
onUpdateQueryParams(queryParams: any): void;
onUpdateGlobals({ globals }: {
globals: Globals;
}): Promise<void>;
onUpdateArgs({ storyId, updatedArgs }: {
storyId: StoryId;
updatedArgs: Args;
}): Promise<void>;
onPreloadStories({ ids }: {
ids: string[];
}): Promise<void>;
renderSelection({ persistedArgs }?: {
persistedArgs?: Args;
}): Promise<void>;
teardownRender(render: PossibleRender<TFramework>, { viewModeChanged }?: {
viewModeChanged?: boolean;
}): Promise<void>;
extract(options?: {
includeDocsOnly: boolean;
}): Promise<Record<string, _storybook_types.StoryContextForEnhancers<TFramework>>>;
mainStoryCallbacks(storyId: StoryId): {
showMain: () => void;
showError: (err: {
title: string;
description: string;
}) => void;
showException: (err: Error) => void;
};
renderPreviewEntryError(reason: string, err: Error): void;
renderMissingStory(): void;
renderStoryLoadingException(storySpecifier: StorySpecifier, err: Error): void;
renderException(storyId: StoryId, error: Error): void;
renderError(storyId: StoryId, { title, description }: {
title: string;
description: string;
}): void;
}
declare class PreviewWeb<TFramework extends Renderer> extends PreviewWithSelection<TFramework> {
constructor();
}
declare function simulateDOMContentLoaded(): void;
declare function simulatePageLoad($container: any): void;
export { DocsContext, Preview, PreviewWeb, PreviewWithSelection, simulateDOMContentLoaded, simulatePageLoad };
export { S as StoryStore, c as prepareContext, a as prepareMeta, p as prepareStory, b as processCSFFile } from './StoryStore-7c60406e.js';
export { D as DEEPLY_EQUAL, P as PropDescriptor, U as UNTARGETED, c as combineArgs, a as combineParameters, b as composeStepRunners, d as composeStories, e as composeStory, f as decorateStory, o as deepDiff, g as defaultDecorateStory, h as filterArgTypes, p as groupArgsByTarget, j as inferControls, m as mapArgsToTypes, q as noTargetArgs, n as normalizeStory, s as sanitizeStoryContextUpdate, i as setProjectAnnotations, r as sortStoriesV6, l as sortStoriesV7, k as userOrAutoTitle, u as userOrAutoTitleFromSpecifier, v as validateOptions } from './sortStories-243da0ce.js';
export { g as getValuesFromArgTypes, b as normalizeComponentAnnotations, n as normalizeInputType, a as normalizeInputTypes, c as normalizeProjectAnnotations, d as useAddonState, u as useSharedState } from './hooks-0a0ec0e3.js';
import * as _storybook_types from '@storybook/types';
import { InputType, StrictInputType, ArgTypes, GlobalTypes, StrictArgTypes, StrictGlobalTypes, Renderer, ModuleExports, NormalizedComponentAnnotations, ProjectAnnotations, NormalizedProjectAnnotations } from '@storybook/types';
export { c as composeConfigs, a as getArrayField, g as getField, b as getObjectField, d as getSingletonField } from './composeConfigs-62a04721.js';
export { H as HooksContext, k as applyHooks, u as useArgs, a as useCallback, b as useChannel, c as useEffect, d as useGlobals, e as useMemo, f as useParameter, g as useReducer, h as useRef, i as useState, j as useStoryContext } from './hooks-54408da1.js';
import '@storybook/types';
import 'synchronous-promise';
declare const normalizeInputType: (inputType: InputType, key: string) => StrictInputType;
declare const normalizeInputTypes: (inputTypes: ArgTypes | GlobalTypes) => StrictArgTypes | StrictGlobalTypes;
declare function normalizeComponentAnnotations<TRenderer extends Renderer>(defaultExport: ModuleExports['default'], title?: string, importPath?: string): NormalizedComponentAnnotations<TRenderer>;
declare function normalizeProjectAnnotations<TRenderer extends Renderer>({ argTypes, globalTypes, argTypesEnhancers, ...annotations }: ProjectAnnotations<TRenderer>): NormalizedProjectAnnotations<TRenderer>;
declare const getValuesFromArgTypes: (argTypes?: ArgTypes) => ArgTypes<_storybook_types.Args>;
declare function useSharedState<S>(sharedId: string, defaultState?: S): [S, (s: S) => void];
declare function useAddonState<S>(addonId: string, defaultState?: S): [S, (s: S) => void];
export { getValuesFromArgTypes, normalizeComponentAnnotations, normalizeInputType, normalizeInputTypes, normalizeProjectAnnotations, useAddonState, useSharedState };

@@ -29,3 +29,3 @@ "use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var store_exports={};__export(store_exports,{DEEPLY_EQUAL:()=>DEEPLY_EQUAL,HooksContext:()=>HooksContext,StoryStore:()=>StoryStore,UNTARGETED:()=>UNTARGETED,applyHooks:()=>applyHooks,combineArgs:()=>combineArgs,combineParameters:()=>combineParameters,composeConfigs:()=>composeConfigs,composeStepRunners:()=>composeStepRunners,composeStories:()=>composeStories,composeStory:()=>composeStory,decorateStory:()=>decorateStory,deepDiff:()=>deepDiff,defaultDecorateStory:()=>defaultDecorateStory,filterArgTypes:()=>filterArgTypes,getArrayField:()=>getArrayField,getField:()=>getField,getObjectField:()=>getObjectField,getSingletonField:()=>getSingletonField,getValuesFromArgTypes:()=>getValuesFromArgTypes,groupArgsByTarget:()=>groupArgsByTarget,inferControls:()=>inferControls,mapArgsToTypes:()=>mapArgsToTypes,noTargetArgs:()=>noTargetArgs,normalizeComponentAnnotations:()=>normalizeComponentAnnotations,normalizeInputType:()=>normalizeInputType,normalizeInputTypes:()=>normalizeInputTypes,normalizeProjectAnnotations:()=>normalizeProjectAnnotations,normalizeStory:()=>normalizeStory,prepareContext:()=>prepareContext,prepareMeta:()=>prepareMeta,prepareStory:()=>prepareStory,processCSFFile:()=>processCSFFile,sanitizeStoryContextUpdate:()=>sanitizeStoryContextUpdate,setProjectAnnotations:()=>setProjectAnnotations,sortStoriesV6:()=>sortStoriesV6,sortStoriesV7:()=>sortStoriesV7,useAddonState:()=>useAddonState,useArgs:()=>useArgs,useCallback:()=>useCallback,useChannel:()=>useChannel,useEffect:()=>useEffect,useGlobals:()=>useGlobals,useMemo:()=>useMemo,useParameter:()=>useParameter,useReducer:()=>useReducer,useRef:()=>useRef,useSharedState:()=>useSharedState,useState:()=>useState,useStoryContext:()=>useStoryContext,userOrAutoTitle:()=>userOrAutoTitle,userOrAutoTitleFromSpecifier:()=>userOrAutoTitleFromSpecifier,validateOptions:()=>validateOptions});module.exports=__toCommonJS(store_exports);var import_memoizerific2=__toESM(require("memoizerific")),import_mapValues4=__toESM(require("lodash/mapValues.js")),import_pick=__toESM(require("lodash/pick.js")),import_synchronous_promise=require("synchronous-promise");var import_global=require("@storybook/global");var import_channels=require("@storybook/channels");function mockChannel(){let transport={setHandler:()=>{},send:()=>{}};return new import_channels.Channel({transport})}var AddonStore=class{constructor(){this.getChannel=()=>{if(!this.channel){let channel=mockChannel();return this.setChannel(channel),channel}return this.channel};this.getServerChannel=()=>{if(!this.serverChannel)throw new Error("Accessing non-existent serverChannel");return this.serverChannel};this.ready=()=>this.promise;this.hasChannel=()=>!!this.channel;this.hasServerChannel=()=>!!this.serverChannel;this.setChannel=channel=>{this.channel=channel,this.resolve()};this.setServerChannel=channel=>{this.serverChannel=channel};this.promise=new Promise(res=>{this.resolve=()=>res(this.getChannel())})}},KEY="__STORYBOOK_ADDONS_PREVIEW";function getAddonsStore(){return import_global.global[KEY]||(import_global.global[KEY]=new AddonStore),import_global.global[KEY]}var addons=getAddonsStore();var import_global2=require("@storybook/global"),import_client_logger=require("@storybook/client-logger"),import_core_events=require("@storybook/core-events");var HooksContext=class{constructor(){this.hookListsMap=void 0;this.mountedDecorators=void 0;this.prevMountedDecorators=void 0;this.currentHooks=void 0;this.nextHookIndex=void 0;this.currentPhase=void 0;this.currentEffects=void 0;this.prevEffects=void 0;this.currentDecoratorName=void 0;this.hasUpdates=void 0;this.currentContext=void 0;this.renderListener=storyId=>{var _a;storyId===((_a=this.currentContext)==null?void 0:_a.id)&&(this.triggerEffects(),this.currentContext=null,this.removeRenderListeners())};this.init()}init(){this.hookListsMap=new WeakMap,this.mountedDecorators=new Set,this.prevMountedDecorators=this.mountedDecorators,this.currentHooks=[],this.nextHookIndex=0,this.currentPhase="NONE",this.currentEffects=[],this.prevEffects=[],this.currentDecoratorName=null,this.hasUpdates=!1,this.currentContext=null}clean(){this.prevEffects.forEach(effect=>{effect.destroy&&effect.destroy()}),this.init(),this.removeRenderListeners()}getNextHook(){let hook=this.currentHooks[this.nextHookIndex];return this.nextHookIndex+=1,hook}triggerEffects(){this.prevEffects.forEach(effect=>{!this.currentEffects.includes(effect)&&effect.destroy&&effect.destroy()}),this.currentEffects.forEach(effect=>{this.prevEffects.includes(effect)||(effect.destroy=effect.create())}),this.prevEffects=this.currentEffects,this.currentEffects=[]}addRenderListeners(){this.removeRenderListeners(),addons.getChannel().on(import_core_events.STORY_RENDERED,this.renderListener)}removeRenderListeners(){addons.getChannel().removeListener(import_core_events.STORY_RENDERED,this.renderListener)}};function hookify(fn){let hookified=(...args)=>{let{hooks}=typeof args[0]=="function"?args[1]:args[0],prevPhase=hooks.currentPhase,prevHooks=hooks.currentHooks,prevNextHookIndex=hooks.nextHookIndex,prevDecoratorName=hooks.currentDecoratorName;hooks.currentDecoratorName=fn.name,hooks.prevMountedDecorators.has(fn)?(hooks.currentPhase="UPDATE",hooks.currentHooks=hooks.hookListsMap.get(fn)||[]):(hooks.currentPhase="MOUNT",hooks.currentHooks=[],hooks.hookListsMap.set(fn,hooks.currentHooks),hooks.prevMountedDecorators.add(fn)),hooks.nextHookIndex=0;let prevContext=import_global2.global.STORYBOOK_HOOKS_CONTEXT;import_global2.global.STORYBOOK_HOOKS_CONTEXT=hooks;let result=fn(...args);if(import_global2.global.STORYBOOK_HOOKS_CONTEXT=prevContext,hooks.currentPhase==="UPDATE"&&hooks.getNextHook()!=null)throw new Error("Rendered fewer hooks than expected. This may be caused by an accidental early return statement.");return hooks.currentPhase=prevPhase,hooks.currentHooks=prevHooks,hooks.nextHookIndex=prevNextHookIndex,hooks.currentDecoratorName=prevDecoratorName,result};return hookified.originalFn=fn,hookified}var numberOfRenders=0,RENDER_LIMIT=25,applyHooks=applyDecorators=>(storyFn,decorators)=>{let decorated=applyDecorators(hookify(storyFn),decorators.map(decorator=>hookify(decorator)));return context=>{let{hooks}=context;hooks.prevMountedDecorators=hooks.mountedDecorators,hooks.mountedDecorators=new Set([storyFn,...decorators]),hooks.currentContext=context,hooks.hasUpdates=!1;let result=decorated(context);for(numberOfRenders=1;hooks.hasUpdates;)if(hooks.hasUpdates=!1,hooks.currentEffects=[],result=decorated(context),numberOfRenders+=1,numberOfRenders>RENDER_LIMIT)throw new Error("Too many re-renders. Storybook limits the number of renders to prevent an infinite loop.");return hooks.addRenderListeners(),result}},areDepsEqual=(deps,nextDeps)=>deps.length===nextDeps.length&&deps.every((dep,i)=>dep===nextDeps[i]),invalidHooksError=()=>new Error("Storybook preview hooks can only be called inside decorators and story functions.");function getHooksContextOrNull(){return import_global2.global.STORYBOOK_HOOKS_CONTEXT||null}function getHooksContextOrThrow(){let hooks=getHooksContextOrNull();if(hooks==null)throw invalidHooksError();return hooks}function useHook(name,callback,deps){let hooks=getHooksContextOrThrow();if(hooks.currentPhase==="MOUNT"){deps!=null&&!Array.isArray(deps)&&import_client_logger.logger.warn(`${name} received a final argument that is not an array (instead, received ${deps}). When specified, the final argument must be an array.`);let hook={name,deps};return hooks.currentHooks.push(hook),callback(hook),hook}if(hooks.currentPhase==="UPDATE"){let hook=hooks.getNextHook();if(hook==null)throw new Error("Rendered more hooks than during the previous render.");return hook.name!==name&&import_client_logger.logger.warn(`Storybook has detected a change in the order of Hooks${hooks.currentDecoratorName?` called by ${hooks.currentDecoratorName}`:""}. This will lead to bugs and errors if not fixed.`),deps!=null&&hook.deps==null&&import_client_logger.logger.warn(`${name} received a final argument during this render, but not during the previous render. Even though the final argument is optional, its type cannot change between renders.`),deps!=null&&hook.deps!=null&&deps.length!==hook.deps.length&&import_client_logger.logger.warn(`The final argument passed to ${name} changed size between renders. The order and size of this array must remain constant.

- Custom args: https://storybook.js.org/docs/react/essentials/controls#fully-custom-args
`),{name:"other",value:"cyclic object"}):(visited.add(value),Array.isArray(value)?{name:"array",value:value.length>0?inferType(value[0],name,new Set(visited)):{name:"other",value:"unknown"}}:{name:"object",value:(0,import_mapValues2.default)(value,field=>inferType(field,name,new Set(visited)))}):{name:"object",value:{}}},inferArgTypes=context=>{let{id,argTypes:userArgTypes={},initialArgs={}}=context,argTypes=(0,import_mapValues2.default)(initialArgs,(arg,key)=>({name:key,type:inferType(arg,`${id}.${key}`,new Set)})),userArgTypesNames=(0,import_mapValues2.default)(userArgTypes,(argType,key)=>({name:key}));return combineParameters(argTypes,userArgTypesNames,userArgTypes)};inferArgTypes.secondPass=!0;var import_mapValues3=__toESM(require("lodash/mapValues.js")),import_client_logger7=require("@storybook/client-logger");var import_pickBy=__toESM(require("lodash/pickBy.js")),matches=(name,descriptor)=>Array.isArray(descriptor)?descriptor.includes(name):name.match(descriptor),filterArgTypes=(argTypes,include,exclude)=>!include&&!exclude?argTypes:argTypes&&(0,import_pickBy.default)(argTypes,(argType,key)=>{let name=argType.name||key;return(!include||matches(name,include))&&(!exclude||!matches(name,exclude))});var inferControl=(argType,name,matchers)=>{let{type,options}=argType;if(type){if(matchers.color&&matchers.color.test(name)){let controlType=type.name;if(controlType==="string")return{control:{type:"color"}};controlType!=="enum"&&import_client_logger7.logger.warn(`Addon controls: Control of type color only supports string, received "${controlType}" instead`)}if(matchers.date&&matchers.date.test(name))return{control:{type:"date"}};switch(type.name){case"array":return{control:{type:"object"}};case"boolean":return{control:{type:"boolean"}};case"string":return{control:{type:"text"}};case"number":return{control:{type:"number"}};case"enum":{let{value}=type;return{control:{type:(value==null?void 0:value.length)<=5?"radio":"select"},options:value}}case"function":case"symbol":return null;default:return{control:{type:options?"select":"object"}}}}},inferControls=context=>{let{argTypes,parameters:{__isArgsStory,controls:{include=null,exclude=null,matchers={}}={}}}=context;if(!__isArgsStory)return argTypes;let filteredArgTypes=filterArgTypes(argTypes,include,exclude),withControls=(0,import_mapValues3.default)(filteredArgTypes,(argType,name)=>(argType==null?void 0:argType.type)&&inferControl(argType,name,matchers));return combineParameters(withControls,filteredArgTypes)};inferControls.secondPass=!0;function normalizeProjectAnnotations({argTypes,globalTypes,argTypesEnhancers,...annotations}){return{...argTypes&&{argTypes:normalizeInputTypes(argTypes)},...globalTypes&&{globalTypes:normalizeInputTypes(globalTypes)},argTypesEnhancers:[...argTypesEnhancers||[],inferArgTypes,inferControls],...annotations}}var import_global4=require("@storybook/global");function composeStepRunners(stepRunners){return async(label,play,playContext)=>{await stepRunners.reduceRight((innerPlay,stepRunner)=>async()=>stepRunner(label,innerPlay,playContext),async()=>play(playContext))()}}function getField(moduleExportList,field){return moduleExportList.map(xs=>{var _a;return((_a=xs.default)==null?void 0:_a[field])??xs[field]}).filter(Boolean)}function getArrayField(moduleExportList,field,options={}){return getField(moduleExportList,field).reduce((a,b)=>options.reverseFileOrder?[...b,...a]:[...a,...b],[])}function getObjectField(moduleExportList,field){return Object.assign({},...getField(moduleExportList,field))}function getSingletonField(moduleExportList,field){return getField(moduleExportList,field).pop()}function composeConfigs(moduleExportList){var _a;let allArgTypeEnhancers=getArrayField(moduleExportList,"argTypesEnhancers"),stepRunners=getField(moduleExportList,"runStep");return{parameters:combineParameters(...getField(moduleExportList,"parameters")),decorators:getArrayField(moduleExportList,"decorators",{reverseFileOrder:!(((_a=import_global4.global.FEATURES)==null?void 0:_a.legacyDecoratorFileOrder)??!1)}),args:getObjectField(moduleExportList,"args"),argsEnhancers:getArrayField(moduleExportList,"argsEnhancers"),argTypes:getObjectField(moduleExportList,"argTypes"),argTypesEnhancers:[...allArgTypeEnhancers.filter(e=>!e.secondPass),...allArgTypeEnhancers.filter(e=>e.secondPass)],globals:getObjectField(moduleExportList,"globals"),globalTypes:getObjectField(moduleExportList,"globalTypes"),loaders:getArrayField(moduleExportList,"loaders"),render:getSingletonField(moduleExportList,"render"),renderToCanvas:getSingletonField(moduleExportList,"renderToCanvas"),renderToDOM:getSingletonField(moduleExportList,"renderToDOM"),applyDecorators:getSingletonField(moduleExportList,"applyDecorators"),runStep:composeStepRunners(stepRunners)}}var import_csf5=require("@storybook/csf");var GLOBAL_STORYBOOK_PROJECT_ANNOTATIONS=composeConfigs([]);function setProjectAnnotations(projectAnnotations){let annotations=Array.isArray(projectAnnotations)?projectAnnotations:[projectAnnotations];GLOBAL_STORYBOOK_PROJECT_ANNOTATIONS=composeConfigs(annotations)}function composeStory(storyAnnotations,componentAnnotations,projectAnnotations=GLOBAL_STORYBOOK_PROJECT_ANNOTATIONS,defaultConfig={},exportsName){var _a;if(storyAnnotations===void 0)throw new Error("Expected a story but received undefined.");componentAnnotations.title=componentAnnotations.title??"ComposedStory";let normalizedComponentAnnotations=normalizeComponentAnnotations(componentAnnotations),storyName=exportsName||storyAnnotations.storyName||((_a=storyAnnotations.story)==null?void 0:_a.name)||storyAnnotations.name||"unknown",normalizedStory=normalizeStory(storyName,storyAnnotations,normalizedComponentAnnotations),normalizedProjectAnnotations=normalizeProjectAnnotations({...projectAnnotations,...defaultConfig}),story=prepareStory(normalizedStory,normalizedComponentAnnotations,normalizedProjectAnnotations),defaultGlobals=getValuesFromArgTypes(projectAnnotations.globalTypes),composedStory=extraArgs=>{let context={...story,hooks:new HooksContext,globals:defaultGlobals,args:{...story.initialArgs,...extraArgs}};return story.unboundStoryFn(prepareContext(context))};return composedStory.storyName=storyName,composedStory.args=story.initialArgs,composedStory.play=story.playFunction,composedStory.parameters=story.parameters,composedStory.id=story.id,composedStory}function composeStories(storiesImport,globalConfig,composeStoryFn){let{default:meta,__esModule,__namedExportsOrder,...stories}=storiesImport;return Object.entries(stories).reduce((storiesMap,[exportsName,story])=>(0,import_csf5.isExportStory)(exportsName,meta)?Object.assign(storiesMap,{[exportsName]:composeStoryFn(story,meta,globalConfig,exportsName)}):storiesMap,{})}var CSF_CACHE_SIZE=1e3,STORY_CACHE_SIZE=1e4,EXTRACT_BATCH_SIZE=20,StoryStore=class{constructor(){this.getStoriesJsonData=()=>{let{storyIndex}=this;if(!storyIndex)throw new Error("getStoriesJsonData called before initialization");let value=this.getSetStoriesPayload(),allowedParameters=["fileName","docsOnly","framework","__id","__isArgsStory"];return{v:3,stories:(0,import_mapValues4.default)(value.stories,story=>{let{importPath}=storyIndex.entries[story.id];return{...(0,import_pick.default)(story,["id","name","title"]),importPath,kind:story.title,story:story.name,parameters:{...(0,import_pick.default)(story.parameters,allowedParameters),fileName:importPath}}})}};this.args=new ArgsStore,this.hooks={},this.processCSFFileWithCache=(0,import_memoizerific2.default)(CSF_CACHE_SIZE)(processCSFFile),this.prepareMetaWithCache=(0,import_memoizerific2.default)(CSF_CACHE_SIZE)(prepareMeta),this.prepareStoryWithCache=(0,import_memoizerific2.default)(STORY_CACHE_SIZE)(prepareStory),this.initializationPromise=new import_synchronous_promise.SynchronousPromise(resolve=>{this.resolveInitializationPromise=resolve})}setProjectAnnotations(projectAnnotations){this.projectAnnotations=normalizeProjectAnnotations(projectAnnotations);let{globals,globalTypes}=projectAnnotations;this.globals?this.globals.set({globals,globalTypes}):this.globals=new GlobalsStore({globals,globalTypes})}initialize({storyIndex,importFn,cache=!1}){return this.storyIndex=new StoryIndexStore(storyIndex),this.importFn=importFn,this.resolveInitializationPromise(),cache?this.cacheAllCSFFiles():import_synchronous_promise.SynchronousPromise.resolve()}async onStoriesChanged({importFn,storyIndex}){await this.initializationPromise,importFn&&(this.importFn=importFn),storyIndex&&(this.storyIndex.entries=storyIndex.entries),this.cachedCSFFiles&&await this.cacheAllCSFFiles()}async storyIdToEntry(storyId){return await this.initializationPromise,this.storyIndex.storyIdToEntry(storyId)}loadCSFFileByStoryId(storyId){if(!this.storyIndex||!this.importFn)throw new Error("loadCSFFileByStoryId called before initialization");let{importPath,title}=this.storyIndex.storyIdToEntry(storyId);return this.importFn(importPath).then(moduleExports=>this.processCSFFileWithCache(moduleExports,importPath,title))}loadAllCSFFiles({batchSize=EXTRACT_BATCH_SIZE}={}){if(!this.storyIndex)throw new Error("loadAllCSFFiles called before initialization");let importPaths=Object.entries(this.storyIndex.entries).map(([storyId,{importPath}])=>[importPath,storyId]),loadInBatches=remainingImportPaths=>{if(remainingImportPaths.length===0)return import_synchronous_promise.SynchronousPromise.resolve([]);let csfFilePromiseList=remainingImportPaths.slice(0,batchSize).map(([importPath,storyId])=>this.loadCSFFileByStoryId(storyId).then(csfFile=>({importPath,csfFile})));return import_synchronous_promise.SynchronousPromise.all(csfFilePromiseList).then(firstResults=>loadInBatches(remainingImportPaths.slice(batchSize)).then(restResults=>firstResults.concat(restResults)))};return loadInBatches(importPaths).then(list=>list.reduce((acc,{importPath,csfFile})=>(acc[importPath]=csfFile,acc),{}))}cacheAllCSFFiles(){return this.initializationPromise.then(()=>this.loadAllCSFFiles().then(csfFiles=>{this.cachedCSFFiles=csfFiles}))}preparedMetaFromCSFFile({csfFile}){if(!this.projectAnnotations)throw new Error("storyFromCSFFile called before initialization");let componentAnnotations=csfFile.meta;return this.prepareMetaWithCache(componentAnnotations,this.projectAnnotations,csfFile.moduleExports.default)}async loadStory({storyId}){await this.initializationPromise;let csfFile=await this.loadCSFFileByStoryId(storyId);return this.storyFromCSFFile({storyId,csfFile})}storyFromCSFFile({storyId,csfFile}){if(!this.projectAnnotations)throw new Error("storyFromCSFFile called before initialization");let storyAnnotations=csfFile.stories[storyId];if(!storyAnnotations)throw new Error(`Didn't find '${storyId}' in CSF file, this is unexpected`);let componentAnnotations=csfFile.meta,story=this.prepareStoryWithCache(storyAnnotations,componentAnnotations,this.projectAnnotations);return this.args.setInitial(story),this.hooks[story.id]=this.hooks[story.id]||new HooksContext,story}componentStoriesFromCSFFile({csfFile}){if(!this.storyIndex)throw new Error("componentStoriesFromCSFFile called before initialization");return Object.keys(this.storyIndex.entries).filter(storyId=>!!csfFile.stories[storyId]).map(storyId=>this.storyFromCSFFile({storyId,csfFile}))}async loadEntry(id){let entry=await this.storyIdToEntry(id),{importFn,storyIndex}=this;if(!storyIndex||!importFn)throw new Error("loadEntry called before initialization");let storyImports=entry.type==="docs"?entry.storiesImports:[],[entryExports,...csfFiles]=await Promise.all([importFn(entry.importPath),...storyImports.map(storyImportPath=>{let firstStoryEntry=storyIndex.importPathToEntry(storyImportPath);return this.loadCSFFileByStoryId(firstStoryEntry.id)})]);return{entryExports,csfFiles}}getStoryContext(story,{forceInitialArgs=!1}={}){if(!this.globals)throw new Error("getStoryContext called before initialization");return prepareContext({...story,args:forceInitialArgs?story.initialArgs:this.args.get(story.id),globals:this.globals.get(),hooks:this.hooks[story.id]})}cleanupStory(story){this.hooks[story.id].clean()}extract(options={includeDocsOnly:!1}){if(!this.storyIndex)throw new Error("extract called before initialization");let{cachedCSFFiles}=this;if(!cachedCSFFiles)throw new Error("Cannot call extract() unless you call cacheAllCSFFiles() first.");return Object.entries(this.storyIndex.entries).reduce((acc,[storyId,{type,importPath}])=>{if(type==="docs")return acc;let csfFile=cachedCSFFiles[importPath],story=this.storyFromCSFFile({storyId,csfFile});return!options.includeDocsOnly&&story.parameters.docsOnly||(acc[storyId]=Object.entries(story).reduce((storyAcc,[key,value])=>key==="moduleExport"||typeof value=="function"?storyAcc:Array.isArray(value)?Object.assign(storyAcc,{[key]:value.slice().sort()}):Object.assign(storyAcc,{[key]:value}),{args:story.initialArgs})),acc},{})}getSetStoriesPayload(){if(!this.globals)throw new Error("getSetStoriesPayload called before initialization");let stories=this.extract({includeDocsOnly:!0}),kindParameters=Object.values(stories).reduce((acc,{title})=>(acc[title]={},acc),{});return{v:2,globals:this.globals.get(),globalParameters:{},kindParameters,stories}}getSetIndexPayload(){if(!this.storyIndex)throw new Error("getSetIndexPayload called before initialization");if(!this.cachedCSFFiles)throw new Error("Cannot call getSetIndexPayload() unless you call cacheAllCSFFiles() first");let{cachedCSFFiles}=this,stories=this.extract({includeDocsOnly:!0});return{v:4,entries:Object.fromEntries(Object.entries(this.storyIndex.entries).map(([id,entry])=>[id,stories[id]?{...entry,args:stories[id].initialArgs,initialArgs:stories[id].initialArgs,argTypes:stories[id].argTypes,parameters:stories[id].parameters}:{...entry,parameters:this.preparedMetaFromCSFFile({csfFile:cachedCSFFiles[entry.importPath]}).parameters}]))}}raw(){return Object.values(this.extract()).map(({id})=>this.fromId(id)).filter(Boolean)}fromId(storyId){if(!this.storyIndex)throw new Error("fromId called before initialization");if(!this.cachedCSFFiles)throw new Error("Cannot call fromId/raw() unless you call cacheAllCSFFiles() first.");let importPath;try{({importPath}=this.storyIndex.storyIdToEntry(storyId))}catch{return null}let csfFile=this.cachedCSFFiles[importPath],story=this.storyFromCSFFile({storyId,csfFile});return{...story,storyFn:update=>{let context={...this.getStoryContext(story),viewMode:"story"};return story.unboundStoryFn({...context,...update})}}}};var import_core_events2=require("@storybook/core-events");function useSharedState(sharedId,defaultState){let channel=addons.getChannel(),[lastValue]=channel.last(`${import_core_events2.SHARED_STATE_CHANGED}-manager-${sharedId}`)||channel.last(`${import_core_events2.SHARED_STATE_SET}-manager-${sharedId}`)||[],[state,setState]=useState(lastValue||defaultState),allListeners=useMemo(()=>({[`${import_core_events2.SHARED_STATE_CHANGED}-manager-${sharedId}`]:s=>setState(s),[`${import_core_events2.SHARED_STATE_SET}-manager-${sharedId}`]:s=>setState(s)}),[sharedId]),emit=useChannel(allListeners,[sharedId]);return useEffect(()=>{defaultState!==void 0&&!lastValue&&emit(`${import_core_events2.SHARED_STATE_SET}-client-${sharedId}`,defaultState)},[sharedId]),[state,s=>{setState(s),emit(`${import_core_events2.SHARED_STATE_CHANGED}-client-${sharedId}`,s)}]}function useAddonState(addonId,defaultState){return useSharedState(addonId,defaultState)}function slash(path){return/^\\\\\?\\/.test(path)?path:path.replace(/\\/g,"/")}var import_ts_dedent6=require("ts-dedent"),import_client_logger8=require("@storybook/client-logger"),stripExtension=path=>{let parts=[...path],last=parts[parts.length-1],dotIndex=last.indexOf("."),stripped=dotIndex>0?last.substr(0,dotIndex):last;parts[parts.length-1]=stripped;let[first,...rest]=parts;return first===""&&(parts=rest),parts},indexRe=/^index$/i,removeRedundantFilename=paths=>{let prevVal;return paths.filter((val,index)=>index===paths.length-1&&(val===prevVal||indexRe.test(val))?!1:(prevVal=val,!0))};function pathJoin(paths){let slashes=new RegExp("/{1,}","g");return paths.join("/").replace(slashes,"/")}var userOrAutoTitleFromSpecifier=(fileName,entry,userTitle)=>{let{directory,importPathMatcher,titlePrefix=""}=entry||{};typeof fileName=="number"&&import_client_logger8.once.warn(import_ts_dedent6.dedent`
`),{name:"other",value:"cyclic object"}):(visited.add(value),Array.isArray(value)?{name:"array",value:value.length>0?inferType(value[0],name,new Set(visited)):{name:"other",value:"unknown"}}:{name:"object",value:(0,import_mapValues2.default)(value,field=>inferType(field,name,new Set(visited)))}):{name:"object",value:{}}},inferArgTypes=context=>{let{id,argTypes:userArgTypes={},initialArgs={}}=context,argTypes=(0,import_mapValues2.default)(initialArgs,(arg,key)=>({name:key,type:inferType(arg,`${id}.${key}`,new Set)})),userArgTypesNames=(0,import_mapValues2.default)(userArgTypes,(argType,key)=>({name:key}));return combineParameters(argTypes,userArgTypesNames,userArgTypes)};inferArgTypes.secondPass=!0;var import_mapValues3=__toESM(require("lodash/mapValues.js")),import_client_logger7=require("@storybook/client-logger");var import_pickBy=__toESM(require("lodash/pickBy.js")),matches=(name,descriptor)=>Array.isArray(descriptor)?descriptor.includes(name):name.match(descriptor),filterArgTypes=(argTypes,include,exclude)=>!include&&!exclude?argTypes:argTypes&&(0,import_pickBy.default)(argTypes,(argType,key)=>{let name=argType.name||key;return(!include||matches(name,include))&&(!exclude||!matches(name,exclude))});var inferControl=(argType,name,matchers)=>{let{type,options}=argType;if(type){if(matchers.color&&matchers.color.test(name)){let controlType=type.name;if(controlType==="string")return{control:{type:"color"}};controlType!=="enum"&&import_client_logger7.logger.warn(`Addon controls: Control of type color only supports string, received "${controlType}" instead`)}if(matchers.date&&matchers.date.test(name))return{control:{type:"date"}};switch(type.name){case"array":return{control:{type:"object"}};case"boolean":return{control:{type:"boolean"}};case"string":return{control:{type:"text"}};case"number":return{control:{type:"number"}};case"enum":{let{value}=type;return{control:{type:(value==null?void 0:value.length)<=5?"radio":"select"},options:value}}case"function":case"symbol":return null;default:return{control:{type:options?"select":"object"}}}}},inferControls=context=>{let{argTypes,parameters:{__isArgsStory,controls:{include=null,exclude=null,matchers={}}={}}}=context;if(!__isArgsStory)return argTypes;let filteredArgTypes=filterArgTypes(argTypes,include,exclude),withControls=(0,import_mapValues3.default)(filteredArgTypes,(argType,name)=>(argType==null?void 0:argType.type)&&inferControl(argType,name,matchers));return combineParameters(withControls,filteredArgTypes)};inferControls.secondPass=!0;function normalizeProjectAnnotations({argTypes,globalTypes,argTypesEnhancers,...annotations}){return{...argTypes&&{argTypes:normalizeInputTypes(argTypes)},...globalTypes&&{globalTypes:normalizeInputTypes(globalTypes)},argTypesEnhancers:[...argTypesEnhancers||[],inferArgTypes,inferControls],...annotations}}var import_global4=require("@storybook/global");function composeStepRunners(stepRunners){return async(label,play,playContext)=>{await stepRunners.reduceRight((innerPlay,stepRunner)=>async()=>stepRunner(label,innerPlay,playContext),async()=>play(playContext))()}}function getField(moduleExportList,field){return moduleExportList.map(xs=>{var _a;return((_a=xs.default)==null?void 0:_a[field])??xs[field]}).filter(Boolean)}function getArrayField(moduleExportList,field,options={}){return getField(moduleExportList,field).reduce((a,b)=>options.reverseFileOrder?[...b,...a]:[...a,...b],[])}function getObjectField(moduleExportList,field){return Object.assign({},...getField(moduleExportList,field))}function getSingletonField(moduleExportList,field){return getField(moduleExportList,field).pop()}function composeConfigs(moduleExportList){var _a;let allArgTypeEnhancers=getArrayField(moduleExportList,"argTypesEnhancers"),stepRunners=getField(moduleExportList,"runStep");return{parameters:combineParameters(...getField(moduleExportList,"parameters")),decorators:getArrayField(moduleExportList,"decorators",{reverseFileOrder:!(((_a=import_global4.global.FEATURES)==null?void 0:_a.legacyDecoratorFileOrder)??!1)}),args:getObjectField(moduleExportList,"args"),argsEnhancers:getArrayField(moduleExportList,"argsEnhancers"),argTypes:getObjectField(moduleExportList,"argTypes"),argTypesEnhancers:[...allArgTypeEnhancers.filter(e=>!e.secondPass),...allArgTypeEnhancers.filter(e=>e.secondPass)],globals:getObjectField(moduleExportList,"globals"),globalTypes:getObjectField(moduleExportList,"globalTypes"),loaders:getArrayField(moduleExportList,"loaders"),render:getSingletonField(moduleExportList,"render"),renderToCanvas:getSingletonField(moduleExportList,"renderToCanvas"),renderToDOM:getSingletonField(moduleExportList,"renderToDOM"),applyDecorators:getSingletonField(moduleExportList,"applyDecorators"),runStep:composeStepRunners(stepRunners)}}var import_csf5=require("@storybook/csf");var GLOBAL_STORYBOOK_PROJECT_ANNOTATIONS=composeConfigs([]);function setProjectAnnotations(projectAnnotations){let annotations=Array.isArray(projectAnnotations)?projectAnnotations:[projectAnnotations];GLOBAL_STORYBOOK_PROJECT_ANNOTATIONS=composeConfigs(annotations)}function composeStory(storyAnnotations,componentAnnotations,projectAnnotations=GLOBAL_STORYBOOK_PROJECT_ANNOTATIONS,defaultConfig={},exportsName){var _a;if(storyAnnotations===void 0)throw new Error("Expected a story but received undefined.");componentAnnotations.title=componentAnnotations.title??"ComposedStory";let normalizedComponentAnnotations=normalizeComponentAnnotations(componentAnnotations),storyName=exportsName||storyAnnotations.storyName||((_a=storyAnnotations.story)==null?void 0:_a.name)||storyAnnotations.name||"unknown",normalizedStory=normalizeStory(storyName,storyAnnotations,normalizedComponentAnnotations),normalizedProjectAnnotations=normalizeProjectAnnotations({...projectAnnotations,...defaultConfig}),story=prepareStory(normalizedStory,normalizedComponentAnnotations,normalizedProjectAnnotations),defaultGlobals=getValuesFromArgTypes(projectAnnotations.globalTypes),composedStory=extraArgs=>{let context={...story,hooks:new HooksContext,globals:defaultGlobals,args:{...story.initialArgs,...extraArgs}};return story.unboundStoryFn(prepareContext(context))};return composedStory.storyName=storyName,composedStory.args=story.initialArgs,composedStory.play=story.playFunction,composedStory.parameters=story.parameters,composedStory.id=story.id,composedStory}function composeStories(storiesImport,globalConfig,composeStoryFn){let{default:meta,__esModule,__namedExportsOrder,...stories}=storiesImport;return Object.entries(stories).reduce((storiesMap,[exportsName,story])=>(0,import_csf5.isExportStory)(exportsName,meta)?Object.assign(storiesMap,{[exportsName]:composeStoryFn(story,meta,globalConfig,exportsName)}):storiesMap,{})}var CSF_CACHE_SIZE=1e3,STORY_CACHE_SIZE=1e4,EXTRACT_BATCH_SIZE=20,StoryStore=class{constructor(){this.getStoriesJsonData=()=>{let{storyIndex}=this;if(!storyIndex)throw new Error("getStoriesJsonData called before initialization");let value=this.getSetStoriesPayload(),allowedParameters=["fileName","docsOnly","framework","__id","__isArgsStory"];return{v:3,stories:(0,import_mapValues4.default)(value.stories,story=>{let{importPath}=storyIndex.entries[story.id];return{...(0,import_pick.default)(story,["id","name","title"]),importPath,kind:story.title,story:story.name,parameters:{...(0,import_pick.default)(story.parameters,allowedParameters),fileName:importPath}}})}};this.args=new ArgsStore,this.hooks={},this.processCSFFileWithCache=(0,import_memoizerific2.default)(CSF_CACHE_SIZE)(processCSFFile),this.prepareMetaWithCache=(0,import_memoizerific2.default)(CSF_CACHE_SIZE)(prepareMeta),this.prepareStoryWithCache=(0,import_memoizerific2.default)(STORY_CACHE_SIZE)(prepareStory),this.initializationPromise=new import_synchronous_promise.SynchronousPromise(resolve=>{this.resolveInitializationPromise=resolve})}setProjectAnnotations(projectAnnotations){this.projectAnnotations=normalizeProjectAnnotations(projectAnnotations);let{globals,globalTypes}=projectAnnotations;this.globals?this.globals.set({globals,globalTypes}):this.globals=new GlobalsStore({globals,globalTypes})}initialize({storyIndex,importFn,cache=!1}){return this.storyIndex=new StoryIndexStore(storyIndex),this.importFn=importFn,this.resolveInitializationPromise(),cache?this.cacheAllCSFFiles():import_synchronous_promise.SynchronousPromise.resolve()}async onStoriesChanged({importFn,storyIndex}){await this.initializationPromise,importFn&&(this.importFn=importFn),storyIndex&&(this.storyIndex.entries=storyIndex.entries),this.cachedCSFFiles&&await this.cacheAllCSFFiles()}async storyIdToEntry(storyId){return await this.initializationPromise,this.storyIndex.storyIdToEntry(storyId)}loadCSFFileByStoryId(storyId){if(!this.storyIndex||!this.importFn)throw new Error("loadCSFFileByStoryId called before initialization");let{importPath,title}=this.storyIndex.storyIdToEntry(storyId);return this.importFn(importPath).then(moduleExports=>this.processCSFFileWithCache(moduleExports,importPath,title))}loadAllCSFFiles({batchSize=EXTRACT_BATCH_SIZE}={}){if(!this.storyIndex)throw new Error("loadAllCSFFiles called before initialization");let importPaths=Object.entries(this.storyIndex.entries).map(([storyId,{importPath}])=>[importPath,storyId]),loadInBatches=remainingImportPaths=>{if(remainingImportPaths.length===0)return import_synchronous_promise.SynchronousPromise.resolve([]);let csfFilePromiseList=remainingImportPaths.slice(0,batchSize).map(([importPath,storyId])=>this.loadCSFFileByStoryId(storyId).then(csfFile=>({importPath,csfFile})));return import_synchronous_promise.SynchronousPromise.all(csfFilePromiseList).then(firstResults=>loadInBatches(remainingImportPaths.slice(batchSize)).then(restResults=>firstResults.concat(restResults)))};return loadInBatches(importPaths).then(list=>list.reduce((acc,{importPath,csfFile})=>(acc[importPath]=csfFile,acc),{}))}cacheAllCSFFiles(){return this.initializationPromise.then(()=>this.loadAllCSFFiles().then(csfFiles=>{this.cachedCSFFiles=csfFiles}))}preparedMetaFromCSFFile({csfFile}){if(!this.projectAnnotations)throw new Error("storyFromCSFFile called before initialization");let componentAnnotations=csfFile.meta;return this.prepareMetaWithCache(componentAnnotations,this.projectAnnotations,csfFile.moduleExports.default)}async loadStory({storyId}){await this.initializationPromise;let csfFile=await this.loadCSFFileByStoryId(storyId);return this.storyFromCSFFile({storyId,csfFile})}storyFromCSFFile({storyId,csfFile}){if(!this.projectAnnotations)throw new Error("storyFromCSFFile called before initialization");let storyAnnotations=csfFile.stories[storyId];if(!storyAnnotations)throw new Error(`Didn't find '${storyId}' in CSF file, this is unexpected`);let componentAnnotations=csfFile.meta,story=this.prepareStoryWithCache(storyAnnotations,componentAnnotations,this.projectAnnotations);return this.args.setInitial(story),this.hooks[story.id]=this.hooks[story.id]||new HooksContext,story}componentStoriesFromCSFFile({csfFile}){if(!this.storyIndex)throw new Error("componentStoriesFromCSFFile called before initialization");return Object.keys(this.storyIndex.entries).filter(storyId=>!!csfFile.stories[storyId]).map(storyId=>this.storyFromCSFFile({storyId,csfFile}))}async loadEntry(id){let entry=await this.storyIdToEntry(id),{importFn,storyIndex}=this;if(!storyIndex||!importFn)throw new Error("loadEntry called before initialization");let storyImports=entry.type==="docs"?entry.storiesImports:[],[entryExports,...csfFiles]=await Promise.all([importFn(entry.importPath),...storyImports.map(storyImportPath=>{let firstStoryEntry=storyIndex.importPathToEntry(storyImportPath);return this.loadCSFFileByStoryId(firstStoryEntry.id)})]);return{entryExports,csfFiles}}getStoryContext(story,{forceInitialArgs=!1}={}){if(!this.globals)throw new Error("getStoryContext called before initialization");return prepareContext({...story,args:forceInitialArgs?story.initialArgs:this.args.get(story.id),globals:this.globals.get(),hooks:this.hooks[story.id]})}cleanupStory(story){this.hooks[story.id].clean()}extract(options={includeDocsOnly:!1}){if(!this.storyIndex)throw new Error("extract called before initialization");let{cachedCSFFiles}=this;if(!cachedCSFFiles)throw new Error("Cannot call extract() unless you call cacheAllCSFFiles() first.");return Object.entries(this.storyIndex.entries).reduce((acc,[storyId,{type,importPath}])=>{if(type==="docs")return acc;let csfFile=cachedCSFFiles[importPath],story=this.storyFromCSFFile({storyId,csfFile});return!options.includeDocsOnly&&story.parameters.docsOnly||(acc[storyId]=Object.entries(story).reduce((storyAcc,[key,value])=>key==="moduleExport"||typeof value=="function"?storyAcc:Array.isArray(value)?Object.assign(storyAcc,{[key]:value.slice().sort()}):Object.assign(storyAcc,{[key]:value}),{args:story.initialArgs})),acc},{})}getSetStoriesPayload(){if(!this.globals)throw new Error("getSetStoriesPayload called before initialization");let stories=this.extract({includeDocsOnly:!0}),kindParameters=Object.values(stories).reduce((acc,{title})=>(acc[title]={},acc),{});return{v:2,globals:this.globals.get(),globalParameters:{},kindParameters,stories}}getSetIndexPayload(){if(!this.storyIndex)throw new Error("getSetIndexPayload called before initialization");if(!this.cachedCSFFiles)throw new Error("Cannot call getSetIndexPayload() unless you call cacheAllCSFFiles() first");let{cachedCSFFiles}=this,stories=this.extract({includeDocsOnly:!0});return{v:4,entries:Object.fromEntries(Object.entries(this.storyIndex.entries).map(([id,entry])=>[id,stories[id]?{...entry,args:stories[id].initialArgs,initialArgs:stories[id].initialArgs,argTypes:stories[id].argTypes,parameters:stories[id].parameters}:{...entry,parameters:this.preparedMetaFromCSFFile({csfFile:cachedCSFFiles[entry.importPath]}).parameters}]))}}raw(){return Object.values(this.extract()).map(({id})=>this.fromId(id)).filter(Boolean)}fromId(storyId){if(!this.storyIndex)throw new Error("fromId called before initialization");if(!this.cachedCSFFiles)throw new Error("Cannot call fromId/raw() unless you call cacheAllCSFFiles() first.");let importPath;try{({importPath}=this.storyIndex.storyIdToEntry(storyId))}catch{return null}let csfFile=this.cachedCSFFiles[importPath],story=this.storyFromCSFFile({storyId,csfFile});return{...story,storyFn:update=>{let context={...this.getStoryContext(story),viewMode:"story"};return story.unboundStoryFn({...context,...update})}}}};var import_core_events2=require("@storybook/core-events");function useSharedState(sharedId,defaultState){let channel=addons.getChannel(),[lastValue]=channel.last(`${import_core_events2.SHARED_STATE_CHANGED}-manager-${sharedId}`)||channel.last(`${import_core_events2.SHARED_STATE_SET}-manager-${sharedId}`)||[],[state,setState]=useState(lastValue||defaultState),allListeners=useMemo(()=>({[`${import_core_events2.SHARED_STATE_CHANGED}-manager-${sharedId}`]:s=>setState(s),[`${import_core_events2.SHARED_STATE_SET}-manager-${sharedId}`]:s=>setState(s)}),[sharedId]),emit=useChannel(allListeners,[sharedId]);return useEffect(()=>{defaultState!==void 0&&!lastValue&&emit(`${import_core_events2.SHARED_STATE_SET}-client-${sharedId}`,defaultState)},[sharedId]),[state,s=>{setState(s),emit(`${import_core_events2.SHARED_STATE_CHANGED}-client-${sharedId}`,s)}]}function useAddonState(addonId,defaultState){return useSharedState(addonId,defaultState)}function slash(path){return path.startsWith("\\\\?\\")?path:path.replace(/\\/g,"/")}var import_ts_dedent6=require("ts-dedent"),import_client_logger8=require("@storybook/client-logger"),stripExtension=path=>{let parts=[...path],last=parts[parts.length-1],dotIndex=last.indexOf("."),stripped=dotIndex>0?last.substr(0,dotIndex):last;parts[parts.length-1]=stripped;let[first,...rest]=parts;return first===""&&(parts=rest),parts},indexRe=/^index$/i,removeRedundantFilename=paths=>{let prevVal;return paths.filter((val,index)=>index===paths.length-1&&(val===prevVal||indexRe.test(val))?!1:(prevVal=val,!0))};function pathJoin(paths){let slashes=new RegExp("/{1,}","g");return paths.join("/").replace(slashes,"/")}var userOrAutoTitleFromSpecifier=(fileName,entry,userTitle)=>{let{directory,importPathMatcher,titlePrefix=""}=entry||{};typeof fileName=="number"&&import_client_logger8.once.warn(import_ts_dedent6.dedent`
CSF Auto-title received a numeric fileName. This typically happens when

@@ -32,0 +32,0 @@ webpack is mis-configured in production mode. To force webpack to produce

{
"name": "@storybook/preview-api",
"version": "7.1.0-alpha.25",
"version": "7.1.0-alpha.26",
"description": "",

@@ -70,9 +70,9 @@ "keywords": [

"dependencies": {
"@storybook/channel-postmessage": "7.1.0-alpha.25",
"@storybook/channels": "7.1.0-alpha.25",
"@storybook/client-logger": "7.1.0-alpha.25",
"@storybook/core-events": "7.1.0-alpha.25",
"@storybook/channel-postmessage": "7.1.0-alpha.26",
"@storybook/channels": "7.1.0-alpha.26",
"@storybook/client-logger": "7.1.0-alpha.26",
"@storybook/core-events": "7.1.0-alpha.26",
"@storybook/csf": "^0.1.0",
"@storybook/global": "^5.0.0",
"@storybook/types": "7.1.0-alpha.25",
"@storybook/types": "7.1.0-alpha.26",
"@types/qs": "^6.9.5",

@@ -89,3 +89,3 @@ "dequal": "^2.0.2",

"@jest/globals": "^26.6.2",
"@storybook/core-common": "7.1.0-alpha.25",
"@storybook/core-common": "7.1.0-alpha.26",
"ansi-to-html": "^0.6.11",

@@ -108,3 +108,3 @@ "react": "^16.14.0",

},
"gitHead": "3f93a9032c93e77e34c3b39adea4b4a0f21e8920"
"gitHead": "515abaa55abc8ad20f906e4ce46cde3d3850991e"
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc