File tree Expand file tree Collapse file tree 4 files changed +73
-2
lines changed
Expand file tree Collapse file tree 4 files changed +73
-2
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ Simplifies the addons creation. Keeps in sync addon's data through the channel.
1111- Provides redux like approach to deal with your addon store via selectors and actions (but don't worry, the default action just simply override your data)
1212- Allows to connect any amount of pannels, buttons and any other addon types to the single addon store
1313- Offers UI container which automatically reflects the aspect ratio of addon panel. Extremely useful to create addon UI responsive for vertical and horizontal panel positions
14+ - Includes Typescript definitions
1415
1516## Usage
1617
Original file line number Diff line number Diff line change 11{
22 "name" : " @storybook/addon-devkit" ,
3- "version" : " 1.3.2 " ,
3+ "version" : " 1.3.3 " ,
44 "description" : " Storybook Addon Development Kit" ,
55 "author" : {
66 "name" : " Oleg Proskurin" ,
77 "url" : " https://github.com/UsulPro"
88 },
99 "main" : " dist/index.js" ,
10+ "types" : " dist/index.d.ts" ,
1011 "scripts" : {
1112 "test" : " jest" ,
1213 "tdd" : " jest --watch" ,
1617 "build-storybook" : " build-storybook -s public" ,
1718 "dev" : " nodemon --exec yarn prepare" ,
1819 "prepare-dev" : " babel dev --out-dir dev-dist --verbose" ,
19- "prepare" : " package-prepare" ,
20+ "prepare" : " package-prepare && cp src/index.d.ts dist " ,
2021 "postpublish" : " node .scripts/npm-postpublish.js"
2122 },
2223 "dependencies" : {
3637 "@storybook/addon-backgrounds" : " ^5.1.9" ,
3738 "@storybook/addon-links" : " ^5.1.9" ,
3839 "@storybook/react" : " ^5.1.9" ,
40+ "@types/react" : " ^16.9.19" ,
3941 "@usulpro/package-prepare" : " ^1.1.4" ,
4042 "babel-eslint" : " ^10.0.1" ,
4143 "babel-jest" : " ^24.9.0" ,
Original file line number Diff line number Diff line change 1+ type Store = {
2+ [ key : string ] : any
3+ } ;
4+
5+ type Selector = ( store : Store ) => any ;
6+ type ParamSelector = ( parameters : {
7+ [ key : string ] : any
8+ } , selectors : {
9+ [ key : string ] : any
10+ } ) => any ;
11+
12+ type ActionDispatcher = ( ...args : any [ ] ) => void | Promise < void > ;
13+ type ActionGenerator = (
14+ action : ( store : Store , ...args : any [ ] ) => Store | Promise < Store >
15+ ) => ActionDispatcher ;
16+ type Actions = ( { local : ActionGenerator , global : ActionGenerator } ) => {
17+ [ key : string ] : ActionDispatcher
18+ } ;
19+
20+ export declare function register (
21+ storeSelectors : {
22+ [ key : string ] : Selector
23+ } ,
24+ createActions : Actions
25+ ) : ( Component : React . ComponentType ) => void ;
26+
27+
28+ interface StoryContext {
29+ id : string ;
30+ name : string ;
31+ kind : string ;
32+ [ key : string ] : any ;
33+ parameters : Parameters ;
34+ }
35+
36+ export type StoryFn < ReturnType = unknown > = ( p ?: StoryContext ) => ReturnType ;
37+ type DecoratorFunction = ( fn : StoryFn , c : StoryContext ) => ReturnType < StoryFn > ;
38+
39+ /**
40+ * Options that controls decorator behavior
41+ */
42+ type DecoratorOptions = {
43+ isGlobal : boolean ,
44+ }
45+
46+ export declare function createDecorator ( storeSelectors : {
47+ [ key : string ] : Selector
48+ } ,
49+ createActions : Actions ,
50+ paramSelectors : {
51+ [ key : string ] : ParamSelector
52+ }
53+ ) : ( Component : React . ComponentType , options : DecoratorOptions ) => DecoratorFunction ;
54+
55+ type AddonParameters = {
56+ [ key : string ] : any
57+ }
58+ export declare function setParameters ( ) : < T extends AddonParameters > ( T ) => ( {
59+ addonKey : T
60+ } )
Original file line number Diff line number Diff line change 22052205 "@types/prop-types" "*"
22062206 csstype "^2.2.0"
22072207
2208+ "@types/react@^16.9.19":
2209+ version "16.9.19"
2210+ resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.19.tgz#c842aa83ea490007d29938146ff2e4d9e4360c40"
2211+ integrity sha512-LJV97//H+zqKWMms0kvxaKYJDG05U2TtQB3chRLF8MPNs+MQh/H1aGlyDUxjaHvu08EAGerdX2z4LTBc7ns77A==
2212+ dependencies:
2213+ "@types/prop-types" "*"
2214+ csstype "^2.2.0"
2215+
22082216"@types/stack-utils@^1.0.1":
22092217 version "1.0.1"
22102218 resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e"
You can’t perform that action at this time.
0 commit comments