@storybook/csf 0.0.2--canary.36.ecfc79e.0 → 0.0.2--canary.48.3bd2bd7.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 +9 -2
- package/dist/story.test.js +71 -2
- package/package.json +1 -1
package/dist/story.d.ts
CHANGED
@@ -93,20 +93,26 @@ 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;
|
106
112
|
args?: Partial<TArgs>;
|
107
113
|
argTypes?: Partial<ArgTypes<TArgs>>;
|
108
114
|
loaders?: LoaderFunction<TFramework, Args>[];
|
109
|
-
render?: ArgsStoryFn<TFramework,
|
115
|
+
render?: ArgsStoryFn<TFramework, TArgs>;
|
110
116
|
};
|
111
117
|
export declare type ProjectAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = BaseAnnotations<TFramework, TArgs> & {
|
112
118
|
argsEnhancers?: ArgsEnhancer<TFramework, Args>[];
|
@@ -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() {
|
@@ -116,7 +120,7 @@ CSF2Story.args = {
|
|
116
120
|
a: 1
|
117
121
|
};
|
118
122
|
var CSF3Story = {
|
119
|
-
render: function render() {
|
123
|
+
render: function render(args) {
|
120
124
|
return 'Named Story';
|
121
125
|
},
|
122
126
|
name: 'Another name for story',
|
@@ -138,7 +142,7 @@ var CSF3Story = {
|
|
138
142
|
}
|
139
143
|
};
|
140
144
|
var CSF3StoryStrict = {
|
141
|
-
render: function render() {
|
145
|
+
render: function render(args) {
|
142
146
|
return 'Named Story';
|
143
147
|
},
|
144
148
|
name: 'Another name for story',
|
@@ -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
|
|