@storybook/csf 0.0.2--canary.43.a3d8c69.0 → 0.0.2--canary.48.3bd2bd7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/story.d.ts +8 -1
- package/dist/story.test.js +69 -0
- package/package.json +1 -1
package/dist/story.d.ts
CHANGED
@@ -93,13 +93,19 @@ export declare type StoryContext<TFramework extends AnyFramework = AnyFramework,
|
|
93
93
|
abortSignal: AbortSignal;
|
94
94
|
canvasElement: HTMLElement;
|
95
95
|
};
|
96
|
-
export declare type
|
96
|
+
export declare type StepLabel = string;
|
97
|
+
export declare type StepFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (label: StepLabel, play: PlayFunction<TFramework, TArgs>) => Promise<void> | void;
|
98
|
+
export declare type PlayFunctionContext<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryContext<TFramework, TArgs> & {
|
99
|
+
step: StepFunction<TFramework, TArgs>;
|
100
|
+
};
|
101
|
+
export declare type PlayFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: PlayFunctionContext<TFramework, TArgs>) => Promise<void> | void;
|
97
102
|
export declare type PartialStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (update?: StoryContextUpdate<TArgs>) => TFramework['storyResult'];
|
98
103
|
export declare type LegacyStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
|
99
104
|
export declare type ArgsStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (args: TArgs, context: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
|
100
105
|
export declare type StoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = LegacyStoryFn<TFramework, TArgs> | ArgsStoryFn<TFramework, TArgs>;
|
101
106
|
export declare type DecoratorFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (fn: PartialStoryFn<TFramework, TArgs>, c: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
|
102
107
|
export declare type DecoratorApplicator<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (storyFn: LegacyStoryFn<TFramework, TArgs>, decorators: DecoratorFunction<TFramework, TArgs>[]) => LegacyStoryFn<TFramework, TArgs>;
|
108
|
+
export declare type StepRunner<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (label: StepLabel, play: PlayFunction<TFramework, TArgs>, context: PlayFunctionContext<TFramework, TArgs>) => Promise<void>;
|
103
109
|
export declare type BaseAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = {
|
104
110
|
decorators?: DecoratorFunction<TFramework, Args>[];
|
105
111
|
parameters?: Parameters;
|
@@ -114,6 +120,7 @@ export declare type ProjectAnnotations<TFramework extends AnyFramework = AnyFram
|
|
114
120
|
globals?: Globals;
|
115
121
|
globalTypes?: GlobalTypes;
|
116
122
|
applyDecorators?: DecoratorApplicator<TFramework, Args>;
|
123
|
+
runStep?: StepRunner<TFramework, TArgs>;
|
117
124
|
};
|
118
125
|
declare type StoryDescriptor = string[] | RegExp;
|
119
126
|
export declare type ComponentAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = BaseAnnotations<TFramework, TArgs> & {
|
package/dist/story.test.js
CHANGED
@@ -1,5 +1,9 @@
|
|
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
9
|
var Button = function Button() {
|
@@ -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
|
|