1 | import type { AnyFramework, DecoratorApplicator, StoryContext, StoryId, Args } from '@storybook/csf';
|
2 | interface Hook {
|
3 | name: string;
|
4 | memoizedState?: any;
|
5 | deps?: any[] | undefined;
|
6 | }
|
7 | interface Effect {
|
8 | create: () => (() => void) | void;
|
9 | destroy?: (() => void) | void;
|
10 | }
|
11 | declare type AbstractFunction = (...args: any[]) => any;
|
12 | export declare class HooksContext<TFramework extends AnyFramework> {
|
13 | hookListsMap: WeakMap<AbstractFunction, Hook[]>;
|
14 | mountedDecorators: Set<AbstractFunction>;
|
15 | prevMountedDecorators: Set<AbstractFunction>;
|
16 | currentHooks: Hook[];
|
17 | nextHookIndex: number;
|
18 | currentPhase: 'MOUNT' | 'UPDATE' | 'NONE';
|
19 | currentEffects: Effect[];
|
20 | prevEffects: Effect[];
|
21 | currentDecoratorName: string | null;
|
22 | hasUpdates: boolean;
|
23 | currentContext: StoryContext<TFramework> | null;
|
24 | renderListener: (storyId: StoryId) => void;
|
25 | constructor();
|
26 | init(): void;
|
27 | clean(): void;
|
28 | getNextHook(): Hook;
|
29 | triggerEffects(): void;
|
30 | addRenderListeners(): void;
|
31 | removeRenderListeners(): void;
|
32 | }
|
33 | export declare const applyHooks: <TFramework extends AnyFramework>(applyDecorators: DecoratorApplicator<TFramework, Args>) => DecoratorApplicator<TFramework, Args>;
|
34 | export declare function useMemo<T>(nextCreate: () => T, deps?: any[]): T;
|
35 | export declare function useCallback<T>(callback: T, deps?: any[]): T;
|
36 | export declare function useRef<T>(initialValue: T): {
|
37 | current: T;
|
38 | };
|
39 | export declare function useState<S>(initialState: (() => S) | S): [S, (update: ((prevState: S) => S) | S) => void];
|
40 | export declare function useReducer<S, A>(reducer: (state: S, action: A) => S, initialState: S): [S, (action: A) => void];
|
41 | export declare function useReducer<S, I, A>(reducer: (state: S, action: A) => S, initialArg: I, init: (initialArg: I) => S): [S, (action: A) => void];
|
42 | export declare function useEffect(create: () => (() => void) | void, deps?: any[]): void;
|
43 | export interface Listener {
|
44 | (...args: any[]): void;
|
45 | }
|
46 | export interface EventMap {
|
47 | [eventId: string]: Listener;
|
48 | }
|
49 | export declare function useChannel(eventMap: EventMap, deps?: any[]): any;
|
50 | export declare function useStoryContext<TFramework extends AnyFramework>(): StoryContext<TFramework>;
|
51 | export declare function useParameter<S>(parameterKey: string, defaultValue?: S): S | undefined;
|
52 | export declare function useArgs(): [Args, (newArgs: Args) => void, (argNames?: [string]) => void];
|
53 | export declare function useGlobals(): [Args, (newGlobals: Args) => void];
|
54 | export {};
|