UNPKG

2.74 kBTypeScriptView Raw
1import { Options as Options$1 } from 'telejson';
2
3declare const PARAM_KEY = "actions";
4declare const ADDON_ID = "storybook/actions";
5declare const PANEL_ID: string;
6declare const EVENT_ID: string;
7declare const CLEAR_ID: string;
8declare const CYCLIC_KEY = "$___storybook.isCyclic";
9
10interface Options {
11 depth: number;
12 clearOnStoryChange: boolean;
13 limit: number;
14}
15type ActionOptions = Partial<Options> & Partial<Options$1>;
16
17interface ActionDisplay {
18 id: string;
19 data: {
20 name: string;
21 args: any[];
22 };
23 count: number;
24 options: ActionOptions;
25}
26
27type HandlerFunction = (...args: any[]) => void;
28
29type ActionsMap<T extends string = string> = Record<T, HandlerFunction>;
30
31interface ActionsFunction {
32 <T extends string>(handlerMap: Record<T, string>, options?: ActionOptions): ActionsMap<T>;
33 <T extends string>(...handlers: T[]): ActionsMap<T>;
34 <T extends string>(handler1: T, options?: ActionOptions): ActionsMap<T>;
35 <T extends string>(handler1: T, handler2: T, options?: ActionOptions): ActionsMap<T>;
36 <T extends string>(handler1: T, handler2: T, handler3: T, options?: ActionOptions): ActionsMap<T>;
37 <T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, options?: ActionOptions): ActionsMap<T>;
38 <T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, options?: ActionOptions): ActionsMap<T>;
39 <T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, handler6: T, options?: ActionOptions): ActionsMap<T>;
40 <T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, handler6: T, handler7: T, options?: ActionOptions): ActionsMap<T>;
41 <T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, handler6: T, handler7: T, handler8: T, options?: ActionOptions): ActionsMap<T>;
42 <T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, handler6: T, handler7: T, handler8: T, handler9: T, options?: ActionOptions): ActionsMap<T>;
43 <T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, handler6: T, handler7: T, handler8: T, handler9: T, handler10: T, options?: ActionOptions): ActionsMap<T>;
44}
45
46type DecoratorFunction = (args: any[]) => any[];
47
48declare function action(name: string, options?: ActionOptions): HandlerFunction;
49
50declare const actions: ActionsFunction;
51
52declare const config: ActionOptions;
53declare const configureActions: (options?: ActionOptions) => void;
54
55export { ADDON_ID, ActionDisplay, ActionOptions, ActionsFunction, ActionsMap, CLEAR_ID, CYCLIC_KEY, DecoratorFunction, EVENT_ID, HandlerFunction, PANEL_ID, PARAM_KEY, action, actions, config, configureActions };