@storybook/csf 0.0.2--canary.49.258942b.0 → 0.0.2--canary.51.23af5af.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/story.d.ts DELETED
@@ -1,154 +0,0 @@
1
- import { SBType, SBScalarType } from './SBType';
2
- export * from './SBType';
3
- export declare type StoryId = string;
4
- export declare type ComponentId = string;
5
- export declare type ComponentTitle = string;
6
- export declare type StoryName = string;
7
- export declare type StoryKind = ComponentTitle;
8
- export interface StoryIdentifier {
9
- componentId: ComponentId;
10
- title: ComponentTitle;
11
- kind: ComponentTitle;
12
- id: StoryId;
13
- name: StoryName;
14
- story: StoryName;
15
- }
16
- export declare type Parameters = {
17
- [name: string]: any;
18
- };
19
- declare type ConditionalTest = {
20
- truthy?: boolean;
21
- } | {
22
- exists: boolean;
23
- } | {
24
- eq: any;
25
- } | {
26
- neq: any;
27
- };
28
- declare type ConditionalValue = {
29
- arg: string;
30
- } | {
31
- global: string;
32
- };
33
- export declare type Conditional = ConditionalValue & ConditionalTest;
34
- export interface InputType {
35
- name?: string;
36
- description?: string;
37
- defaultValue?: any;
38
- type?: SBType | SBScalarType['name'];
39
- if?: Conditional;
40
- [key: string]: any;
41
- }
42
- export interface StrictInputType extends InputType {
43
- name: string;
44
- type?: SBType;
45
- }
46
- export declare type Args = {
47
- [name: string]: any;
48
- };
49
- export declare type ArgTypes<TArgs = Args> = {
50
- [name in keyof TArgs]: InputType;
51
- };
52
- export declare type StrictArgTypes<TArgs = Args> = {
53
- [name in keyof TArgs]: StrictInputType;
54
- };
55
- export declare type Globals = {
56
- [name: string]: any;
57
- };
58
- export declare type GlobalTypes = {
59
- [name: string]: InputType;
60
- };
61
- export declare type StrictGlobalTypes = {
62
- [name: string]: StrictInputType;
63
- };
64
- export declare type AnyFramework = {
65
- component: unknown;
66
- storyResult: unknown;
67
- T?: unknown;
68
- };
69
- export declare type StoryContextForEnhancers<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryIdentifier & {
70
- component?: (TFramework & {
71
- T: any;
72
- })['component'];
73
- subcomponents?: Record<string, (TFramework & {
74
- T: any;
75
- })['component']>;
76
- parameters: Parameters;
77
- initialArgs: TArgs;
78
- argTypes: StrictArgTypes<TArgs>;
79
- };
80
- export declare type ArgsEnhancer<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContextForEnhancers<TFramework, TArgs>) => TArgs;
81
- export declare type ArgTypesEnhancer<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = ((context: StoryContextForEnhancers<TFramework, TArgs>) => StrictArgTypes<TArgs>) & {
82
- secondPass?: boolean;
83
- };
84
- export declare type StoryContextUpdate<TArgs = Args> = {
85
- args?: TArgs;
86
- globals?: Globals;
87
- [key: string]: any;
88
- };
89
- export declare type ViewMode = 'story' | 'docs';
90
- export declare type StoryContextForLoaders<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryContextForEnhancers<TFramework, TArgs> & Required<StoryContextUpdate<TArgs>> & {
91
- hooks: unknown;
92
- viewMode: ViewMode;
93
- originalStoryFn: StoryFn<TFramework>;
94
- };
95
- export declare type LoaderFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContextForLoaders<TFramework, TArgs>) => Promise<Record<string, any>>;
96
- export declare type StoryContext<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryContextForLoaders<TFramework, TArgs> & {
97
- loaded: Record<string, any>;
98
- abortSignal: AbortSignal;
99
- canvasElement: HTMLElement;
100
- };
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'];
108
- export declare type LegacyStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (context: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
109
- export declare type ArgsStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (args: TArgs, context: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
110
- export declare type StoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = LegacyStoryFn<TFramework, TArgs> | ArgsStoryFn<TFramework, TArgs>;
111
- export declare type DecoratorFunction<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = (fn: PartialStoryFn<TFramework, TArgs>, c: StoryContext<TFramework, TArgs>) => TFramework['storyResult'];
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>;
114
- export declare type BaseAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = {
115
- decorators?: DecoratorFunction<TFramework, TArgs>[];
116
- parameters?: Parameters;
117
- args?: Partial<TArgs>;
118
- argTypes?: Partial<ArgTypes<TArgs>>;
119
- loaders?: LoaderFunction<TFramework, TArgs>[];
120
- render?: ArgsStoryFn<TFramework, TArgs>;
121
- };
122
- export declare type ProjectAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = BaseAnnotations<TFramework, TArgs> & {
123
- argsEnhancers?: ArgsEnhancer<TFramework, Args>[];
124
- argTypesEnhancers?: ArgTypesEnhancer<TFramework, Args>[];
125
- globals?: Globals;
126
- globalTypes?: GlobalTypes;
127
- applyDecorators?: DecoratorApplicator<TFramework, Args>;
128
- runStep?: StepRunner<TFramework, TArgs>;
129
- };
130
- declare type StoryDescriptor = string[] | RegExp;
131
- export interface ComponentAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args> extends BaseAnnotations<TFramework, TArgs> {
132
- title?: ComponentTitle;
133
- id?: ComponentId;
134
- includeStories?: StoryDescriptor;
135
- excludeStories?: StoryDescriptor;
136
- component?: (TFramework & {
137
- T: Args extends TArgs ? any : TArgs;
138
- })['component'];
139
- subcomponents?: Record<string, TFramework['component']>;
140
- }
141
- export declare type StoryAnnotations<TFramework extends AnyFramework = AnyFramework, TArgs = Args, TRequiredArgs = Partial<TArgs>> = BaseAnnotations<TFramework, TArgs> & {
142
- name?: StoryName;
143
- storyName?: StoryName;
144
- play?: PlayFunction<TFramework, TArgs>;
145
- story?: Omit<StoryAnnotations<TFramework, TArgs>, 'story'>;
146
- } & ({} extends TRequiredArgs ? {
147
- args?: TRequiredArgs;
148
- } : {
149
- args: TRequiredArgs;
150
- });
151
- export declare type LegacyAnnotatedStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = StoryFn<TFramework, TArgs> & StoryAnnotations<TFramework, TArgs>;
152
- export declare type LegacyStoryAnnotationsOrFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = LegacyAnnotatedStoryFn<TFramework, TArgs> | StoryAnnotations<TFramework, TArgs>;
153
- export declare type AnnotatedStoryFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = ArgsStoryFn<TFramework, TArgs> & StoryAnnotations<TFramework, TArgs>;
154
- export declare type StoryAnnotationsOrFn<TFramework extends AnyFramework = AnyFramework, TArgs = Args> = AnnotatedStoryFn<TFramework, TArgs> | StoryAnnotations<TFramework, TArgs>;
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
- });
@@ -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
- });