UNPKG

3.09 kBTypeScriptView Raw
1declare const PARAM_KEY = "actions";
2declare const ADDON_ID = "storybook/actions";
3declare const PANEL_ID = "storybook/actions/panel";
4declare const EVENT_ID = "storybook/actions/action-event";
5declare const CLEAR_ID = "storybook/actions/action-clear";
6declare const CYCLIC_KEY = "$___storybook.isCyclic";
7
8interface Options$1 {
9 allowRegExp: boolean;
10 allowFunction: boolean;
11 allowSymbol: boolean;
12 allowDate: boolean;
13 allowUndefined: boolean;
14 allowClass: boolean;
15 allowError: boolean;
16 maxDepth: number;
17 space: number | undefined;
18 lazyEval: boolean;
19}
20
21interface Options {
22 depth: number;
23 clearOnStoryChange: boolean;
24 limit: number;
25 implicit: boolean;
26 id: string;
27}
28type ActionOptions = Partial<Options> & Partial<Options$1>;
29
30interface ActionDisplay {
31 id: string;
32 data: {
33 name: string;
34 args: any[];
35 };
36 count: number;
37 options: ActionOptions;
38}
39
40type HandlerFunction = (...args: any[]) => void;
41
42type ActionsMap<T extends string = string> = Record<T, HandlerFunction>;
43
44interface ActionsFunction {
45 <T extends string>(handlerMap: Record<T, string>, options?: ActionOptions): ActionsMap<T>;
46 <T extends string>(...handlers: T[]): ActionsMap<T>;
47 <T extends string>(handler1: T, options?: ActionOptions): ActionsMap<T>;
48 <T extends string>(handler1: T, handler2: T, options?: ActionOptions): ActionsMap<T>;
49 <T extends string>(handler1: T, handler2: T, handler3: T, options?: ActionOptions): ActionsMap<T>;
50 <T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, options?: ActionOptions): ActionsMap<T>;
51 <T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, options?: ActionOptions): ActionsMap<T>;
52 <T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, handler6: T, options?: ActionOptions): ActionsMap<T>;
53 <T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, handler6: T, handler7: T, options?: ActionOptions): ActionsMap<T>;
54 <T extends string>(handler1: T, handler2: T, handler3: T, handler4: T, handler5: T, handler6: T, handler7: T, handler8: T, options?: ActionOptions): ActionsMap<T>;
55 <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>;
56 <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>;
57}
58
59type DecoratorFunction = (args: any[]) => any[];
60
61declare function action(name: string, options?: ActionOptions): HandlerFunction;
62
63declare const actions: ActionsFunction;
64
65declare const config: ActionOptions;
66declare const configureActions: (options?: ActionOptions) => void;
67
68export { ADDON_ID, ActionDisplay, ActionOptions, ActionsFunction, ActionsMap, CLEAR_ID, CYCLIC_KEY, DecoratorFunction, EVENT_ID, HandlerFunction, PANEL_ID, PARAM_KEY, action, actions, config, configureActions };