@storybook/csf 0.0.2--canary.4566f4d.1 → 0.0.2--canary.0899bb7.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 +29 -0
- package/package.json +1 -1
- package/dist/includeConditionalArg.test.d.ts +0 -1
- package/dist/properties.d.ts +0 -75
- package/dist/properties.js +0 -27
- package/dist/properties.test.d.ts +0 -1
- package/dist/properties.test.js +0 -14
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>) => 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,31 @@ var CSF3StoryStrict = {
|
|
157
161
|
}],
|
158
162
|
args: {
|
159
163
|
x: '1'
|
164
|
+
},
|
165
|
+
play: function play(_ref) {
|
166
|
+
var step = _ref.step;
|
167
|
+
step('a step', function (_ref2) {
|
168
|
+
var substep = _ref2.step;
|
169
|
+
substep('a substep', function () {});
|
170
|
+
});
|
171
|
+
}
|
172
|
+
};
|
173
|
+
var project = {
|
174
|
+
runStep: function runStep(label, play, context) {
|
175
|
+
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
|
176
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
177
|
+
while (1) {
|
178
|
+
switch (_context.prev = _context.next) {
|
179
|
+
case 0:
|
180
|
+
return _context.abrupt("return", play(context));
|
181
|
+
|
182
|
+
case 1:
|
183
|
+
case "end":
|
184
|
+
return _context.stop();
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}, _callee);
|
188
|
+
}))();
|
160
189
|
}
|
161
190
|
}; // NOTE Jest forced to define at least one test in file
|
162
191
|
|
package/package.json
CHANGED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/dist/properties.d.ts
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
export declare enum PropertyTypes {
|
2
|
-
TEXT = "text",
|
3
|
-
NUMBER = "number",
|
4
|
-
BOOLEAN = "boolean",
|
5
|
-
OPTIONS = "options",
|
6
|
-
DATE = "date",
|
7
|
-
COLOR = "color",
|
8
|
-
BUTTON = "button",
|
9
|
-
OBJECT = "object",
|
10
|
-
ARRAY = "array",
|
11
|
-
FILES = "files"
|
12
|
-
}
|
13
|
-
export interface StoryPropertyBase<T> {
|
14
|
-
type: PropertyTypes;
|
15
|
-
label?: string;
|
16
|
-
value?: T;
|
17
|
-
hideLabel?: boolean;
|
18
|
-
hidden?: boolean;
|
19
|
-
groupId?: string;
|
20
|
-
order?: number;
|
21
|
-
}
|
22
|
-
export interface StoryPropertyText extends StoryPropertyBase<string> {
|
23
|
-
type: PropertyTypes.TEXT;
|
24
|
-
placeholder?: string;
|
25
|
-
maxRows?: number;
|
26
|
-
}
|
27
|
-
export interface StoryPropertyBoolean extends StoryPropertyBase<boolean> {
|
28
|
-
type: PropertyTypes.BOOLEAN;
|
29
|
-
}
|
30
|
-
export interface StoryPropertyColor extends StoryPropertyBase<string> {
|
31
|
-
type: PropertyTypes.COLOR;
|
32
|
-
}
|
33
|
-
export interface StoryPropertyDate extends StoryPropertyBase<Date> {
|
34
|
-
type: PropertyTypes.DATE;
|
35
|
-
datePicker?: boolean;
|
36
|
-
timePicker?: boolean;
|
37
|
-
}
|
38
|
-
export interface StoryPropertyFiles extends StoryPropertyBase<string[]> {
|
39
|
-
type: PropertyTypes.FILES;
|
40
|
-
accept?: string;
|
41
|
-
}
|
42
|
-
export interface StoryPropertyArray extends StoryPropertyBase<string[]> {
|
43
|
-
type: PropertyTypes.ARRAY;
|
44
|
-
separator?: string;
|
45
|
-
}
|
46
|
-
export interface StoryPropertyObject extends StoryPropertyBase<object> {
|
47
|
-
type: PropertyTypes.OBJECT;
|
48
|
-
}
|
49
|
-
export interface StoryPropertyButton extends StoryPropertyBase<void> {
|
50
|
-
type: PropertyTypes.BUTTON;
|
51
|
-
onClick?: (prop: StoryPropertyButton) => void;
|
52
|
-
}
|
53
|
-
export declare type OptionsValueType<T = unknown> = T | string | number | string[] | number[] | {
|
54
|
-
label: string;
|
55
|
-
value: any;
|
56
|
-
};
|
57
|
-
export declare type OptionsListType<T = unknown> = {
|
58
|
-
[key: string]: T;
|
59
|
-
} | OptionsValueType<T>[];
|
60
|
-
export interface StoryPropertyOptions<T = unknown> extends StoryPropertyBase<OptionsValueType<T>> {
|
61
|
-
type: PropertyTypes.OPTIONS;
|
62
|
-
options: OptionsListType<T>;
|
63
|
-
display?: 'select' | 'multi-select' | 'radio' | 'inline-radio' | 'check' | 'inline-check';
|
64
|
-
}
|
65
|
-
export interface StoryPropertyNumber extends StoryPropertyBase<number> {
|
66
|
-
type: PropertyTypes.NUMBER;
|
67
|
-
range?: boolean;
|
68
|
-
min?: number;
|
69
|
-
max?: number;
|
70
|
-
step?: number;
|
71
|
-
}
|
72
|
-
export declare type StoryProperty = StoryPropertyText | StoryPropertyBoolean | StoryPropertyColor | StoryPropertyDate | StoryPropertyObject | StoryPropertyButton | StoryPropertyOptions | StoryPropertyNumber | StoryPropertyArray | StoryPropertyFiles;
|
73
|
-
export interface StoryProperties {
|
74
|
-
[name: string]: StoryProperty;
|
75
|
-
}
|
package/dist/properties.js
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.PropertyTypes = void 0;
|
7
|
-
|
8
|
-
/**
|
9
|
-
* Property field types
|
10
|
-
* examples are provided for the different types:
|
11
|
-
*
|
12
|
-
*/
|
13
|
-
var PropertyTypes;
|
14
|
-
exports.PropertyTypes = PropertyTypes;
|
15
|
-
|
16
|
-
(function (PropertyTypes) {
|
17
|
-
PropertyTypes["TEXT"] = "text";
|
18
|
-
PropertyTypes["NUMBER"] = "number";
|
19
|
-
PropertyTypes["BOOLEAN"] = "boolean";
|
20
|
-
PropertyTypes["OPTIONS"] = "options";
|
21
|
-
PropertyTypes["DATE"] = "date";
|
22
|
-
PropertyTypes["COLOR"] = "color";
|
23
|
-
PropertyTypes["BUTTON"] = "button";
|
24
|
-
PropertyTypes["OBJECT"] = "object";
|
25
|
-
PropertyTypes["ARRAY"] = "array";
|
26
|
-
PropertyTypes["FILES"] = "files";
|
27
|
-
})(PropertyTypes || (exports.PropertyTypes = PropertyTypes = {}));
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/dist/properties.test.js
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _ = require(".");
|
4
|
-
|
5
|
-
describe('properties', function () {
|
6
|
-
it('type PropertyTypes.TEXT', function () {
|
7
|
-
expect(function () {
|
8
|
-
var prop = {
|
9
|
-
type: _.PropertyTypes.TEXT
|
10
|
-
};
|
11
|
-
return prop.type === 'text';
|
12
|
-
}).toBeTruthy();
|
13
|
-
});
|
14
|
-
});
|