@storybook/csf 0.1.9--canary.96.46e1c3c.0 → 0.1.9--canary.91.b332918.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.ts +24 -35
- package/dist/index.js +5 -5
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
@@ -215,15 +215,16 @@ interface GlobalTypes {
|
|
215
215
|
interface StrictGlobalTypes {
|
216
216
|
[name: string]: StrictInputType;
|
217
217
|
}
|
218
|
-
|
218
|
+
interface Renderer {
|
219
219
|
/** What is the type of the `component` annotation in this renderer? */
|
220
220
|
component: unknown;
|
221
221
|
/** What does the story function return in this renderer? */
|
222
222
|
storyResult: unknown;
|
223
223
|
/** What type of element does this renderer render to? */
|
224
224
|
canvasElement: unknown;
|
225
|
+
mount(): Promise<Canvas>;
|
225
226
|
T?: unknown;
|
226
|
-
}
|
227
|
+
}
|
227
228
|
/** @deprecated - use `Renderer` */
|
228
229
|
type AnyFramework = Renderer;
|
229
230
|
interface StoryContextForEnhancers<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryIdentifier {
|
@@ -247,26 +248,30 @@ interface StoryContextUpdate<TArgs = Args> {
|
|
247
248
|
[key: string]: any;
|
248
249
|
}
|
249
250
|
type ViewMode = 'story' | 'docs';
|
250
|
-
interface StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryContextForEnhancers<TRenderer, TArgs>, Required<StoryContextUpdate<TArgs>> {
|
251
|
-
hooks: unknown;
|
252
|
-
viewMode: ViewMode;
|
253
|
-
originalStoryFn: StoryFn<TRenderer>;
|
254
|
-
}
|
255
251
|
type LoaderFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContextForLoaders<TRenderer, TArgs>) => Promise<Record<string, any> | void> | Record<string, any> | void;
|
256
252
|
type Awaitable<T> = T | PromiseLike<T>;
|
257
253
|
type CleanupCallback = () => Awaitable<unknown>;
|
258
|
-
type BeforeAll = () => Awaitable<CleanupCallback | void>;
|
259
254
|
type BeforeEach<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContext<TRenderer, TArgs>) => Awaitable<CleanupCallback | void>;
|
260
|
-
interface
|
255
|
+
interface Canvas {
|
256
|
+
}
|
257
|
+
interface StoryContext<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryContextForEnhancers<TRenderer, TArgs>, Required<StoryContextUpdate<TArgs>> {
|
258
|
+
hooks: unknown;
|
259
|
+
viewMode: ViewMode;
|
260
|
+
originalStoryFn: StoryFn<TRenderer>;
|
261
261
|
loaded: Record<string, any>;
|
262
262
|
abortSignal: AbortSignal;
|
263
263
|
canvasElement: TRenderer['canvasElement'];
|
264
|
+
canvas: Canvas;
|
265
|
+
step: StepFunction<TRenderer, TArgs>;
|
266
|
+
mount: TRenderer['mount'];
|
267
|
+
context: this;
|
268
|
+
}
|
269
|
+
interface StoryContextForLoaders<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryContext<TRenderer, TArgs> {
|
270
|
+
}
|
271
|
+
interface PlayFunctionContext<TRenderer extends Renderer = Renderer, TArgs = Args> extends StoryContext<TRenderer, TArgs> {
|
264
272
|
}
|
265
273
|
type StepLabel = string;
|
266
274
|
type StepFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (label: StepLabel, play: PlayFunction<TRenderer, TArgs>) => Promise<void> | void;
|
267
|
-
type PlayFunctionContext<TRenderer extends Renderer = Renderer, TArgs = Args> = StoryContext<TRenderer, TArgs> & {
|
268
|
-
step: StepFunction<TRenderer, TArgs>;
|
269
|
-
};
|
270
275
|
type PlayFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: PlayFunctionContext<TRenderer, TArgs>) => Promise<void> | void;
|
271
276
|
type PartialStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (update?: StoryContextUpdate<Partial<TArgs>>) => TRenderer['storyResult'];
|
272
277
|
type LegacyStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (context: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
|
@@ -276,8 +281,8 @@ type ArgsStoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = (args: T
|
|
276
281
|
type StoryFn<TRenderer extends Renderer = Renderer, TArgs = Args> = LegacyStoryFn<TRenderer, TArgs> | ArgsStoryFn<TRenderer, TArgs>;
|
277
282
|
type DecoratorFunction<TRenderer extends Renderer = Renderer, TArgs = Args> = (fn: PartialStoryFn<TRenderer, TArgs>, c: StoryContext<TRenderer, TArgs>) => TRenderer['storyResult'];
|
278
283
|
type DecoratorApplicator<TRenderer extends Renderer = Renderer, TArgs = Args> = (storyFn: LegacyStoryFn<TRenderer, TArgs>, decorators: DecoratorFunction<TRenderer, TArgs>[]) => LegacyStoryFn<TRenderer, TArgs>;
|
279
|
-
type StepRunner<TRenderer extends Renderer = Renderer, TArgs = Args> = (label: StepLabel, play: PlayFunction<TRenderer, TArgs>, context:
|
280
|
-
|
284
|
+
type StepRunner<TRenderer extends Renderer = Renderer, TArgs = Args> = (label: StepLabel, play: PlayFunction<TRenderer, TArgs>, context: StoryContext<TRenderer, TArgs>) => Promise<void>;
|
285
|
+
interface BaseAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> {
|
281
286
|
/**
|
282
287
|
* Wrapper components or Storybook decorators that wrap a story.
|
283
288
|
*
|
@@ -322,24 +327,16 @@ type BaseAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> = {
|
|
322
327
|
* Named tags for a story, used to filter stories in different contexts.
|
323
328
|
*/
|
324
329
|
tags?: Tag[];
|
325
|
-
|
326
|
-
|
330
|
+
mount?: (context: StoryContext<TRenderer, TArgs>) => TRenderer['mount'];
|
331
|
+
}
|
332
|
+
interface ProjectAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> extends BaseAnnotations<TRenderer, TArgs> {
|
327
333
|
argsEnhancers?: ArgsEnhancer<TRenderer, Args>[];
|
328
334
|
argTypesEnhancers?: ArgTypesEnhancer<TRenderer, Args>[];
|
329
|
-
/**
|
330
|
-
* Function to be called once, before rendering any story. When the function is async, it will be awaited.
|
331
|
-
* A cleanup function may be returned. This function may only be defined globally.
|
332
|
-
*/
|
333
|
-
beforeAll?: BeforeAll;
|
334
|
-
/**
|
335
|
-
* @deprecated Project `globals` renamed to `initiaGlobals`
|
336
|
-
*/
|
337
335
|
globals?: Globals;
|
338
|
-
initialGlobals?: Globals;
|
339
336
|
globalTypes?: GlobalTypes;
|
340
337
|
applyDecorators?: DecoratorApplicator<TRenderer, Args>;
|
341
338
|
runStep?: StepRunner<TRenderer, TArgs>;
|
342
|
-
}
|
339
|
+
}
|
343
340
|
type StoryDescriptor$1 = string[] | RegExp;
|
344
341
|
interface ComponentAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args> extends BaseAnnotations<TRenderer, TArgs> {
|
345
342
|
/**
|
@@ -412,10 +409,6 @@ interface ComponentAnnotations<TRenderer extends Renderer = Renderer, TArgs = Ar
|
|
412
409
|
* Function that is executed after the story is rendered.
|
413
410
|
*/
|
414
411
|
play?: PlayFunction<TRenderer, TArgs>;
|
415
|
-
/**
|
416
|
-
* Override the globals values for all stories in this component
|
417
|
-
*/
|
418
|
-
globals?: Globals;
|
419
412
|
}
|
420
413
|
type StoryAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args, TRequiredArgs = Partial<TArgs>> = BaseAnnotations<TRenderer, TArgs> & {
|
421
414
|
/**
|
@@ -430,10 +423,6 @@ type StoryAnnotations<TRenderer extends Renderer = Renderer, TArgs = Args, TRequ
|
|
430
423
|
* Function that is executed after the story is rendered.
|
431
424
|
*/
|
432
425
|
play?: PlayFunction<TRenderer, TArgs>;
|
433
|
-
/**
|
434
|
-
* Override the globals values for this story
|
435
|
-
*/
|
436
|
-
globals?: Globals;
|
437
426
|
/** @deprecated */
|
438
427
|
story?: Omit<StoryAnnotations<TRenderer, TArgs>, 'story'>;
|
439
428
|
} & ({} extends TRequiredArgs ? {
|
@@ -498,4 +487,4 @@ declare const parseKind: (kind: string, { rootSeparator, groupSeparator }: Separ
|
|
498
487
|
*/
|
499
488
|
declare const combineTags: (...tags: string[]) => string[];
|
500
489
|
|
501
|
-
export { AnnotatedStoryFn, AnyFramework, ArgTypes, ArgTypesEnhancer, Args, ArgsEnhancer, ArgsFromMeta, ArgsStoryFn, BaseAnnotations,
|
490
|
+
export { AnnotatedStoryFn, AnyFramework, ArgTypes, ArgTypesEnhancer, Args, ArgsEnhancer, ArgsFromMeta, ArgsStoryFn, BaseAnnotations, BeforeEach, Canvas, CleanupCallback, ComponentAnnotations, ComponentId, ComponentTitle, Conditional, DecoratorApplicator, DecoratorFunction, GlobalTypes, Globals, IncludeExcludeOptions, InputType, LegacyAnnotatedStoryFn, LegacyStoryAnnotationsOrFn, LegacyStoryFn, LoaderFunction, Parameters, PartialStoryFn, PlayFunction, PlayFunctionContext, ProjectAnnotations, Renderer, SBArrayType, SBEnumType, SBIntersectionType, SBObjectType, SBOtherType, SBScalarType, SBType, SBUnionType, SeparatorOptions, StepFunction, StepLabel, StepRunner, StoryAnnotations, StoryAnnotationsOrFn, StoryContext, StoryContextForEnhancers, StoryContextForLoaders, StoryContextUpdate, StoryFn, StoryId, StoryIdentifier, StoryKind, StoryName, StrictArgTypes, StrictArgs, StrictGlobalTypes, StrictInputType, StrictParameters, Tag, ViewMode, combineTags, includeConditionalArg, isExportStory, parseKind, sanitize, storyNameFromExport, toId };
|
package/dist/index.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
var
|
3
|
+
var C=Object.create;var u=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var v=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var E=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of F(e))!w.call(r,a)&&a!==n&&u(r,a,{get:()=>e[a],enumerable:!(t=B(e,a))||t.enumerable});return r};var I=(r,e,n)=>(n=r!=null?C(h(r)):{},E(e||!r||!r.__esModule?u(n,"default",{value:r,enumerable:!0}):n,r));var x=v(T=>{Object.defineProperty(T,"__esModule",{value:!0}),T.isEqual=function(){var r=Object.prototype.toString,e=Object.getPrototypeOf,n=Object.getOwnPropertySymbols?function(t){return Object.keys(t).concat(Object.getOwnPropertySymbols(t))}:Object.keys;return function(t,a){return function i(o,s,p){var y,g,d,l=r.call(o),b=r.call(s);if(o===s)return !0;if(o==null||s==null)return !1;if(p.indexOf(o)>-1&&p.indexOf(s)>-1)return !0;if(p.push(o,s),l!=b||(y=n(o),g=n(s),y.length!=g.length||y.some(function(A){return !i(o[A],s[A],p)})))return !1;switch(l.slice(8,-1)){case"Symbol":return o.valueOf()==s.valueOf();case"Date":case"Number":return +o==+s||+o!=+o&&+s!=+s;case"RegExp":case"Function":case"String":case"Boolean":return ""+o==""+s;case"Set":case"Map":y=o.entries(),g=s.entries();do if(!i((d=y.next()).value,g.next().value,p))return !1;while(!d.done);return !0;case"ArrayBuffer":o=new Uint8Array(o),s=new Uint8Array(s);case"DataView":o=new Uint8Array(o.buffer),s=new Uint8Array(s.buffer);case"Float32Array":case"Float64Array":case"Int8Array":case"Int16Array":case"Int32Array":case"Uint8Array":case"Uint16Array":case"Uint32Array":case"Uint8ClampedArray":case"Arguments":case"Array":if(o.length!=s.length)return !1;for(d=0;d<o.length;d++)if((d in o||d in s)&&(d in o!=d in s||!i(o[d],s[d],p)))return !1;return !0;case"Object":return i(e(o),e(s),p);default:return !1}}(t,a,[])}}();});function R(r){return r.replace(/_/g," ").replace(/-/g," ").replace(/\./g," ").replace(/([^\n])([A-Z])([a-z])/g,(e,n,t,a)=>`${n} ${t}${a}`).replace(/([a-z])([A-Z])/g,(e,n,t)=>`${n} ${t}`).replace(/([a-z])([0-9])/gi,(e,n,t)=>`${n} ${t}`).replace(/([0-9])([a-z])/gi,(e,n,t)=>`${n} ${t}`).replace(/(\s|^)(\w)/g,(e,n,t)=>`${n}${t.toUpperCase()}`).replace(/ +/g," ").trim()}var c=I(x()),S=r=>r.map(e=>typeof e<"u").filter(Boolean).length,P=(r,e)=>{let{exists:n,eq:t,neq:a,truthy:i}=r;if(S([n,t,a,i])>1)throw new Error(`Invalid conditional test ${JSON.stringify({exists:n,eq:t,neq:a})}`);if(typeof t<"u")return (0, c.isEqual)(e,t);if(typeof a<"u")return !(0, c.isEqual)(e,a);if(typeof n<"u"){let s=typeof e<"u";return n?s:!s}return (typeof i>"u"?!0:i)?!!e:!e},k=(r,e,n)=>{if(!r.if)return !0;let{arg:t,global:a}=r.if;if(S([t,a])!==1)throw new Error(`Invalid conditional value ${JSON.stringify({arg:t,global:a})}`);let i=t?e[t]:n[a];return P(r.if,i)};var O=r=>r.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi,"-").replace(/-+/g,"-").replace(/^-+/,"").replace(/-+$/,""),m=(r,e)=>{let n=O(r);if(n==="")throw new Error(`Invalid ${e} '${r}', must include alphanumeric characters`);return n},N=(r,e)=>`${m(r,"kind")}${e?`--${m(e,"name")}`:""}`,M=r=>R(r);function f(r,e){return Array.isArray(e)?e.includes(r):r.match(e)}function G(r,{includeStories:e,excludeStories:n}){return r!=="__esModule"&&(!e||f(r,e))&&(!n||!f(r,n))}var V=(r,{rootSeparator:e,groupSeparator:n})=>{let[t,a]=r.split(e,2),i=(a||r).split(n).filter(o=>!!o);return {root:a?t:null,groups:i}},z=(...r)=>{let e=r.reduce((n,t)=>(t.startsWith("!")?n.delete(t.slice(1)):n.add(t),n),new Set);return Array.from(e)};
|
4
4
|
|
5
5
|
exports.combineTags = z;
|
6
|
-
exports.includeConditionalArg =
|
7
|
-
exports.isExportStory =
|
6
|
+
exports.includeConditionalArg = k;
|
7
|
+
exports.isExportStory = G;
|
8
8
|
exports.parseKind = V;
|
9
9
|
exports.sanitize = O;
|
10
|
-
exports.storyNameFromExport =
|
11
|
-
exports.toId =
|
10
|
+
exports.storyNameFromExport = M;
|
11
|
+
exports.toId = N;
|
package/dist/index.mjs
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
var
|
1
|
+
var C=Object.create;var u=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var v=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var E=(r,e,n,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of F(e))!w.call(r,a)&&a!==n&&u(r,a,{get:()=>e[a],enumerable:!(t=B(e,a))||t.enumerable});return r};var I=(r,e,n)=>(n=r!=null?C(h(r)):{},E(e||!r||!r.__esModule?u(n,"default",{value:r,enumerable:!0}):n,r));var x=v(T=>{Object.defineProperty(T,"__esModule",{value:!0}),T.isEqual=function(){var r=Object.prototype.toString,e=Object.getPrototypeOf,n=Object.getOwnPropertySymbols?function(t){return Object.keys(t).concat(Object.getOwnPropertySymbols(t))}:Object.keys;return function(t,a){return function i(o,s,p){var y,g,d,l=r.call(o),b=r.call(s);if(o===s)return !0;if(o==null||s==null)return !1;if(p.indexOf(o)>-1&&p.indexOf(s)>-1)return !0;if(p.push(o,s),l!=b||(y=n(o),g=n(s),y.length!=g.length||y.some(function(A){return !i(o[A],s[A],p)})))return !1;switch(l.slice(8,-1)){case"Symbol":return o.valueOf()==s.valueOf();case"Date":case"Number":return +o==+s||+o!=+o&&+s!=+s;case"RegExp":case"Function":case"String":case"Boolean":return ""+o==""+s;case"Set":case"Map":y=o.entries(),g=s.entries();do if(!i((d=y.next()).value,g.next().value,p))return !1;while(!d.done);return !0;case"ArrayBuffer":o=new Uint8Array(o),s=new Uint8Array(s);case"DataView":o=new Uint8Array(o.buffer),s=new Uint8Array(s.buffer);case"Float32Array":case"Float64Array":case"Int8Array":case"Int16Array":case"Int32Array":case"Uint8Array":case"Uint16Array":case"Uint32Array":case"Uint8ClampedArray":case"Arguments":case"Array":if(o.length!=s.length)return !1;for(d=0;d<o.length;d++)if((d in o||d in s)&&(d in o!=d in s||!i(o[d],s[d],p)))return !1;return !0;case"Object":return i(e(o),e(s),p);default:return !1}}(t,a,[])}}();});function R(r){return r.replace(/_/g," ").replace(/-/g," ").replace(/\./g," ").replace(/([^\n])([A-Z])([a-z])/g,(e,n,t,a)=>`${n} ${t}${a}`).replace(/([a-z])([A-Z])/g,(e,n,t)=>`${n} ${t}`).replace(/([a-z])([0-9])/gi,(e,n,t)=>`${n} ${t}`).replace(/([0-9])([a-z])/gi,(e,n,t)=>`${n} ${t}`).replace(/(\s|^)(\w)/g,(e,n,t)=>`${n}${t.toUpperCase()}`).replace(/ +/g," ").trim()}var c=I(x()),S=r=>r.map(e=>typeof e<"u").filter(Boolean).length,P=(r,e)=>{let{exists:n,eq:t,neq:a,truthy:i}=r;if(S([n,t,a,i])>1)throw new Error(`Invalid conditional test ${JSON.stringify({exists:n,eq:t,neq:a})}`);if(typeof t<"u")return (0, c.isEqual)(e,t);if(typeof a<"u")return !(0, c.isEqual)(e,a);if(typeof n<"u"){let s=typeof e<"u";return n?s:!s}return (typeof i>"u"?!0:i)?!!e:!e},k=(r,e,n)=>{if(!r.if)return !0;let{arg:t,global:a}=r.if;if(S([t,a])!==1)throw new Error(`Invalid conditional value ${JSON.stringify({arg:t,global:a})}`);let i=t?e[t]:n[a];return P(r.if,i)};var O=r=>r.toLowerCase().replace(/[ ’–—―′¿'`~!@#$%^&*()_|+\-=?;:'",.<>\{\}\[\]\\\/]/gi,"-").replace(/-+/g,"-").replace(/^-+/,"").replace(/-+$/,""),m=(r,e)=>{let n=O(r);if(n==="")throw new Error(`Invalid ${e} '${r}', must include alphanumeric characters`);return n},N=(r,e)=>`${m(r,"kind")}${e?`--${m(e,"name")}`:""}`,M=r=>R(r);function f(r,e){return Array.isArray(e)?e.includes(r):r.match(e)}function G(r,{includeStories:e,excludeStories:n}){return r!=="__esModule"&&(!e||f(r,e))&&(!n||!f(r,n))}var V=(r,{rootSeparator:e,groupSeparator:n})=>{let[t,a]=r.split(e,2),i=(a||r).split(n).filter(o=>!!o);return {root:a?t:null,groups:i}},z=(...r)=>{let e=r.reduce((n,t)=>(t.startsWith("!")?n.delete(t.slice(1)):n.add(t),n),new Set);return Array.from(e)};
|
2
2
|
|
3
|
-
export { z as combineTags,
|
3
|
+
export { z as combineTags, k as includeConditionalArg, G as isExportStory, V as parseKind, O as sanitize, M as storyNameFromExport, N as toId };
|