@storybook/csf 0.0.2--canary.51.768ca23.0 → 0.0.2--canary.51.26e6539.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/index.d.ts +325 -9
- package/dist/index.js +88 -117
- package/dist/index.mjs +73 -0
- package/package.json +25 -12
- package/.babelrc.js +0 -6
- package/dist/SBType.d.ts +0 -33
- package/dist/SBType.js +0 -1
- package/dist/includeConditionalArg.d.ts +0 -3
- package/dist/includeConditionalArg.js +0 -74
- package/dist/includeConditionalArg.test.js +0 -325
- package/dist/index.test.js +0 -142
- package/dist/story.d.ts +0 -164
- package/dist/story.js +0 -17
- package/dist/story.test.js +0 -236
package/dist/story.d.ts
DELETED
@@ -1,164 +0,0 @@
|
|
1
|
-
import { Simplify, UnionToIntersection } from 'type-fest';
|
2
|
-
import { SBType, SBScalarType } from './SBType';
|
3
|
-
export * from './SBType';
|
4
|
-
export declare type StoryId = string;
|
5
|
-
export declare type ComponentId = string;
|
6
|
-
export declare type ComponentTitle = string;
|
7
|
-
export declare type StoryName = string;
|
8
|
-
export declare type StoryKind = ComponentTitle;
|
9
|
-
export interface StoryIdentifier {
|
10
|
-
componentId: ComponentId;
|
11
|
-
title: ComponentTitle;
|
12
|
-
kind: ComponentTitle;
|
13
|
-
id: StoryId;
|
14
|
-
name: StoryName;
|
15
|
-
story: StoryName;
|
16
|
-
}
|
17
|
-
export declare type Parameters = {
|
18
|
-
[name: string]: any;
|
19
|
-
};
|
20
|
-
declare type ConditionalTest = {
|
21
|
-
truthy?: boolean;
|
22
|
-
} | {
|
23
|
-
exists: boolean;
|
24
|
-
} | {
|
25
|
-
eq: any;
|
26
|
-
} | {
|
27
|
-
neq: any;
|
28
|
-
};
|
29
|
-
declare type ConditionalValue = {
|
30
|
-
arg: string;
|
31
|
-
} | {
|
32
|
-
global: string;
|
33
|
-
};
|
34
|
-
export declare type Conditional = ConditionalValue & ConditionalTest;
|
35
|
-
export interface InputType {
|
36
|
-
name?: string;
|
37
|
-
description?: string;
|
38
|
-
defaultValue?: any;
|
39
|
-
type?: SBType | SBScalarType['name'];
|
40
|
-
if?: Conditional;
|
41
|
-
[key: string]: any;
|
42
|
-
}
|
43
|
-
export interface StrictInputType extends InputType {
|
44
|
-
name: string;
|
45
|
-
type?: SBType;
|
46
|
-
}
|
47
|
-
export declare type Args = {
|
48
|
-
[name: string]: any;
|
49
|
-
};
|
50
|
-
export declare type ArgTypes<TArgs = Args> = {
|
51
|
-
[name in keyof TArgs]: InputType;
|
52
|
-
};
|
53
|
-
export declare type StrictArgTypes<TArgs = Args> = {
|
54
|
-
[name in keyof TArgs]: StrictInputType;
|
55
|
-
};
|
56
|
-
export declare type Globals = {
|
57
|
-
[name: string]: any;
|
58
|
-
};
|
59
|
-
export declare type GlobalTypes = {
|
60
|
-
[name: string]: InputType;
|
61
|
-
};
|
62
|
-
export declare type StrictGlobalTypes = {
|
63
|
-
[name: string]: StrictInputType;
|
64
|
-
};
|
65
|
-
export declare type AnyFramework = {
|
66
|
-
component: unknown;
|
67
|
-
storyResult: unknown;
|
68
|
-
T?: unknown;
|
69
|
-
};
|
70
|
-
export declare type StoryContextForEnhancers<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryIdentifier & {
|
71
|
-
component?: (TFramework & {
|
72
|
-
T: any;
|
73
|
-
})['component'];
|
74
|
-
subcomponents?: Record<string, (TFramework & {
|
75
|
-
T: any;
|
76
|
-
})['component']>;
|
77
|
-
parameters: Parameters;
|
78
|
-
initialArgs: TArgs;
|
79
|
-
argTypes: StrictArgTypes<TArgs>;
|
80
|
-
};
|
81
|
-
export declare type ArgsEnhancer<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContextForEnhancers<TFramework, TArgs>) => TArgs;
|
82
|
-
export declare type ArgTypesEnhancer<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = ((context: StoryContextForEnhancers<TFramework, TArgs>) => StrictArgTypes<TArgs>) & {
|
83
|
-
secondPass?: boolean;
|
84
|
-
};
|
85
|
-
export declare type StoryContextUpdate<TArgs = Args> = {
|
86
|
-
args?: TArgs;
|
87
|
-
globals?: Globals;
|
88
|
-
[key: string]: any;
|
89
|
-
};
|
90
|
-
export declare type ViewMode = 'story' | 'docs';
|
91
|
-
export declare type StoryContextForLoaders<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryContextForEnhancers<TFramework, TArgs> & Required<StoryContextUpdate<TArgs>> & {
|
92
|
-
hooks: unknown;
|
93
|
-
viewMode: ViewMode;
|
94
|
-
originalStoryFn: StoryFn<TFramework>;
|
95
|
-
};
|
96
|
-
export declare type LoaderFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContextForLoaders<TFramework, TArgs>) => Promise<Record<string, any>>;
|
97
|
-
export declare type StoryContext<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryContextForLoaders<TFramework, TArgs> & {
|
98
|
-
loaded: Record<string, any>;
|
99
|
-
abortSignal: AbortSignal;
|
100
|
-
canvasElement: HTMLElement;
|
101
|
-
};
|
102
|
-
export declare type StepLabel = string;
|
103
|
-
export declare type StepFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (label: StepLabel, play: PlayFunction<TFramework, TArgs>) => Promise<void> | void;
|
104
|
-
export declare type PlayFunctionContext<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryContext<TFramework, TArgs> & {
|
105
|
-
step: StepFunction<TFramework, TArgs>;
|
106
|
-
};
|
107
|
-
export declare type PlayFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: PlayFunctionContext<TFramework, TArgs>) => Promise<void> | void;
|
108
|
-
export declare type PartialStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (update?: StoryContextUpdate<Partial<TArgs>>) => TFramework['storyResult'];
|
109
|
-
export declare type LegacyStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
|
110
|
-
export declare type ArgsStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (args: TArgs, context: StoryContext<TFramework, TArgs>) => (TFramework & {
|
111
|
-
T: TArgs;
|
112
|
-
})['storyResult'];
|
113
|
-
export declare type StoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = LegacyStoryFn<TFramework, TArgs> | ArgsStoryFn<TFramework, TArgs>;
|
114
|
-
export declare type DecoratorFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (fn: PartialStoryFn<TFramework, TArgs>, c: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
|
115
|
-
export declare type DecoratorApplicator<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (storyFn: LegacyStoryFn<TFramework, TArgs>, decorators: DecoratorFunction<TFramework, TArgs>[]) => LegacyStoryFn<TFramework, TArgs>;
|
116
|
-
export declare type StepRunner<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (label: StepLabel, play: PlayFunction<TFramework, TArgs>, context: PlayFunctionContext<TFramework, TArgs>) => Promise<void>;
|
117
|
-
export declare type BaseAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = {
|
118
|
-
decorators?: DecoratorFunction<TFramework, TArgs>[];
|
119
|
-
parameters?: Parameters;
|
120
|
-
args?: Partial<TArgs>;
|
121
|
-
argTypes?: Partial<ArgTypes<TArgs>>;
|
122
|
-
loaders?: LoaderFunction<TFramework, TArgs>[];
|
123
|
-
render?: ArgsStoryFn<TFramework, TArgs>;
|
124
|
-
};
|
125
|
-
export declare type ProjectAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = BaseAnnotations<TFramework, TArgs> & {
|
126
|
-
argsEnhancers?: ArgsEnhancer<TFramework, Args>[];
|
127
|
-
argTypesEnhancers?: ArgTypesEnhancer<TFramework, Args>[];
|
128
|
-
globals?: Globals;
|
129
|
-
globalTypes?: GlobalTypes;
|
130
|
-
applyDecorators?: DecoratorApplicator<TFramework, Args>;
|
131
|
-
runStep?: StepRunner<TFramework, TArgs>;
|
132
|
-
};
|
133
|
-
declare type StoryDescriptor = string[] | RegExp;
|
134
|
-
export interface ComponentAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> extends BaseAnnotations<TFramework, TArgs> {
|
135
|
-
title?: ComponentTitle;
|
136
|
-
id?: ComponentId;
|
137
|
-
includeStories?: StoryDescriptor;
|
138
|
-
excludeStories?: StoryDescriptor;
|
139
|
-
component?: (TFramework & {
|
140
|
-
T: Args extends TArgs ? any : TArgs;
|
141
|
-
})['component'];
|
142
|
-
subcomponents?: Record<string, TFramework['component']>;
|
143
|
-
}
|
144
|
-
export declare type StoryAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args, TRequiredArgs = Partial<TArgs>> = BaseAnnotations<TFramework, TArgs> & {
|
145
|
-
name?: StoryName;
|
146
|
-
storyName?: StoryName;
|
147
|
-
play?: PlayFunction<TFramework, TArgs>;
|
148
|
-
story?: Omit<StoryAnnotations<TFramework, TArgs>, 'story'>;
|
149
|
-
} & ({} extends TRequiredArgs ? {
|
150
|
-
args?: TRequiredArgs;
|
151
|
-
} : {
|
152
|
-
args: TRequiredArgs;
|
153
|
-
});
|
154
|
-
export declare type LegacyAnnotatedStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryFn<TFramework, TArgs> & StoryAnnotations<TFramework, TArgs>;
|
155
|
-
export declare type LegacyStoryAnnotationsOrFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = LegacyAnnotatedStoryFn<TFramework, TArgs> | StoryAnnotations<TFramework, TArgs>;
|
156
|
-
export declare type AnnotatedStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = ArgsStoryFn<TFramework, TArgs> & StoryAnnotations<TFramework, TArgs>;
|
157
|
-
export declare type StoryAnnotationsOrFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = AnnotatedStoryFn<TFramework, TArgs> | StoryAnnotations<TFramework, TArgs>;
|
158
|
-
export declare type ArgsFromMeta<TFramework extends AnyFramework, Meta> = Meta extends {
|
159
|
-
render?: ArgsStoryFn<TFramework, infer RArgs>;
|
160
|
-
loaders?: (infer Loaders)[];
|
161
|
-
decorators?: (infer Decorators)[];
|
162
|
-
} ? Simplify<RArgs & DecoratorsArgs<TFramework, Decorators> & LoaderArgs<TFramework, Loaders>> : unknown;
|
163
|
-
declare type DecoratorsArgs<TFramework extends AnyFramework, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TFramework, infer Args> ? Args : unknown>;
|
164
|
-
declare type LoaderArgs<TFramework extends AnyFramework, Loaders> = UnionToIntersection<Loaders extends LoaderFunction<TFramework, infer Args> ? Args : unknown>;
|
package/dist/story.js
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
|
7
|
-
var _SBType = require("./SBType");
|
8
|
-
|
9
|
-
Object.keys(_SBType).forEach(function (key) {
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
11
|
-
Object.defineProperty(exports, key, {
|
12
|
-
enumerable: true,
|
13
|
-
get: function get() {
|
14
|
-
return _SBType[key];
|
15
|
-
}
|
16
|
-
});
|
17
|
-
});
|
package/dist/story.test.js
DELETED
@@ -1,236 +0,0 @@
|
|
1
|
-
"use strict";
|
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
|
-
|
7
|
-
// NOTE Example of internal type definition for @storybook/<X> (where X is a framework)
|
8
|
-
// NOTE Examples of using types from @storybook/<X> in real project
|
9
|
-
var Button = function Button(props) {
|
10
|
-
return 'Button';
|
11
|
-
}; // NOTE Various kind usages
|
12
|
-
|
13
|
-
|
14
|
-
var simple = {
|
15
|
-
title: 'simple',
|
16
|
-
component: Button,
|
17
|
-
decorators: [function (storyFn, context) {
|
18
|
-
return "withDecorator(".concat(storyFn(context), ")");
|
19
|
-
}],
|
20
|
-
parameters: {
|
21
|
-
a: function a() {
|
22
|
-
return null;
|
23
|
-
},
|
24
|
-
b: NaN,
|
25
|
-
c: Symbol('symbol')
|
26
|
-
},
|
27
|
-
loaders: [function () {
|
28
|
-
return Promise.resolve({
|
29
|
-
d: '3'
|
30
|
-
});
|
31
|
-
}],
|
32
|
-
args: {
|
33
|
-
x: '1'
|
34
|
-
},
|
35
|
-
argTypes: {
|
36
|
-
x: {
|
37
|
-
type: {
|
38
|
-
name: 'string'
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}
|
42
|
-
};
|
43
|
-
var strict = {
|
44
|
-
title: 'simple',
|
45
|
-
component: Button,
|
46
|
-
decorators: [function (storyFn, context) {
|
47
|
-
return "withDecorator(".concat(storyFn(context), ")");
|
48
|
-
}],
|
49
|
-
parameters: {
|
50
|
-
a: function a() {
|
51
|
-
return null;
|
52
|
-
},
|
53
|
-
b: NaN,
|
54
|
-
c: Symbol('symbol')
|
55
|
-
},
|
56
|
-
loaders: [function () {
|
57
|
-
return Promise.resolve({
|
58
|
-
d: '3'
|
59
|
-
});
|
60
|
-
}],
|
61
|
-
args: {
|
62
|
-
x: '1'
|
63
|
-
},
|
64
|
-
argTypes: {
|
65
|
-
x: {
|
66
|
-
type: {
|
67
|
-
name: 'string'
|
68
|
-
}
|
69
|
-
}
|
70
|
-
}
|
71
|
-
}; // NOTE Various story usages
|
72
|
-
|
73
|
-
var Simple = function Simple() {
|
74
|
-
return 'Simple';
|
75
|
-
};
|
76
|
-
|
77
|
-
var CSF1Story = function CSF1Story() {
|
78
|
-
return 'Named Story';
|
79
|
-
};
|
80
|
-
|
81
|
-
CSF1Story.story = {
|
82
|
-
name: 'Another name for story',
|
83
|
-
decorators: [function (storyFn) {
|
84
|
-
return "Wrapped(".concat(storyFn());
|
85
|
-
}],
|
86
|
-
parameters: {
|
87
|
-
a: [1, '2', {}],
|
88
|
-
b: undefined,
|
89
|
-
c: Button
|
90
|
-
},
|
91
|
-
loaders: [function () {
|
92
|
-
return Promise.resolve({
|
93
|
-
d: '3'
|
94
|
-
});
|
95
|
-
}],
|
96
|
-
args: {
|
97
|
-
a: 1
|
98
|
-
}
|
99
|
-
};
|
100
|
-
|
101
|
-
var CSF2Story = function CSF2Story() {
|
102
|
-
return 'Named Story';
|
103
|
-
};
|
104
|
-
|
105
|
-
CSF2Story.storyName = 'Another name for story';
|
106
|
-
CSF2Story.decorators = [function (storyFn) {
|
107
|
-
return "Wrapped(".concat(storyFn());
|
108
|
-
}];
|
109
|
-
CSF2Story.parameters = {
|
110
|
-
a: [1, '2', {}],
|
111
|
-
b: undefined,
|
112
|
-
c: Button
|
113
|
-
};
|
114
|
-
CSF2Story.loaders = [function () {
|
115
|
-
return Promise.resolve({
|
116
|
-
d: '3'
|
117
|
-
});
|
118
|
-
}];
|
119
|
-
CSF2Story.args = {
|
120
|
-
a: 1
|
121
|
-
};
|
122
|
-
var CSF3Story = {
|
123
|
-
render: function render(args) {
|
124
|
-
return 'Named Story';
|
125
|
-
},
|
126
|
-
name: 'Another name for story',
|
127
|
-
decorators: [function (storyFn) {
|
128
|
-
return "Wrapped(".concat(storyFn());
|
129
|
-
}],
|
130
|
-
parameters: {
|
131
|
-
a: [1, '2', {}],
|
132
|
-
b: undefined,
|
133
|
-
c: Button
|
134
|
-
},
|
135
|
-
loaders: [function () {
|
136
|
-
return Promise.resolve({
|
137
|
-
d: '3'
|
138
|
-
});
|
139
|
-
}],
|
140
|
-
args: {
|
141
|
-
a: 1
|
142
|
-
}
|
143
|
-
};
|
144
|
-
var CSF3StoryStrict = {
|
145
|
-
render: function render(args) {
|
146
|
-
return 'Named Story';
|
147
|
-
},
|
148
|
-
name: 'Another name for story',
|
149
|
-
decorators: [function (storyFn) {
|
150
|
-
return "Wrapped(".concat(storyFn());
|
151
|
-
}],
|
152
|
-
parameters: {
|
153
|
-
a: [1, '2', {}],
|
154
|
-
b: undefined,
|
155
|
-
c: Button
|
156
|
-
},
|
157
|
-
loaders: [function () {
|
158
|
-
return Promise.resolve({
|
159
|
-
d: '3'
|
160
|
-
});
|
161
|
-
}],
|
162
|
-
args: {
|
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
|
-
}))();
|
229
|
-
}
|
230
|
-
}; // NOTE Jest forced to define at least one test in file
|
231
|
-
|
232
|
-
describe('story', function () {
|
233
|
-
test('true', function () {
|
234
|
-
return expect(true).toBe(true);
|
235
|
-
});
|
236
|
-
});
|