1- type Store = {
2- [ key : string ] : any
3- } ;
1+ import { types as addonTypes } from '@storybook/addons'
2+ import { API } from '@storybook/api'
3+
4+ interface Dictionary < T = any > {
5+ [ key : string ] : T
6+ }
7+
8+ type AddonStore = Dictionary ;
49
5- type Selector = ( store : Store ) => any ;
10+ type Selector = ( store : AddonStore ) => any ;
611type ParamSelector = ( parameters : {
712 [ key : string ] : any
813} , selectors : {
@@ -11,18 +16,19 @@ type ParamSelector = (parameters: {
1116
1217type ActionDispatcher = ( ...args : any [ ] ) => void | Promise < void > ;
1318type ActionGenerator = (
14- action : ( store : Store , ...args : any [ ] ) => Store | Promise < Store >
19+ action : ( store : AddonStore , ...args : any [ ] ) => AddonStore | Promise < AddonStore >
1520) => ActionDispatcher ;
16- type Actions = ( { local : ActionGenerator , global : ActionGenerator } ) => {
17- [ key : string ] : ActionDispatcher
18- } ;
21+ type Actions = ( { local : ActionGenerator , global : ActionGenerator } ) => Dictionary < ActionDispatcher > ;
22+
23+ type RegisterOptions = {
24+ type ?: addonTypes
25+ initData ?: Dictionary
26+ }
1927
2028export declare function register (
21- storeSelectors : {
22- [ key : string ] : Selector
23- } ,
24- createActions : Actions
25- ) : ( Component : React . ComponentType ) => void ;
29+ storeSelectors ?: Dictionary < Selector > ,
30+ createActions ?: Actions
31+ ) : ( Component : React . ComponentType , options : RegisterOptions ) => void ;
2632
2733
2834interface StoryContext {
@@ -43,18 +49,40 @@ type DecoratorOptions = {
4349 isGlobal : boolean ,
4450}
4551
46- export declare function createDecorator ( storeSelectors : {
47- [ key : string ] : Selector
48- } ,
52+ export declare function createDecorator ( storeSelectors ?: Dictionary < Selector > ,
4953 createActions : Actions ,
50- paramSelectors : {
51- [ key : string ] : ParamSelector
52- }
54+ paramSelectors ?: Dictionary <
55+ ( parameters : Dictionary , selectors : Dictionary < ( ) => any > ) => any
56+ >
5357) : ( Component : React . ComponentType , options : DecoratorOptions ) => DecoratorFunction ;
5458
55- type AddonParameters = {
56- [ key : string ] : any
57- }
59+ type AddonParameters = Dictionary < any >
60+
5861export declare function setParameters ( ) : < T extends AddonParameters > ( T ) => ( {
59- addonKey : T
62+ [ ConfigValues . PARAM_Key ] : T
6063} )
64+
65+ type ConfigOptions = {
66+ addonId ?: string
67+ panelId ?: string
68+ panelTitle ?: string
69+ paramKey ?: string
70+ eventInit ?: string
71+ eventData ?: string
72+ eventBack ?: string
73+ }
74+
75+ export declare function setConfig ( config : ConfigOptions ) : void
76+
77+ type ConfigValues = {
78+ ADDON_ID : string
79+ PANEL_ID : string
80+ PANEL_Title : string
81+ PARAM_Key : string
82+ EVENT_ID_INIT : string
83+ EVENT_ID_DATA : string
84+ EVENT_ID_BACK : string
85+ }
86+
87+ export declare function getConfig ( ) : ConfigValues
88+
0 commit comments