storybook 10.2.0-alpha.15 → 10.2.0-alpha.17
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/_node-chunks/{builder-manager-SOKYB5NF.js → builder-manager-Q4F5VX5J.js} +14 -12
- package/dist/_node-chunks/{camelcase-SXQWF7PW.js → camelcase-FL6OBJRZ.js} +7 -7
- package/dist/_node-chunks/{chunk-5KEIALUH.js → chunk-25OWI2RR.js} +6 -6
- package/dist/_node-chunks/{chunk-ENNDE4GC.js → chunk-2XSHQN7K.js} +10 -10
- package/dist/_node-chunks/{chunk-E3Y5MHXD.js → chunk-3D4SLKEE.js} +7 -7
- package/dist/_node-chunks/{chunk-FKBWQGIF.js → chunk-5Q5JEISY.js} +6 -6
- package/dist/_node-chunks/{chunk-Q6WUEJ4S.js → chunk-C3FPVGL4.js} +6 -6
- package/dist/_node-chunks/chunk-CBPOKBOR.js +18 -0
- package/dist/_node-chunks/{chunk-2FQAOAQ6.js → chunk-CCJGKJ27.js} +12 -12
- package/dist/_node-chunks/{chunk-MD52RVZX.js → chunk-DJ3RRSJ7.js} +7 -7
- package/dist/_node-chunks/chunk-EG3WZ464.js +23 -0
- package/dist/_node-chunks/{chunk-6SIUW3HU.js → chunk-EYPTVKFI.js} +123 -72
- package/dist/_node-chunks/{chunk-TN3Q52LO.js → chunk-FAARRTOD.js} +6 -6
- package/dist/_node-chunks/{chunk-QPKBPYOY.js → chunk-G7P42ZEY.js} +7 -7
- package/dist/_node-chunks/chunk-GYJ7LPFJ.js +144 -0
- package/dist/_node-chunks/{chunk-BOY3TNPC.js → chunk-IRMNO3QS.js} +9 -9
- package/dist/_node-chunks/{chunk-BRW7NFUP.js → chunk-IWM3WHZE.js} +7 -7
- package/dist/_node-chunks/{chunk-RGWB6DD7.js → chunk-JBRILZWU.js} +6 -6
- package/dist/_node-chunks/{chunk-HFKM7JHQ.js → chunk-KKNWPXMS.js} +6 -6
- package/dist/_node-chunks/{chunk-45UIB4YF.js → chunk-MU4E5UBA.js} +7 -7
- package/dist/_node-chunks/{chunk-274OMYGE.js → chunk-PWI3ORDV.js} +22 -22
- package/dist/_node-chunks/chunk-RGEHGZS6.js +61 -0
- package/dist/_node-chunks/{chunk-KNGN3UEO.js → chunk-V3SFCYKQ.js} +7 -7
- package/dist/_node-chunks/{chunk-4GKVZO2T.js → chunk-VK4OWRKU.js} +9 -9
- package/dist/_node-chunks/{chunk-K4YVLJRS.js → chunk-VT2FICF4.js} +6 -6
- package/dist/_node-chunks/{chunk-SZWIX5YC.js → chunk-VTBZVEBF.js} +529 -142
- package/dist/_node-chunks/{chunk-T57UCO67.js → chunk-XI7HDOMY.js} +7 -7
- package/dist/_node-chunks/{chunk-PI7P5HFH.js → chunk-XTIFAWOB.js} +250 -14
- package/dist/_node-chunks/{chunk-AIIQJ6UR.js → chunk-XYONORVT.js} +7 -7
- package/dist/_node-chunks/{chunk-MQZLLJRG.js → chunk-ZOUBYBCH.js} +9 -9
- package/dist/_node-chunks/{globby-LGQ5P2JB.js → globby-4BDMCAAD.js} +9 -9
- package/dist/_node-chunks/{lib-5LBLULG3.js → lib-XS2XQMOO.js} +7 -7
- package/dist/_node-chunks/{mdx-N42X6CFJ-TAPL5IEO.js → mdx-N42X6CFJ-JFERGMQH.js} +8 -8
- package/dist/_node-chunks/{p-limit-GTMOHYQF.js → p-limit-I4CLTHWH.js} +7 -7
- package/dist/babel/index.js +10 -10
- package/dist/bin/core.js +12 -12
- package/dist/bin/dispatcher.js +11 -11
- package/dist/bin/loader.js +9 -9
- package/dist/cli/index.js +18 -18
- package/dist/common/index.js +19 -19
- package/dist/core-events/index.d.ts +19 -3
- package/dist/core-events/index.js +5 -1
- package/dist/core-server/index.d.ts +64 -2
- package/dist/core-server/index.js +37 -34
- package/dist/core-server/presets/common-override-preset.js +11 -11
- package/dist/core-server/presets/common-preset.js +532 -234
- package/dist/csf/index.d.ts +139 -9
- package/dist/csf/index.js +41 -14
- package/dist/csf-tools/index.d.ts +19 -1
- package/dist/csf-tools/index.js +11 -10
- package/dist/manager/globals-runtime.js +6 -2
- package/dist/manager/runtime.js +17 -98
- package/dist/manager-api/index.js +1 -1
- package/dist/mocking-utils/index.js +8 -8
- package/dist/node-logger/index.js +9 -9
- package/dist/preview/runtime.js +33 -6
- package/dist/preview-api/index.d.ts +68 -67
- package/dist/server-errors.js +11 -11
- package/dist/telemetry/index.d.ts +13 -2
- package/dist/telemetry/index.js +23 -22
- package/package.json +1 -1
- package/dist/_node-chunks/chunk-2BHD5YKF.js +0 -35
- package/dist/_node-chunks/chunk-MM7Z4SG7.js +0 -23
- package/dist/_node-chunks/chunk-TYSSQECX.js +0 -61
- package/dist/_node-chunks/chunk-YP34ARUD.js +0 -18
package/dist/csf/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StorybookTypes, Renderer as Renderer$1, ProjectAnnotations as ProjectAnnotations$1, NormalizedProjectAnnotations,
|
|
1
|
+
import { StorybookTypes, Renderer as Renderer$1, ProjectAnnotations as ProjectAnnotations$1, NormalizedProjectAnnotations, ComponentAnnotations as ComponentAnnotations$1, StoryAnnotations as StoryAnnotations$1, ComposedStoryFn, TestFunction as TestFunction$1 } from 'storybook/internal/types';
|
|
2
2
|
import { AddonTypes as AddonTypes$1, StoryContext as StoryContext$1 } from 'storybook/internal/csf';
|
|
3
3
|
|
|
4
4
|
declare global {
|
|
@@ -7,6 +7,74 @@ declare global {
|
|
|
7
7
|
}
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
Returns a boolean for whether the two given types are equal.
|
|
12
|
+
|
|
13
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
14
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
15
|
+
*/
|
|
16
|
+
type IsEqual<T, U> =
|
|
17
|
+
(<G>() => G extends T ? 1 : 2) extends
|
|
18
|
+
(<G>() => G extends U ? 1 : 2)
|
|
19
|
+
? true
|
|
20
|
+
: false;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
Filter out keys from an object.
|
|
24
|
+
|
|
25
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
26
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
27
|
+
Returns `Key` otherwise.
|
|
28
|
+
|
|
29
|
+
@example
|
|
30
|
+
```
|
|
31
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
32
|
+
//=> never
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
@example
|
|
36
|
+
```
|
|
37
|
+
type Filtered = Filter<'bar', string>;
|
|
38
|
+
//=> never
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
@example
|
|
42
|
+
```
|
|
43
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
44
|
+
//=> 'bar'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
@see {Except}
|
|
48
|
+
*/
|
|
49
|
+
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
Create a type from an object type without certain keys.
|
|
53
|
+
|
|
54
|
+
This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
|
|
55
|
+
|
|
56
|
+
This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
|
|
57
|
+
|
|
58
|
+
@example
|
|
59
|
+
```
|
|
60
|
+
import type {Except} from 'type-fest';
|
|
61
|
+
|
|
62
|
+
type Foo = {
|
|
63
|
+
a: number;
|
|
64
|
+
b: string;
|
|
65
|
+
c: boolean;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
type FooWithoutA = Except<Foo, 'a' | 'c'>;
|
|
69
|
+
//=> {b: string};
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
@category Object
|
|
73
|
+
*/
|
|
74
|
+
type Except<ObjectType, KeysType extends keyof ObjectType> = {
|
|
75
|
+
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
|
|
76
|
+
};
|
|
77
|
+
|
|
10
78
|
/**
|
|
11
79
|
@see Simplify
|
|
12
80
|
*/
|
|
@@ -196,6 +264,39 @@ type RemoveIndexSignature<ObjectType> = {
|
|
|
196
264
|
: KeyType]: ObjectType[KeyType];
|
|
197
265
|
};
|
|
198
266
|
|
|
267
|
+
/**
|
|
268
|
+
Create a type that makes the given keys optional. The remaining keys are kept as is. The sister of the `SetRequired` type.
|
|
269
|
+
|
|
270
|
+
Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are optional.
|
|
271
|
+
|
|
272
|
+
@example
|
|
273
|
+
```
|
|
274
|
+
import type {SetOptional} from 'type-fest';
|
|
275
|
+
|
|
276
|
+
type Foo = {
|
|
277
|
+
a: number;
|
|
278
|
+
b?: string;
|
|
279
|
+
c: boolean;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
|
|
283
|
+
// type SomeOptional = {
|
|
284
|
+
// a: number;
|
|
285
|
+
// b?: string; // Was already optional and still is.
|
|
286
|
+
// c?: boolean; // Is now optional.
|
|
287
|
+
// }
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
@category Object
|
|
291
|
+
*/
|
|
292
|
+
type SetOptional<BaseType, Keys extends keyof BaseType> =
|
|
293
|
+
Simplify<
|
|
294
|
+
// Pick just the keys that are readonly from the base type.
|
|
295
|
+
Except<BaseType, Keys> &
|
|
296
|
+
// Pick the keys that should be mutable from the base type and make them mutable.
|
|
297
|
+
Partial<Pick<BaseType, Keys>>
|
|
298
|
+
>;
|
|
299
|
+
|
|
199
300
|
/**
|
|
200
301
|
Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
201
302
|
|
|
@@ -262,12 +363,16 @@ interface SBBaseType {
|
|
|
262
363
|
raw?: string;
|
|
263
364
|
}
|
|
264
365
|
type SBScalarType = SBBaseType & {
|
|
265
|
-
name: 'boolean' | 'string' | 'number' | 'function' | 'symbol';
|
|
366
|
+
name: 'boolean' | 'string' | 'number' | 'function' | 'symbol' | 'date';
|
|
266
367
|
};
|
|
267
368
|
type SBArrayType = SBBaseType & {
|
|
268
369
|
name: 'array';
|
|
269
370
|
value: SBType;
|
|
270
371
|
};
|
|
372
|
+
type SBNodeType = SBBaseType & {
|
|
373
|
+
name: 'node';
|
|
374
|
+
renderer: string;
|
|
375
|
+
};
|
|
271
376
|
type SBObjectType = SBBaseType & {
|
|
272
377
|
name: 'object';
|
|
273
378
|
value: Record<string, SBType>;
|
|
@@ -284,11 +389,19 @@ type SBUnionType = SBBaseType & {
|
|
|
284
389
|
name: 'union';
|
|
285
390
|
value: SBType[];
|
|
286
391
|
};
|
|
392
|
+
type SBLiteralType = SBBaseType & {
|
|
393
|
+
name: 'literal';
|
|
394
|
+
value: unknown;
|
|
395
|
+
};
|
|
396
|
+
type SBTupleType = SBBaseType & {
|
|
397
|
+
name: 'tuple';
|
|
398
|
+
value: SBType[];
|
|
399
|
+
};
|
|
287
400
|
type SBOtherType = SBBaseType & {
|
|
288
401
|
name: 'other';
|
|
289
402
|
value: string;
|
|
290
403
|
};
|
|
291
|
-
type SBType = SBScalarType | SBEnumType | SBArrayType | SBObjectType | SBIntersectionType | SBUnionType | SBOtherType;
|
|
404
|
+
type SBType = SBScalarType | SBEnumType | SBArrayType | SBNodeType | SBObjectType | SBIntersectionType | SBUnionType | SBLiteralType | SBTupleType | SBOtherType;
|
|
292
405
|
|
|
293
406
|
interface ActionsParameters {
|
|
294
407
|
/**
|
|
@@ -721,7 +834,23 @@ interface GlobalTypes {
|
|
|
721
834
|
interface StrictGlobalTypes {
|
|
722
835
|
[name: string]: StrictInputType;
|
|
723
836
|
}
|
|
837
|
+
/**
|
|
838
|
+
* AddonTypes allows addons to extend the type system with additional args, parameters, and globals.
|
|
839
|
+
*
|
|
840
|
+
* Addons can use `definePreviewAddon<AddonTypes>()` to declare additional types that will be merged
|
|
841
|
+
* into the story context. For example, an addon that provides a `theme` arg could declare:
|
|
842
|
+
*
|
|
843
|
+
* ```ts
|
|
844
|
+
* const themeAddon = definePreviewAddon<{ args: { theme: 'light' | 'dark' } }>({
|
|
845
|
+
* decorators: [(Story, { args }) => <ThemeProvider theme={args.theme}><Story /></ThemeProvider>]
|
|
846
|
+
* });
|
|
847
|
+
* ```
|
|
848
|
+
*
|
|
849
|
+
* When users include this addon in their preview config, the `theme` arg becomes available and
|
|
850
|
+
* type-checked across all stories.
|
|
851
|
+
*/
|
|
724
852
|
interface AddonTypes {
|
|
853
|
+
args?: unknown;
|
|
725
854
|
parameters?: Record<string, any>;
|
|
726
855
|
globals?: Record<string, any>;
|
|
727
856
|
}
|
|
@@ -991,11 +1120,12 @@ interface Preview<TRenderer extends Renderer$1 = Renderer$1> {
|
|
|
991
1120
|
addons?: PreviewAddon<never>[];
|
|
992
1121
|
};
|
|
993
1122
|
composed: NormalizedProjectAnnotations<TRenderer>;
|
|
994
|
-
meta<TArgs
|
|
1123
|
+
meta<TArgs, TInput extends ComponentAnnotations$1<TRenderer & {
|
|
995
1124
|
args: TArgs;
|
|
996
|
-
}, TArgs>>(input: TInput): Meta<TRenderer & {
|
|
1125
|
+
}, TArgs & TRenderer['args']>>(input: TInput): Meta<TRenderer & {
|
|
997
1126
|
args: TArgs;
|
|
998
1127
|
}, TInput>;
|
|
1128
|
+
type<T>(): Preview<TRenderer & T>;
|
|
999
1129
|
}
|
|
1000
1130
|
type InferTypes<T extends PreviewAddon<never>[]> = T extends PreviewAddon<infer C>[] ? C & {
|
|
1001
1131
|
csf4: true;
|
|
@@ -1007,14 +1137,14 @@ interface PreviewAddon<in TExtraContext extends AddonTypes$1 = AddonTypes$1> ext
|
|
|
1007
1137
|
}
|
|
1008
1138
|
declare function definePreviewAddon<TExtraContext extends AddonTypes$1 = AddonTypes$1>(preview: ProjectAnnotations$1<Renderer$1>): PreviewAddon<TExtraContext>;
|
|
1009
1139
|
declare function isPreview(input: unknown): input is Preview<Renderer$1>;
|
|
1010
|
-
interface Meta<TRenderer extends Renderer$1,
|
|
1140
|
+
interface Meta<TRenderer extends Renderer$1, TMetaInput extends ComponentAnnotations$1<TRenderer, TRenderer['args']> = ComponentAnnotations$1<TRenderer, TRenderer['args']>> {
|
|
1011
1141
|
readonly _tag: 'Meta';
|
|
1012
|
-
input:
|
|
1142
|
+
input: TMetaInput;
|
|
1013
1143
|
preview: Preview<TRenderer>;
|
|
1014
1144
|
story(input?: () => TRenderer['storyResult']): Story<TRenderer, {
|
|
1015
1145
|
render: () => TRenderer['storyResult'];
|
|
1016
1146
|
}>;
|
|
1017
|
-
story<TInput extends StoryAnnotations$1<TRenderer, TRenderer['args']
|
|
1147
|
+
story<TInput extends StoryAnnotations$1<TRenderer, TRenderer['args'], SetOptional<TRenderer['args'], keyof TRenderer['args'] & keyof TMetaInput['args']>>>(input?: TInput): Story<TRenderer, TInput>;
|
|
1018
1148
|
}
|
|
1019
1149
|
declare function isMeta(input: unknown): input is Meta<Renderer$1>;
|
|
1020
1150
|
interface Story<TRenderer extends Renderer$1, TInput extends StoryAnnotations$1<TRenderer, TRenderer['args']> = StoryAnnotations$1<TRenderer, TRenderer['args']>> {
|
|
@@ -1065,4 +1195,4 @@ declare const parseKind: (kind: string, { rootSeparator, groupSeparator }: Separ
|
|
|
1065
1195
|
/** Combine a set of project / meta / story tags, removing duplicates and handling negations. */
|
|
1066
1196
|
declare const combineTags: (...tags: string[]) => string[];
|
|
1067
1197
|
|
|
1068
|
-
export { type AddonTypes, type AfterEach, type AnnotatedStoryFn, type AnyFramework, type ArgTypes, type ArgTypesEnhancer, type Args, type ArgsEnhancer, type ArgsFromMeta, type ArgsStoryFn, type BaseAnnotations, type BeforeAll, type BeforeEach, type Canvas, type CleanupCallback, type ComponentAnnotations, type ComponentId, type ComponentTitle, type Conditional, type CoreTypes, type DecoratorApplicator, type DecoratorFunction, type GlobalTypes, type Globals, type IncludeExcludeOptions, type InferTypes, type InputType, type LegacyAnnotatedStoryFn, type LegacyStoryAnnotationsOrFn, type LegacyStoryFn, type LoaderFunction, type Meta, type Parameters, type PartialStoryFn, type PlayFunction, type PlayFunctionContext, type Preview, type PreviewAddon, type ProjectAnnotations, type Renderer, type SBArrayType, type SBEnumType, type SBIntersectionType, type SBObjectType, type SBOtherType, type SBScalarType, type SBType, type SBUnionType, type SeparatorOptions, type StepFunction, type StepLabel, type StepRunner, type Story, type StoryAnnotations, type StoryAnnotationsOrFn, type StoryContext, type StoryContextForEnhancers, type StoryContextForLoaders, type StoryContextUpdate, type StoryFn, type StoryId, type StoryIdentifier, type StoryKind, type StoryName, type StrictArgTypes, type StrictArgs, type StrictGlobalTypes, type StrictInputType, type StrictParameters, type Tag, type TestFunction, type ViewMode, combineTags, definePreview, definePreviewAddon, getCoreAnnotations, getStoryChildren, includeConditionalArg, isExportStory, isMeta, isPreview, isStory, parseKind, sanitize, storyNameFromExport, toId, toTestId };
|
|
1198
|
+
export { type AddonTypes, type AfterEach, type AnnotatedStoryFn, type AnyFramework, type ArgTypes, type ArgTypesEnhancer, type Args, type ArgsEnhancer, type ArgsFromMeta, type ArgsStoryFn, type BaseAnnotations, type BeforeAll, type BeforeEach, type Canvas, type CleanupCallback, type ComponentAnnotations, type ComponentId, type ComponentTitle, type Conditional, type CoreTypes, type DecoratorApplicator, type DecoratorFunction, type GlobalTypes, type Globals, type IncludeExcludeOptions, type InferTypes, type InputType, type LegacyAnnotatedStoryFn, type LegacyStoryAnnotationsOrFn, type LegacyStoryFn, type LoaderFunction, type Meta, type Parameters, type PartialStoryFn, type PlayFunction, type PlayFunctionContext, type Preview, type PreviewAddon, type ProjectAnnotations, type Renderer, type SBArrayType, type SBEnumType, type SBIntersectionType, type SBLiteralType, type SBNodeType, type SBObjectType, type SBOtherType, type SBScalarType, type SBTupleType, type SBType, type SBUnionType, type SeparatorOptions, type StepFunction, type StepLabel, type StepRunner, type Story, type StoryAnnotations, type StoryAnnotationsOrFn, type StoryContext, type StoryContextForEnhancers, type StoryContextForLoaders, type StoryContextUpdate, type StoryFn, type StoryId, type StoryIdentifier, type StoryKind, type StoryName, type StrictArgTypes, type StrictArgs, type StrictGlobalTypes, type StrictInputType, type StrictParameters, type Tag, type TestFunction, type ViewMode, combineTags, definePreview, definePreviewAddon, getCoreAnnotations, getStoryChildren, includeConditionalArg, isExportStory, isMeta, isPreview, isStory, parseKind, sanitize, storyNameFromExport, toId, toTestId };
|
package/dist/csf/index.js
CHANGED
|
@@ -340,8 +340,30 @@ var { step } = instrument(
|
|
|
340
340
|
runStep: step
|
|
341
341
|
});
|
|
342
342
|
|
|
343
|
-
// src/
|
|
343
|
+
// src/core-server/utils/ghost-stories/test-annotations.ts
|
|
344
344
|
import { definePreviewAddon as definePreviewAddon4 } from "storybook/internal/csf";
|
|
345
|
+
var isEmptyRender = (element) => {
|
|
346
|
+
let style = getComputedStyle(element), rect = element.getBoundingClientRect();
|
|
347
|
+
return !(rect.width > 0 && rect.height > 0 && style.visibility !== "hidden" && Number(style.opacity) > 0 && style.display !== "none");
|
|
348
|
+
}, afterEach = async ({ reporting, canvasElement, globals }) => {
|
|
349
|
+
try {
|
|
350
|
+
if (!globals.ghostStories)
|
|
351
|
+
return;
|
|
352
|
+
let emptyRender = isEmptyRender(canvasElement.firstElementChild ?? canvasElement);
|
|
353
|
+
emptyRender && reporting.addReport({
|
|
354
|
+
type: "render-analysis",
|
|
355
|
+
version: 1,
|
|
356
|
+
result: {
|
|
357
|
+
emptyRender
|
|
358
|
+
},
|
|
359
|
+
status: "warning"
|
|
360
|
+
});
|
|
361
|
+
} catch {
|
|
362
|
+
}
|
|
363
|
+
}, test_annotations_default = () => definePreviewAddon4({ afterEach });
|
|
364
|
+
|
|
365
|
+
// src/highlight/preview.ts
|
|
366
|
+
import { definePreviewAddon as definePreviewAddon5 } from "storybook/internal/csf";
|
|
345
367
|
import { addons } from "storybook/preview-api";
|
|
346
368
|
|
|
347
369
|
// src/highlight/useHighlights.ts
|
|
@@ -892,10 +914,10 @@ var menuId = "storybook-highlights-menu", rootId = "storybook-highlights-root",
|
|
|
892
914
|
|
|
893
915
|
// src/highlight/preview.ts
|
|
894
916
|
globalThis?.FEATURES?.highlight && addons?.ready && addons.ready().then(useHighlights);
|
|
895
|
-
var preview_default4 = () =>
|
|
917
|
+
var preview_default4 = () => definePreviewAddon5({});
|
|
896
918
|
|
|
897
919
|
// src/measure/preview.ts
|
|
898
|
-
import { definePreviewAddon as
|
|
920
|
+
import { definePreviewAddon as definePreviewAddon6 } from "storybook/internal/csf";
|
|
899
921
|
|
|
900
922
|
// src/measure/withMeasure.ts
|
|
901
923
|
import { useEffect as useEffect2 } from "storybook/preview-api";
|
|
@@ -1267,13 +1289,13 @@ var withMeasure = (StoryFn, context) => {
|
|
|
1267
1289
|
// src/measure/preview.ts
|
|
1268
1290
|
var decorators2 = globalThis.FEATURES?.measure ? [withMeasure] : [], initialGlobals2 = {
|
|
1269
1291
|
[PARAM_KEY3]: !1
|
|
1270
|
-
}, preview_default5 = () =>
|
|
1292
|
+
}, preview_default5 = () => definePreviewAddon6({
|
|
1271
1293
|
decorators: decorators2,
|
|
1272
1294
|
initialGlobals: initialGlobals2
|
|
1273
1295
|
});
|
|
1274
1296
|
|
|
1275
1297
|
// src/outline/preview.ts
|
|
1276
|
-
import { definePreviewAddon as
|
|
1298
|
+
import { definePreviewAddon as definePreviewAddon7 } from "storybook/internal/csf";
|
|
1277
1299
|
|
|
1278
1300
|
// src/outline/withOutline.ts
|
|
1279
1301
|
import { useEffect as useEffect3, useMemo } from "storybook/preview-api";
|
|
@@ -1709,10 +1731,10 @@ var withOutline = (StoryFn, context) => {
|
|
|
1709
1731
|
// src/outline/preview.ts
|
|
1710
1732
|
var decorators3 = globalThis.FEATURES?.outline ? [withOutline] : [], initialGlobals3 = {
|
|
1711
1733
|
[PARAM_KEY4]: !1
|
|
1712
|
-
}, preview_default6 = () =>
|
|
1734
|
+
}, preview_default6 = () => definePreviewAddon7({ decorators: decorators3, initialGlobals: initialGlobals3 });
|
|
1713
1735
|
|
|
1714
1736
|
// src/test/preview.ts
|
|
1715
|
-
import { definePreviewAddon as
|
|
1737
|
+
import { definePreviewAddon as definePreviewAddon8 } from "storybook/internal/csf";
|
|
1716
1738
|
import { instrument as instrument2 } from "storybook/internal/instrumenter";
|
|
1717
1739
|
import {
|
|
1718
1740
|
clearAllMocks,
|
|
@@ -1778,15 +1800,15 @@ var resetAllMocksLoader = ({ parameters: parameters2 }) => {
|
|
|
1778
1800
|
}
|
|
1779
1801
|
} catch {
|
|
1780
1802
|
}
|
|
1781
|
-
}, preview_default7 = () =>
|
|
1803
|
+
}, preview_default7 = () => definePreviewAddon8({
|
|
1782
1804
|
loaders: [resetAllMocksLoader, nameSpiesAndWrapActionsInSpies, enhanceContext]
|
|
1783
1805
|
});
|
|
1784
1806
|
|
|
1785
1807
|
// src/viewport/preview.ts
|
|
1786
|
-
import { definePreviewAddon as
|
|
1808
|
+
import { definePreviewAddon as definePreviewAddon9 } from "storybook/internal/csf";
|
|
1787
1809
|
var initialGlobals4 = {
|
|
1788
1810
|
[PARAM_KEY]: { value: void 0, isRotated: !1 }
|
|
1789
|
-
}, preview_default8 = () =>
|
|
1811
|
+
}, preview_default8 = () => definePreviewAddon9({
|
|
1790
1812
|
initialGlobals: initialGlobals4
|
|
1791
1813
|
});
|
|
1792
1814
|
|
|
@@ -1808,7 +1830,9 @@ function getCoreAnnotations() {
|
|
|
1808
1830
|
// @ts-expect-error CJS fallback
|
|
1809
1831
|
(preview_default3.default ?? preview_default3)(),
|
|
1810
1832
|
// @ts-expect-error CJS fallback
|
|
1811
|
-
(preview_default7.default ?? preview_default7)()
|
|
1833
|
+
(preview_default7.default ?? preview_default7)(),
|
|
1834
|
+
// @ts-expect-error CJS fallback
|
|
1835
|
+
(test_annotations_default.default ?? test_annotations_default)()
|
|
1812
1836
|
];
|
|
1813
1837
|
}
|
|
1814
1838
|
|
|
@@ -1825,13 +1849,16 @@ function definePreview(input) {
|
|
|
1825
1849
|
composeConfigs([...getCoreAnnotations(), ...addons2 ?? [], rest])
|
|
1826
1850
|
), composed;
|
|
1827
1851
|
},
|
|
1852
|
+
type() {
|
|
1853
|
+
return this;
|
|
1854
|
+
},
|
|
1828
1855
|
meta(meta) {
|
|
1829
1856
|
return defineMeta(meta, this);
|
|
1830
1857
|
}
|
|
1831
1858
|
};
|
|
1832
1859
|
return globalThis.globalProjectAnnotations = preview.composed, preview;
|
|
1833
1860
|
}
|
|
1834
|
-
function
|
|
1861
|
+
function definePreviewAddon10(preview) {
|
|
1835
1862
|
return preview;
|
|
1836
1863
|
}
|
|
1837
1864
|
function isPreview(input) {
|
|
@@ -1843,7 +1870,7 @@ function isMeta(input) {
|
|
|
1843
1870
|
function defineMeta(input, preview) {
|
|
1844
1871
|
return {
|
|
1845
1872
|
_tag: "Meta",
|
|
1846
|
-
input,
|
|
1873
|
+
input: { ...input, parameters: { ...input.parameters, csfFactory: !0 } },
|
|
1847
1874
|
preview,
|
|
1848
1875
|
// @ts-expect-error hard
|
|
1849
1876
|
story(story = {}) {
|
|
@@ -1961,7 +1988,7 @@ var parseKind = (kind, { rootSeparator, groupSeparator }) => {
|
|
|
1961
1988
|
export {
|
|
1962
1989
|
combineTags2 as combineTags,
|
|
1963
1990
|
definePreview,
|
|
1964
|
-
|
|
1991
|
+
definePreviewAddon10 as definePreviewAddon,
|
|
1965
1992
|
getCoreAnnotations,
|
|
1966
1993
|
getStoryChildren,
|
|
1967
1994
|
includeConditionalArg,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { types, NodePath, GeneratorOptions, generate, RecastOptions } from 'storybook/internal/babel';
|
|
2
2
|
export { babelParse } from 'storybook/internal/babel';
|
|
3
3
|
import { ComponentAnnotations, StoryAnnotations, IndexInputStats, IndexedCSFFile, IndexInput, CsfEnricher, StoriesEntry, Tag } from 'storybook/internal/types';
|
|
4
|
+
import { ArgTypes } from 'storybook/internal/csf';
|
|
4
5
|
|
|
5
6
|
interface PrintResultType {
|
|
6
7
|
code: string;
|
|
@@ -295,4 +296,21 @@ declare function vitestTransform({ code, fileName, configDir, stories, tagsFilte
|
|
|
295
296
|
previewLevelTags: Tag[];
|
|
296
297
|
}): Promise<ReturnType<typeof formatCsf>>;
|
|
297
298
|
|
|
298
|
-
|
|
299
|
+
/**
|
|
300
|
+
* Transforms a component file directly into a Vitest test file. Uses a getComponentArgTypes
|
|
301
|
+
* function to retrieve component argTypes for required prop generation. Uses portable stories to
|
|
302
|
+
* construct a test based on the default state of a component (basic render + required args)
|
|
303
|
+
*/
|
|
304
|
+
declare const componentTransform: ({ code, fileName, getComponentArgTypes, }: {
|
|
305
|
+
code: string;
|
|
306
|
+
fileName: string;
|
|
307
|
+
getComponentArgTypes?: (options: {
|
|
308
|
+
componentName: string;
|
|
309
|
+
fileName: string;
|
|
310
|
+
}) => Promise<ArgTypes | null | undefined>;
|
|
311
|
+
}) => Promise<ReturnType<typeof generate> | {
|
|
312
|
+
code: string;
|
|
313
|
+
map: null;
|
|
314
|
+
}>;
|
|
315
|
+
|
|
316
|
+
export { BadMetaError, ConfigFile, CsfFile, type CsfOptions, type EnrichCsfOptions, MixedFactoryError, MultipleMetaError, NoMetaError, type StaticMeta, type StaticStory, type StoryTest, babelParseFile, componentTransform, enrichCsf, enrichCsfMeta, enrichCsfStory, extractDescription, extractSource, formatConfig, formatCsf, getStorySortParameter, isCsfFactoryPreview, isModuleMock, isValidPreviewPath, loadConfig, loadCsf, printConfig, printCsf, readConfig, readCsf, vitestTransform, writeConfig, writeCsf };
|
package/dist/csf-tools/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_w8tq4vh9mzk from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_w8tq4vh9mzk from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_w8tq4vh9mzk from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_w8tq4vh9mzk.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_w8tq4vh9mzk.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_w8tq4vh9mzk.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
NoMetaError,
|
|
19
19
|
babelParse,
|
|
20
20
|
babelParseFile,
|
|
21
|
+
componentTransform,
|
|
21
22
|
enrichCsf,
|
|
22
23
|
enrichCsfMeta,
|
|
23
24
|
enrichCsfStory,
|
|
@@ -38,10 +39,9 @@ import {
|
|
|
38
39
|
vitestTransform,
|
|
39
40
|
writeConfig,
|
|
40
41
|
writeCsf
|
|
41
|
-
} from "../_node-chunks/chunk-
|
|
42
|
-
import "../_node-chunks/chunk-
|
|
43
|
-
import "../_node-chunks/chunk-
|
|
44
|
-
import "../_node-chunks/chunk-5KEIALUH.js";
|
|
42
|
+
} from "../_node-chunks/chunk-VTBZVEBF.js";
|
|
43
|
+
import "../_node-chunks/chunk-G7P42ZEY.js";
|
|
44
|
+
import "../_node-chunks/chunk-25OWI2RR.js";
|
|
45
45
|
export {
|
|
46
46
|
BadMetaError,
|
|
47
47
|
ConfigFile,
|
|
@@ -51,6 +51,7 @@ export {
|
|
|
51
51
|
NoMetaError,
|
|
52
52
|
babelParse,
|
|
53
53
|
babelParseFile,
|
|
54
|
+
componentTransform,
|
|
54
55
|
enrichCsf,
|
|
55
56
|
enrichCsfMeta,
|
|
56
57
|
enrichCsfStory,
|
|
@@ -31520,6 +31520,8 @@ __export(core_events_exports, {
|
|
|
31520
31520
|
FILE_COMPONENT_SEARCH_RESPONSE: () => FILE_COMPONENT_SEARCH_RESPONSE,
|
|
31521
31521
|
FORCE_REMOUNT: () => FORCE_REMOUNT,
|
|
31522
31522
|
FORCE_RE_RENDER: () => FORCE_RE_RENDER,
|
|
31523
|
+
GHOST_STORIES_REQUEST: () => GHOST_STORIES_REQUEST,
|
|
31524
|
+
GHOST_STORIES_RESPONSE: () => GHOST_STORIES_RESPONSE,
|
|
31523
31525
|
GLOBALS_UPDATED: () => GLOBALS_UPDATED,
|
|
31524
31526
|
MANAGER_INERT_ATTRIBUTE_CHANGED: () => MANAGER_INERT_ATTRIBUTE_CHANGED,
|
|
31525
31527
|
NAVIGATE_URL: () => NAVIGATE_URL,
|
|
@@ -31569,7 +31571,7 @@ __export(core_events_exports, {
|
|
|
31569
31571
|
UPDATE_STORY_ARGS: () => UPDATE_STORY_ARGS,
|
|
31570
31572
|
default: () => core_events_default
|
|
31571
31573
|
});
|
|
31572
|
-
var events = /* @__PURE__ */ ((events2) => (events2.CHANNEL_WS_DISCONNECT = "channelWSDisconnect", events2.CHANNEL_CREATED = "channelCreated", events2.CONFIG_ERROR = "configError", events2.STORY_INDEX_INVALIDATED = "storyIndexInvalidated", events2.STORY_SPECIFIED = "storySpecified", events2.SET_CONFIG = "setConfig", events2.SET_STORIES = "setStories", events2.SET_INDEX = "setIndex", events2.SET_CURRENT_STORY = "setCurrentStory", events2.CURRENT_STORY_WAS_SET = "currentStoryWasSet", events2.FORCE_RE_RENDER = "forceReRender", events2.FORCE_REMOUNT = "forceRemount", events2.PRELOAD_ENTRIES = "preloadStories", events2.STORY_PREPARED = "storyPrepared", events2.DOCS_PREPARED = "docsPrepared", events2.STORY_CHANGED = "storyChanged", events2.STORY_UNCHANGED = "storyUnchanged", events2.STORY_RENDERED = "storyRendered", events2.STORY_FINISHED = "storyFinished", events2.STORY_MISSING = "storyMissing", events2.STORY_ERRORED = "storyErrored", events2.STORY_THREW_EXCEPTION = "storyThrewException", events2.STORY_RENDER_PHASE_CHANGED = "storyRenderPhaseChanged", events2.STORY_HOT_UPDATED = "storyHotUpdated", events2.PLAY_FUNCTION_THREW_EXCEPTION = "playFunctionThrewException", events2.UNHANDLED_ERRORS_WHILE_PLAYING = "unhandledErrorsWhilePlaying", events2.UPDATE_STORY_ARGS = "updateStoryArgs", events2.STORY_ARGS_UPDATED = "storyArgsUpdated", events2.RESET_STORY_ARGS = "resetStoryArgs", events2.SET_FILTER = "setFilter", events2.SET_GLOBALS = "setGlobals", events2.UPDATE_GLOBALS = "updateGlobals", events2.GLOBALS_UPDATED = "globalsUpdated", events2.REGISTER_SUBSCRIPTION = "registerSubscription", events2.PREVIEW_INITIALIZED = "previewInitialized", events2.PREVIEW_KEYDOWN = "previewKeydown", events2.PREVIEW_BUILDER_PROGRESS = "preview_builder_progress", events2.SELECT_STORY = "selectStory", events2.STORIES_COLLAPSE_ALL = "storiesCollapseAll", events2.STORIES_EXPAND_ALL = "storiesExpandAll", events2.DOCS_RENDERED = "docsRendered", events2.SHARED_STATE_CHANGED = "sharedStateChanged", events2.SHARED_STATE_SET = "sharedStateSet", events2.NAVIGATE_URL = "navigateUrl", events2.UPDATE_QUERY_PARAMS = "updateQueryParams", events2.REQUEST_WHATS_NEW_DATA = "requestWhatsNewData", events2.RESULT_WHATS_NEW_DATA = "resultWhatsNewData", events2.SET_WHATS_NEW_CACHE = "setWhatsNewCache", events2.TOGGLE_WHATS_NEW_NOTIFICATIONS = "toggleWhatsNewNotifications", events2.TELEMETRY_ERROR = "telemetryError", events2.FILE_COMPONENT_SEARCH_REQUEST = "fileComponentSearchRequest", events2.FILE_COMPONENT_SEARCH_RESPONSE = "fileComponentSearchResponse", events2.SAVE_STORY_REQUEST = "saveStoryRequest", events2.SAVE_STORY_RESPONSE = "saveStoryResponse", events2.ARGTYPES_INFO_REQUEST = "argtypesInfoRequest", events2.ARGTYPES_INFO_RESPONSE = "argtypesInfoResponse", events2.CREATE_NEW_STORYFILE_REQUEST = "createNewStoryfileRequest", events2.CREATE_NEW_STORYFILE_RESPONSE = "createNewStoryfileResponse", events2.OPEN_IN_EDITOR_REQUEST = "openInEditorRequest", events2.OPEN_IN_EDITOR_RESPONSE = "openInEditorResponse", events2.MANAGER_INERT_ATTRIBUTE_CHANGED = "managerInertAttributeChanged", events2))(events || {}), core_events_default = events, {
|
|
31574
|
+
var events = /* @__PURE__ */ ((events2) => (events2.CHANNEL_WS_DISCONNECT = "channelWSDisconnect", events2.CHANNEL_CREATED = "channelCreated", events2.CONFIG_ERROR = "configError", events2.STORY_INDEX_INVALIDATED = "storyIndexInvalidated", events2.STORY_SPECIFIED = "storySpecified", events2.SET_CONFIG = "setConfig", events2.SET_STORIES = "setStories", events2.SET_INDEX = "setIndex", events2.SET_CURRENT_STORY = "setCurrentStory", events2.CURRENT_STORY_WAS_SET = "currentStoryWasSet", events2.FORCE_RE_RENDER = "forceReRender", events2.FORCE_REMOUNT = "forceRemount", events2.PRELOAD_ENTRIES = "preloadStories", events2.STORY_PREPARED = "storyPrepared", events2.DOCS_PREPARED = "docsPrepared", events2.STORY_CHANGED = "storyChanged", events2.STORY_UNCHANGED = "storyUnchanged", events2.STORY_RENDERED = "storyRendered", events2.STORY_FINISHED = "storyFinished", events2.STORY_MISSING = "storyMissing", events2.STORY_ERRORED = "storyErrored", events2.STORY_THREW_EXCEPTION = "storyThrewException", events2.STORY_RENDER_PHASE_CHANGED = "storyRenderPhaseChanged", events2.STORY_HOT_UPDATED = "storyHotUpdated", events2.PLAY_FUNCTION_THREW_EXCEPTION = "playFunctionThrewException", events2.UNHANDLED_ERRORS_WHILE_PLAYING = "unhandledErrorsWhilePlaying", events2.UPDATE_STORY_ARGS = "updateStoryArgs", events2.STORY_ARGS_UPDATED = "storyArgsUpdated", events2.RESET_STORY_ARGS = "resetStoryArgs", events2.SET_FILTER = "setFilter", events2.SET_GLOBALS = "setGlobals", events2.UPDATE_GLOBALS = "updateGlobals", events2.GLOBALS_UPDATED = "globalsUpdated", events2.REGISTER_SUBSCRIPTION = "registerSubscription", events2.PREVIEW_INITIALIZED = "previewInitialized", events2.PREVIEW_KEYDOWN = "previewKeydown", events2.PREVIEW_BUILDER_PROGRESS = "preview_builder_progress", events2.SELECT_STORY = "selectStory", events2.STORIES_COLLAPSE_ALL = "storiesCollapseAll", events2.STORIES_EXPAND_ALL = "storiesExpandAll", events2.DOCS_RENDERED = "docsRendered", events2.SHARED_STATE_CHANGED = "sharedStateChanged", events2.SHARED_STATE_SET = "sharedStateSet", events2.NAVIGATE_URL = "navigateUrl", events2.UPDATE_QUERY_PARAMS = "updateQueryParams", events2.REQUEST_WHATS_NEW_DATA = "requestWhatsNewData", events2.RESULT_WHATS_NEW_DATA = "resultWhatsNewData", events2.SET_WHATS_NEW_CACHE = "setWhatsNewCache", events2.TOGGLE_WHATS_NEW_NOTIFICATIONS = "toggleWhatsNewNotifications", events2.TELEMETRY_ERROR = "telemetryError", events2.FILE_COMPONENT_SEARCH_REQUEST = "fileComponentSearchRequest", events2.FILE_COMPONENT_SEARCH_RESPONSE = "fileComponentSearchResponse", events2.SAVE_STORY_REQUEST = "saveStoryRequest", events2.SAVE_STORY_RESPONSE = "saveStoryResponse", events2.ARGTYPES_INFO_REQUEST = "argtypesInfoRequest", events2.ARGTYPES_INFO_RESPONSE = "argtypesInfoResponse", events2.CREATE_NEW_STORYFILE_REQUEST = "createNewStoryfileRequest", events2.CREATE_NEW_STORYFILE_RESPONSE = "createNewStoryfileResponse", events2.GHOST_STORIES_REQUEST = "ghostStoriesRequest", events2.GHOST_STORIES_RESPONSE = "ghostStoriesResponse", events2.OPEN_IN_EDITOR_REQUEST = "openInEditorRequest", events2.OPEN_IN_EDITOR_RESPONSE = "openInEditorResponse", events2.MANAGER_INERT_ATTRIBUTE_CHANGED = "managerInertAttributeChanged", events2))(events || {}), core_events_default = events, {
|
|
31573
31575
|
CHANNEL_WS_DISCONNECT,
|
|
31574
31576
|
CHANNEL_CREATED,
|
|
31575
31577
|
CONFIG_ERROR,
|
|
@@ -31628,6 +31630,8 @@ var events = /* @__PURE__ */ ((events2) => (events2.CHANNEL_WS_DISCONNECT = "cha
|
|
|
31628
31630
|
SAVE_STORY_RESPONSE,
|
|
31629
31631
|
ARGTYPES_INFO_REQUEST,
|
|
31630
31632
|
ARGTYPES_INFO_RESPONSE,
|
|
31633
|
+
GHOST_STORIES_REQUEST,
|
|
31634
|
+
GHOST_STORIES_RESPONSE,
|
|
31631
31635
|
OPEN_IN_EDITOR_REQUEST,
|
|
31632
31636
|
OPEN_IN_EDITOR_RESPONSE,
|
|
31633
31637
|
MANAGER_INERT_ATTRIBUTE_CHANGED
|
|
@@ -62133,7 +62137,7 @@ init_dist();
|
|
|
62133
62137
|
var import_memoizerific8 = __toESM(require_memoizerific(), 1), import_semver = __toESM(require_semver2(), 1);
|
|
62134
62138
|
|
|
62135
62139
|
// src/manager-api/version.ts
|
|
62136
|
-
var version = "10.2.0-alpha.
|
|
62140
|
+
var version = "10.2.0-alpha.17";
|
|
62137
62141
|
|
|
62138
62142
|
// src/manager-api/modules/versions.ts
|
|
62139
62143
|
var { VERSIONCHECK } = scope, getVersionCheckData = (0, import_memoizerific8.default)(1)(() => {
|