@storybook/csf 0.0.2--canary.43.a3d8c69.0 → 0.0.2--canary.49.9d84710.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/story.d.ts +29 -11
- package/dist/story.test.js +74 -5
- package/package.json +2 -2
package/dist/story.d.ts
CHANGED
@@ -64,10 +64,15 @@ export declare type StrictGlobalTypes = {
|
|
64
64
|
export declare type AnyFramework = {
|
65
65
|
component: unknown;
|
66
66
|
storyResult: unknown;
|
67
|
+
T?: unknown;
|
67
68
|
};
|
68
69
|
export declare type StoryContextForEnhancers<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryIdentifier & {
|
69
|
-
component?: TFramework
|
70
|
-
|
70
|
+
component?: (TFramework & {
|
71
|
+
T: any;
|
72
|
+
})['component'];
|
73
|
+
subcomponents?: (TFramework & {
|
74
|
+
T: any;
|
75
|
+
})['component'];
|
71
76
|
parameters: Parameters;
|
72
77
|
initialArgs: TArgs;
|
73
78
|
argTypes: StrictArgTypes<TArgs>;
|
@@ -93,19 +98,25 @@ export declare type StoryContext<TFramework extends AnyFramework = AnyFramework,
|
|
93
98
|
abortSignal: AbortSignal;
|
94
99
|
canvasElement: HTMLElement;
|
95
100
|
};
|
96
|
-
export declare type
|
97
|
-
export declare type
|
101
|
+
export declare type StepLabel = string;
|
102
|
+
export declare type StepFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (label: StepLabel, play: PlayFunction<TFramework, TArgs>) => Promise<void> | void;
|
103
|
+
export declare type PlayFunctionContext<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryContext<TFramework, TArgs> & {
|
104
|
+
step: StepFunction<TFramework, TArgs>;
|
105
|
+
};
|
106
|
+
export declare type PlayFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: PlayFunctionContext<TFramework, TArgs>) => Promise<void> | void;
|
107
|
+
export declare type PartialStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (update?: StoryContextUpdate<Partial<TArgs>>) => TFramework['storyResult'];
|
98
108
|
export declare type LegacyStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
|
99
109
|
export declare type ArgsStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (args: TArgs, context: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
|
100
110
|
export declare type StoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = LegacyStoryFn<TFramework, TArgs> | ArgsStoryFn<TFramework, TArgs>;
|
101
111
|
export declare type DecoratorFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (fn: PartialStoryFn<TFramework, TArgs>, c: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
|
102
112
|
export declare type DecoratorApplicator<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (storyFn: LegacyStoryFn<TFramework, TArgs>, decorators: DecoratorFunction<TFramework, TArgs>[]) => LegacyStoryFn<TFramework, TArgs>;
|
113
|
+
export declare type StepRunner<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (label: StepLabel, play: PlayFunction<TFramework, TArgs>, context: PlayFunctionContext<TFramework, TArgs>) => Promise<void>;
|
103
114
|
export declare type BaseAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = {
|
104
|
-
decorators?: DecoratorFunction<TFramework,
|
115
|
+
decorators?: DecoratorFunction<TFramework, TArgs>[];
|
105
116
|
parameters?: Parameters;
|
106
117
|
args?: Partial<TArgs>;
|
107
118
|
argTypes?: Partial<ArgTypes<TArgs>>;
|
108
|
-
loaders?: LoaderFunction<TFramework,
|
119
|
+
loaders?: LoaderFunction<TFramework, TArgs>[];
|
109
120
|
render?: ArgsStoryFn<TFramework, TArgs>;
|
110
121
|
};
|
111
122
|
export declare type ProjectAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = BaseAnnotations<TFramework, TArgs> & {
|
@@ -114,22 +125,29 @@ export declare type ProjectAnnotations<TFramework extends AnyFramework = AnyFram
|
|
114
125
|
globals?: Globals;
|
115
126
|
globalTypes?: GlobalTypes;
|
116
127
|
applyDecorators?: DecoratorApplicator<TFramework, Args>;
|
128
|
+
runStep?: StepRunner<TFramework, TArgs>;
|
117
129
|
};
|
118
130
|
declare type StoryDescriptor = string[] | RegExp;
|
119
|
-
export
|
131
|
+
export interface ComponentAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> extends BaseAnnotations<TFramework, TArgs> {
|
120
132
|
title?: ComponentTitle;
|
121
133
|
id?: ComponentId;
|
122
134
|
includeStories?: StoryDescriptor;
|
123
135
|
excludeStories?: StoryDescriptor;
|
124
|
-
component?: TFramework
|
136
|
+
component?: (TFramework & {
|
137
|
+
T: Args extends TArgs ? any : TArgs;
|
138
|
+
})['component'];
|
125
139
|
subcomponents?: Record<string, TFramework['component']>;
|
126
|
-
}
|
127
|
-
export declare type StoryAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args
|
140
|
+
}
|
141
|
+
export declare type StoryAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args, TArgsAnnotations = Partial<TArgs>> = BaseAnnotations<TFramework, TArgs> & {
|
128
142
|
name?: StoryName;
|
129
143
|
storyName?: StoryName;
|
130
144
|
play?: PlayFunction<TFramework, TArgs>;
|
131
145
|
story?: Omit<StoryAnnotations<TFramework, TArgs>, 'story'>;
|
132
|
-
}
|
146
|
+
} & ({} extends TArgsAnnotations ? {
|
147
|
+
args?: TArgsAnnotations;
|
148
|
+
} : {
|
149
|
+
args: TArgsAnnotations;
|
150
|
+
});
|
133
151
|
export declare type LegacyAnnotatedStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryFn<TFramework, TArgs> & StoryAnnotations<TFramework, TArgs>;
|
134
152
|
export declare type LegacyStoryAnnotationsOrFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = LegacyAnnotatedStoryFn<TFramework, TArgs> | StoryAnnotations<TFramework, TArgs>;
|
135
153
|
export declare type AnnotatedStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = ArgsStoryFn<TFramework, TArgs> & StoryAnnotations<TFramework, TArgs>;
|
package/dist/story.test.js
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
4
|
+
|
5
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
6
|
+
|
3
7
|
// NOTE Example of internal type definition for @storybook/<X> (where X is a framework)
|
4
8
|
// NOTE Examples of using types from @storybook/<X> in real project
|
5
|
-
var Button = function Button() {
|
9
|
+
var Button = function Button(props) {
|
6
10
|
return 'Button';
|
7
|
-
};
|
11
|
+
}; // NOTE Various kind usages
|
12
|
+
|
8
13
|
|
9
|
-
// NOTE Various kind usages
|
10
14
|
var simple = {
|
11
15
|
title: 'simple',
|
12
16
|
component: Button,
|
@@ -26,10 +30,10 @@ var simple = {
|
|
26
30
|
});
|
27
31
|
}],
|
28
32
|
args: {
|
29
|
-
|
33
|
+
x: '1'
|
30
34
|
},
|
31
35
|
argTypes: {
|
32
|
-
|
36
|
+
x: {
|
33
37
|
type: {
|
34
38
|
name: 'string'
|
35
39
|
}
|
@@ -157,6 +161,71 @@ var CSF3StoryStrict = {
|
|
157
161
|
}],
|
158
162
|
args: {
|
159
163
|
x: '1'
|
164
|
+
},
|
165
|
+
play: function () {
|
166
|
+
var _play = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(_ref) {
|
167
|
+
var step;
|
168
|
+
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
169
|
+
while (1) {
|
170
|
+
switch (_context2.prev = _context2.next) {
|
171
|
+
case 0:
|
172
|
+
step = _ref.step;
|
173
|
+
_context2.next = 3;
|
174
|
+
return step('a step', /*#__PURE__*/function () {
|
175
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref2) {
|
176
|
+
var substep;
|
177
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
178
|
+
while (1) {
|
179
|
+
switch (_context.prev = _context.next) {
|
180
|
+
case 0:
|
181
|
+
substep = _ref2.step;
|
182
|
+
_context.next = 3;
|
183
|
+
return substep('a substep', function () {});
|
184
|
+
|
185
|
+
case 3:
|
186
|
+
case "end":
|
187
|
+
return _context.stop();
|
188
|
+
}
|
189
|
+
}
|
190
|
+
}, _callee);
|
191
|
+
}));
|
192
|
+
|
193
|
+
return function (_x2) {
|
194
|
+
return _ref3.apply(this, arguments);
|
195
|
+
};
|
196
|
+
}());
|
197
|
+
|
198
|
+
case 3:
|
199
|
+
case "end":
|
200
|
+
return _context2.stop();
|
201
|
+
}
|
202
|
+
}
|
203
|
+
}, _callee2);
|
204
|
+
}));
|
205
|
+
|
206
|
+
function play(_x) {
|
207
|
+
return _play.apply(this, arguments);
|
208
|
+
}
|
209
|
+
|
210
|
+
return play;
|
211
|
+
}()
|
212
|
+
};
|
213
|
+
var project = {
|
214
|
+
runStep: function runStep(label, play, context) {
|
215
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
|
216
|
+
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
217
|
+
while (1) {
|
218
|
+
switch (_context3.prev = _context3.next) {
|
219
|
+
case 0:
|
220
|
+
return _context3.abrupt("return", play(context));
|
221
|
+
|
222
|
+
case 1:
|
223
|
+
case "end":
|
224
|
+
return _context3.stop();
|
225
|
+
}
|
226
|
+
}
|
227
|
+
}, _callee3);
|
228
|
+
}))();
|
160
229
|
}
|
161
230
|
}; // NOTE Jest forced to define at least one test in file
|
162
231
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@storybook/csf",
|
3
|
-
"version": "0.0.2--canary.
|
3
|
+
"version": "0.0.2--canary.49.9d84710.0",
|
4
4
|
"description": "Component Story Format (CSF) utilities",
|
5
5
|
"keywords": [
|
6
6
|
"storybook",
|
@@ -61,7 +61,7 @@
|
|
61
61
|
"common-tags": "^1.8.0",
|
62
62
|
"eslint": "^6.7.1",
|
63
63
|
"jest": "^24.9.0",
|
64
|
-
"prettier": "^
|
64
|
+
"prettier": "^2.7.1",
|
65
65
|
"typescript": "^3.7.2"
|
66
66
|
},
|
67
67
|
"auto": {
|