storybook 10.2.0-alpha.8 → 10.2.0-beta.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.
Files changed (97) hide show
  1. package/dist/_browser-chunks/{Color-E5XDEOX4.js → Color-XESOIGZP.js} +57 -3
  2. package/dist/_browser-chunks/chunk-AFVOZMXQ.js +23 -0
  3. package/dist/_browser-chunks/{chunk-3PJE6VLG.js → chunk-ASKQZAOS.js} +1 -12
  4. package/dist/_browser-chunks/chunk-IYCKG66Y.js +171 -0
  5. package/dist/_browser-chunks/chunk-LCHBOIHN.js +64 -0
  6. package/dist/_browser-chunks/{chunk-IPA5A322.js → chunk-MEXTPDJG.js} +1 -1
  7. package/dist/_browser-chunks/{chunk-54PNNATT.js → chunk-NQJGOFZV.js} +18 -1
  8. package/dist/_browser-chunks/{chunk-VUZYLZ4B.js → chunk-QOXZ7W26.js} +31 -15
  9. package/dist/_browser-chunks/{chunk-LOTN4ZCW.js → chunk-SI6AKD4S.js} +2 -2
  10. package/dist/_browser-chunks/chunk-YK43Z22A.js +263 -0
  11. package/dist/_node-chunks/{builder-manager-2XASU3VS.js → builder-manager-JEJE63VV.js} +15 -12
  12. package/dist/_node-chunks/camelcase-HALRJETF.js +62 -0
  13. package/dist/_node-chunks/{chunk-5GRHJJHD.js → chunk-3SKE4CCB.js} +9 -9
  14. package/dist/_node-chunks/chunk-4UYAC7Y2.js +18 -0
  15. package/dist/_node-chunks/{chunk-S7FIFCTX.js → chunk-6UAQEBJX.js} +10 -10
  16. package/dist/_node-chunks/{chunk-ZKB7MQRR.js → chunk-72K4WVI5.js} +18 -14
  17. package/dist/_node-chunks/{chunk-6TJUL42C.js → chunk-7ZX5CX6B.js} +15 -69
  18. package/dist/_node-chunks/{chunk-LEZENLG7.js → chunk-ADTWC7QJ.js} +7 -7
  19. package/dist/_node-chunks/{chunk-2OC7H5MZ.js → chunk-APUXGW3Y.js} +7 -7
  20. package/dist/_node-chunks/{chunk-5WQXPM6D.js → chunk-AXDM43NU.js} +6 -6
  21. package/dist/_node-chunks/{chunk-LOXLI4XT.js → chunk-B422K4XV.js} +6 -6
  22. package/dist/_node-chunks/{chunk-3K6P75SS.js → chunk-BJOXVTWM.js} +12 -571
  23. package/dist/_node-chunks/{chunk-TTGXODEY.js → chunk-BLGRU6F5.js} +7 -7
  24. package/dist/_node-chunks/{chunk-2KSITKBI.js → chunk-CG47ALAV.js} +7 -7
  25. package/dist/_node-chunks/chunk-FH4FRUMP.js +23 -0
  26. package/dist/_node-chunks/{chunk-DTM4A3DJ.js → chunk-GBZ23FIZ.js} +125 -73
  27. package/dist/_node-chunks/{chunk-IJ34563N.js → chunk-IZ3ATSWZ.js} +5262 -1480
  28. package/dist/_node-chunks/{chunk-JWL5NLJU.js → chunk-IZFEBWVB.js} +6 -6
  29. package/dist/_node-chunks/{chunk-5BRYY6XB.js → chunk-KL5CKFPT.js} +9 -9
  30. package/dist/_node-chunks/{chunk-COGO4JMD.js → chunk-MLXCYULR.js} +7 -7
  31. package/dist/_node-chunks/{chunk-7B4JYHGV.js → chunk-MV2QM7P3.js} +6 -6
  32. package/dist/_node-chunks/chunk-PHX5XNP7.js +144 -0
  33. package/dist/_node-chunks/{chunk-VJFHZL2T.js → chunk-QL6L57W7.js} +533 -144
  34. package/dist/_node-chunks/{chunk-Q6WPGVIW.js → chunk-RPBXVPRB.js} +6 -6
  35. package/dist/_node-chunks/{chunk-DYQ6QR45.js → chunk-UH2GWMFP.js} +260 -162
  36. package/dist/_node-chunks/chunk-WNGL2VRJ.js +126 -0
  37. package/dist/_node-chunks/{chunk-WKC523P7.js → chunk-XAL452XB.js} +36 -14
  38. package/dist/_node-chunks/{chunk-UNHOAAXU.js → chunk-YVXXMWQO.js} +7 -7
  39. package/dist/_node-chunks/chunk-YYDL7JOC.js +61 -0
  40. package/dist/_node-chunks/{chunk-MLYPMYG5.js → chunk-Z7FLE2TR.js} +6 -6
  41. package/dist/_node-chunks/{globby-FWMT4OOQ.js → globby-4D4NBVG7.js} +11 -20
  42. package/dist/_node-chunks/{lib-YCGXIMW5.js → lib-RM2DWHZQ.js} +7 -7
  43. package/dist/_node-chunks/{mdx-N42X6CFJ-CRGM5LTU.js → mdx-N42X6CFJ-RAL72UTP.js} +8 -8
  44. package/dist/_node-chunks/{p-limit-UJIYI4QT.js → p-limit-6PUJQL5X.js} +18 -14
  45. package/dist/babel/index.js +10 -10
  46. package/dist/bin/core.js +12 -12
  47. package/dist/bin/dispatcher.js +11 -11
  48. package/dist/bin/loader.js +9 -9
  49. package/dist/cli/index.d.ts +1504 -424
  50. package/dist/cli/index.js +18 -18
  51. package/dist/common/index.d.ts +1319 -271
  52. package/dist/common/index.js +22 -22
  53. package/dist/components/index.d.ts +4 -1
  54. package/dist/components/index.js +228 -227
  55. package/dist/core-events/index.d.ts +23 -7
  56. package/dist/core-events/index.js +5 -1
  57. package/dist/core-server/index.d.ts +108 -4
  58. package/dist/core-server/index.js +3459 -3086
  59. package/dist/core-server/presets/common-manager.js +208 -160
  60. package/dist/core-server/presets/common-override-preset.js +11 -11
  61. package/dist/core-server/presets/common-preset.js +576 -4536
  62. package/dist/csf/index.d.ts +147 -15
  63. package/dist/csf/index.js +52 -23
  64. package/dist/csf-tools/index.d.ts +19 -1
  65. package/dist/csf-tools/index.js +11 -9
  66. package/dist/docs-tools/index.d.ts +2 -2
  67. package/dist/docs-tools/index.js +4 -5
  68. package/dist/manager/globals-runtime.js +2749 -6907
  69. package/dist/manager/runtime.js +2939 -2295
  70. package/dist/manager-api/index.d.ts +89 -21
  71. package/dist/manager-api/index.js +82 -23
  72. package/dist/mocking-utils/index.js +8 -8
  73. package/dist/node-logger/index.d.ts +1453 -108
  74. package/dist/node-logger/index.js +9 -9
  75. package/dist/preview/runtime.js +784 -5059
  76. package/dist/preview-api/index.d.ts +26 -1
  77. package/dist/preview-api/index.js +11 -8
  78. package/dist/router/index.js +5 -4
  79. package/dist/server-errors.js +11 -11
  80. package/dist/telemetry/index.d.ts +14 -2
  81. package/dist/telemetry/index.js +23 -22
  82. package/dist/theming/index.d.ts +5 -5
  83. package/dist/theming/index.js +21 -2
  84. package/dist/types/index.d.ts +24 -11
  85. package/dist/viewport/index.d.ts +5 -3
  86. package/dist/viewport/index.js +12 -3
  87. package/package.json +27 -26
  88. package/dist/_browser-chunks/chunk-2NDLAB5X.js +0 -363
  89. package/dist/_browser-chunks/chunk-CLSHX4VX.js +0 -4140
  90. package/dist/_browser-chunks/chunk-HPYUT3WS.js +0 -199
  91. package/dist/_browser-chunks/chunk-XCZK5QUJ.js +0 -0
  92. package/dist/_node-chunks/camelcase-KIWRHB2G.js +0 -37
  93. package/dist/_node-chunks/chunk-2ANLCK4Y.js +0 -18
  94. package/dist/_node-chunks/chunk-3TW66YXG.js +0 -70
  95. package/dist/_node-chunks/chunk-UFXCGC4W.js +0 -23
  96. package/dist/_node-chunks/chunk-X4YDIHYE.js +0 -61
  97. package/dist/_node-chunks/dist-GICI6ZHU.js +0 -121
@@ -1,4 +1,4 @@
1
- import { StorybookTypes, Renderer as Renderer$1, ProjectAnnotations as ProjectAnnotations$1, NormalizedProjectAnnotations, Args as Args$1, ComponentAnnotations as ComponentAnnotations$1, StoryAnnotations as StoryAnnotations$1, ComposedStoryFn, TestFunction as TestFunction$1 } from 'storybook/internal/types';
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
  /**
@@ -515,8 +628,9 @@ interface TestTypes {
515
628
  interface Viewport {
516
629
  name: string;
517
630
  styles: ViewportStyles;
518
- type?: 'desktop' | 'mobile' | 'tablet' | 'other';
631
+ type?: ViewportType;
519
632
  }
633
+ type ViewportType = 'desktop' | 'mobile' | 'tablet' | 'watch' | 'other';
520
634
  interface ViewportStyles {
521
635
  height: string;
522
636
  width: string;
@@ -524,7 +638,8 @@ interface ViewportStyles {
524
638
  type GlobalState = {
525
639
  /**
526
640
  * When set, the viewport is applied and cannot be changed using the toolbar. Must match the key
527
- * of one of the available viewports.
641
+ * of one of the available viewports or follow the format '{width}-{height}', e.g. '320-480' which
642
+ * may include a unit (e.g. '100vw' or '100pct').
528
643
  */
529
644
  value: string | undefined;
530
645
  /**
@@ -671,8 +786,8 @@ interface InputType {
671
786
  category?: string;
672
787
  /** @see https://storybook.js.org/docs/api/arg-types#tabledefaultvalue */
673
788
  defaultValue?: {
674
- summary?: string;
675
- detail?: string;
789
+ summary?: string | undefined;
790
+ detail?: string | undefined;
676
791
  };
677
792
  /** @see https://storybook.js.org/docs/api/arg-types#tabledisable */
678
793
  disable?: boolean;
@@ -680,8 +795,8 @@ interface InputType {
680
795
  subcategory?: string;
681
796
  /** @see https://storybook.js.org/docs/api/arg-types#tabletype */
682
797
  type?: {
683
- summary?: string;
684
- detail?: string;
798
+ summary?: string | undefined;
799
+ detail?: string | undefined;
685
800
  };
686
801
  };
687
802
  /** @see https://storybook.js.org/docs/api/arg-types#type */
@@ -719,7 +834,23 @@ interface GlobalTypes {
719
834
  interface StrictGlobalTypes {
720
835
  [name: string]: StrictInputType;
721
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
+ */
722
852
  interface AddonTypes {
853
+ args?: unknown;
723
854
  parameters?: Record<string, any>;
724
855
  globals?: Record<string, any>;
725
856
  }
@@ -989,11 +1120,12 @@ interface Preview<TRenderer extends Renderer$1 = Renderer$1> {
989
1120
  addons?: PreviewAddon<never>[];
990
1121
  };
991
1122
  composed: NormalizedProjectAnnotations<TRenderer>;
992
- meta<TArgs extends Args$1, TInput extends ComponentAnnotations$1<TRenderer & {
1123
+ meta<TArgs, TInput extends ComponentAnnotations$1<TRenderer & {
993
1124
  args: TArgs;
994
- }, TArgs>>(input: TInput): Meta<TRenderer & {
1125
+ }, TArgs & TRenderer['args']>>(input: TInput): Meta<TRenderer & {
995
1126
  args: TArgs;
996
1127
  }, TInput>;
1128
+ type<T>(): Preview<TRenderer & T>;
997
1129
  }
998
1130
  type InferTypes<T extends PreviewAddon<never>[]> = T extends PreviewAddon<infer C>[] ? C & {
999
1131
  csf4: true;
@@ -1005,14 +1137,14 @@ interface PreviewAddon<in TExtraContext extends AddonTypes$1 = AddonTypes$1> ext
1005
1137
  }
1006
1138
  declare function definePreviewAddon<TExtraContext extends AddonTypes$1 = AddonTypes$1>(preview: ProjectAnnotations$1<Renderer$1>): PreviewAddon<TExtraContext>;
1007
1139
  declare function isPreview(input: unknown): input is Preview<Renderer$1>;
1008
- interface Meta<TRenderer extends Renderer$1, TInput extends ComponentAnnotations$1<TRenderer, TRenderer['args']> = ComponentAnnotations$1<TRenderer, TRenderer['args']>> {
1140
+ interface Meta<TRenderer extends Renderer$1, TMetaInput extends ComponentAnnotations$1<TRenderer, TRenderer['args']> = ComponentAnnotations$1<TRenderer, TRenderer['args']>> {
1009
1141
  readonly _tag: 'Meta';
1010
- input: TInput;
1142
+ input: TMetaInput;
1011
1143
  preview: Preview<TRenderer>;
1012
1144
  story(input?: () => TRenderer['storyResult']): Story<TRenderer, {
1013
1145
  render: () => TRenderer['storyResult'];
1014
1146
  }>;
1015
- story<TInput extends StoryAnnotations$1<TRenderer, TRenderer['args']>>(input?: TInput): Story<TRenderer, TInput>;
1147
+ story<TInput extends StoryAnnotations$1<TRenderer, TRenderer['args'], SetOptional<TRenderer['args'], keyof TRenderer['args'] & keyof TMetaInput['args']>>>(input?: TInput): Story<TRenderer, TInput>;
1016
1148
  }
1017
1149
  declare function isMeta(input: unknown): input is Meta<Renderer$1>;
1018
1150
  interface Story<TRenderer extends Renderer$1, TInput extends StoryAnnotations$1<TRenderer, TRenderer['args']> = StoryAnnotations$1<TRenderer, TRenderer['args']>> {
@@ -1063,4 +1195,4 @@ declare const parseKind: (kind: string, { rootSeparator, groupSeparator }: Separ
1063
1195
  /** Combine a set of project / meta / story tags, removing duplicates and handling negations. */
1064
1196
  declare const combineTags: (...tags: string[]) => string[];
1065
1197
 
1066
- 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
@@ -10,21 +10,23 @@ import {
10
10
  mountDestructured,
11
11
  normalizeArrays,
12
12
  normalizeProjectAnnotations
13
- } from "../_browser-chunks/chunk-VUZYLZ4B.js";
14
- import "../_browser-chunks/chunk-IPA5A322.js";
13
+ } from "../_browser-chunks/chunk-QOXZ7W26.js";
14
+ import "../_browser-chunks/chunk-MEXTPDJG.js";
15
+ import {
16
+ Tag
17
+ } from "../_browser-chunks/chunk-AFVOZMXQ.js";
15
18
  import "../_browser-chunks/chunk-XLJZ7AOP.js";
16
19
  import {
17
20
  combineParameters
18
- } from "../_browser-chunks/chunk-LOTN4ZCW.js";
19
- import "../_browser-chunks/chunk-XCZK5QUJ.js";
21
+ } from "../_browser-chunks/chunk-SI6AKD4S.js";
22
+ import "../_browser-chunks/chunk-IYCKG66Y.js";
23
+ import "../_browser-chunks/chunk-NZMVUW5T.js";
20
24
  import {
21
25
  invariant
22
26
  } from "../_browser-chunks/chunk-IWQGIXJS.js";
23
27
  import "../_browser-chunks/chunk-V2VKKSMQ.js";
24
- import "../_browser-chunks/chunk-CLSHX4VX.js";
25
- import "../_browser-chunks/chunk-HPYUT3WS.js";
26
- import "../_browser-chunks/chunk-2NDLAB5X.js";
27
- import "../_browser-chunks/chunk-NZMVUW5T.js";
28
+ import "../_browser-chunks/chunk-YK43Z22A.js";
29
+ import "../_browser-chunks/chunk-LCHBOIHN.js";
28
30
  import "../_browser-chunks/chunk-ZCFV7BZB.js";
29
31
  import {
30
32
  dedent
@@ -338,8 +340,30 @@ var { step } = instrument(
338
340
  runStep: step
339
341
  });
340
342
 
341
- // src/highlight/preview.ts
343
+ // src/core-server/utils/ghost-stories/test-annotations.ts
342
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";
343
367
  import { addons } from "storybook/preview-api";
344
368
 
345
369
  // src/highlight/useHighlights.ts
@@ -890,10 +914,10 @@ var menuId = "storybook-highlights-menu", rootId = "storybook-highlights-root",
890
914
 
891
915
  // src/highlight/preview.ts
892
916
  globalThis?.FEATURES?.highlight && addons?.ready && addons.ready().then(useHighlights);
893
- var preview_default4 = () => definePreviewAddon4({});
917
+ var preview_default4 = () => definePreviewAddon5({});
894
918
 
895
919
  // src/measure/preview.ts
896
- import { definePreviewAddon as definePreviewAddon5 } from "storybook/internal/csf";
920
+ import { definePreviewAddon as definePreviewAddon6 } from "storybook/internal/csf";
897
921
 
898
922
  // src/measure/withMeasure.ts
899
923
  import { useEffect as useEffect2 } from "storybook/preview-api";
@@ -1265,13 +1289,13 @@ var withMeasure = (StoryFn, context) => {
1265
1289
  // src/measure/preview.ts
1266
1290
  var decorators2 = globalThis.FEATURES?.measure ? [withMeasure] : [], initialGlobals2 = {
1267
1291
  [PARAM_KEY3]: !1
1268
- }, preview_default5 = () => definePreviewAddon5({
1292
+ }, preview_default5 = () => definePreviewAddon6({
1269
1293
  decorators: decorators2,
1270
1294
  initialGlobals: initialGlobals2
1271
1295
  });
1272
1296
 
1273
1297
  // src/outline/preview.ts
1274
- import { definePreviewAddon as definePreviewAddon6 } from "storybook/internal/csf";
1298
+ import { definePreviewAddon as definePreviewAddon7 } from "storybook/internal/csf";
1275
1299
 
1276
1300
  // src/outline/withOutline.ts
1277
1301
  import { useEffect as useEffect3, useMemo } from "storybook/preview-api";
@@ -1707,10 +1731,10 @@ var withOutline = (StoryFn, context) => {
1707
1731
  // src/outline/preview.ts
1708
1732
  var decorators3 = globalThis.FEATURES?.outline ? [withOutline] : [], initialGlobals3 = {
1709
1733
  [PARAM_KEY4]: !1
1710
- }, preview_default6 = () => definePreviewAddon6({ decorators: decorators3, initialGlobals: initialGlobals3 });
1734
+ }, preview_default6 = () => definePreviewAddon7({ decorators: decorators3, initialGlobals: initialGlobals3 });
1711
1735
 
1712
1736
  // src/test/preview.ts
1713
- import { definePreviewAddon as definePreviewAddon7 } from "storybook/internal/csf";
1737
+ import { definePreviewAddon as definePreviewAddon8 } from "storybook/internal/csf";
1714
1738
  import { instrument as instrument2 } from "storybook/internal/instrumenter";
1715
1739
  import {
1716
1740
  clearAllMocks,
@@ -1776,15 +1800,15 @@ var resetAllMocksLoader = ({ parameters: parameters2 }) => {
1776
1800
  }
1777
1801
  } catch {
1778
1802
  }
1779
- }, preview_default7 = () => definePreviewAddon7({
1803
+ }, preview_default7 = () => definePreviewAddon8({
1780
1804
  loaders: [resetAllMocksLoader, nameSpiesAndWrapActionsInSpies, enhanceContext]
1781
1805
  });
1782
1806
 
1783
1807
  // src/viewport/preview.ts
1784
- import { definePreviewAddon as definePreviewAddon8 } from "storybook/internal/csf";
1808
+ import { definePreviewAddon as definePreviewAddon9 } from "storybook/internal/csf";
1785
1809
  var initialGlobals4 = {
1786
1810
  [PARAM_KEY]: { value: void 0, isRotated: !1 }
1787
- }, preview_default8 = () => definePreviewAddon8({
1811
+ }, preview_default8 = () => definePreviewAddon9({
1788
1812
  initialGlobals: initialGlobals4
1789
1813
  });
1790
1814
 
@@ -1806,7 +1830,9 @@ function getCoreAnnotations() {
1806
1830
  // @ts-expect-error CJS fallback
1807
1831
  (preview_default3.default ?? preview_default3)(),
1808
1832
  // @ts-expect-error CJS fallback
1809
- (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)()
1810
1836
  ];
1811
1837
  }
1812
1838
 
@@ -1823,13 +1849,16 @@ function definePreview(input) {
1823
1849
  composeConfigs([...getCoreAnnotations(), ...addons2 ?? [], rest])
1824
1850
  ), composed;
1825
1851
  },
1852
+ type() {
1853
+ return this;
1854
+ },
1826
1855
  meta(meta) {
1827
1856
  return defineMeta(meta, this);
1828
1857
  }
1829
1858
  };
1830
1859
  return globalThis.globalProjectAnnotations = preview.composed, preview;
1831
1860
  }
1832
- function definePreviewAddon9(preview) {
1861
+ function definePreviewAddon10(preview) {
1833
1862
  return preview;
1834
1863
  }
1835
1864
  function isPreview(input) {
@@ -1841,7 +1870,7 @@ function isMeta(input) {
1841
1870
  function defineMeta(input, preview) {
1842
1871
  return {
1843
1872
  _tag: "Meta",
1844
- input,
1873
+ input: { ...input, parameters: { ...input.parameters, csfFactory: !0 } },
1845
1874
  preview,
1846
1875
  // @ts-expect-error hard
1847
1876
  story(story = {}) {
@@ -1889,7 +1918,7 @@ function defineStory(input, meta) {
1889
1918
  }, test = this.extend({
1890
1919
  ...annotations,
1891
1920
  name,
1892
- tags: ["test-fn", "!autodocs", ...annotations.tags ?? []],
1921
+ tags: [Tag.TEST_FN, `!${Tag.AUTODOCS}`, ...annotations.tags ?? []],
1893
1922
  play
1894
1923
  });
1895
1924
  return __children.push(test), test;
@@ -1959,7 +1988,7 @@ var parseKind = (kind, { rootSeparator, groupSeparator }) => {
1959
1988
  export {
1960
1989
  combineTags2 as combineTags,
1961
1990
  definePreview,
1962
- definePreviewAddon9 as definePreviewAddon,
1991
+ definePreviewAddon10 as definePreviewAddon,
1963
1992
  getCoreAnnotations,
1964
1993
  getStoryChildren,
1965
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
- export { BadMetaError, ConfigFile, CsfFile, type CsfOptions, type EnrichCsfOptions, MixedFactoryError, MultipleMetaError, NoMetaError, type StaticMeta, type StaticStory, type StoryTest, babelParseFile, enrichCsf, enrichCsfMeta, enrichCsfStory, extractDescription, extractSource, formatConfig, formatCsf, getStorySortParameter, isCsfFactoryPreview, isModuleMock, isValidPreviewPath, loadConfig, loadCsf, printConfig, printCsf, readConfig, readCsf, vitestTransform, writeConfig, writeCsf };
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 };
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_3bfbtrdgjix from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_3bfbtrdgjix from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_3bfbtrdgjix from "node:module";
1
+ import CJS_COMPAT_NODE_URL_phceqgr585q from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_phceqgr585q from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_phceqgr585q from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_3bfbtrdgjix.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_3bfbtrdgjix.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_3bfbtrdgjix.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_phceqgr585q.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_phceqgr585q.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_phceqgr585q.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,9 +39,9 @@ import {
38
39
  vitestTransform,
39
40
  writeConfig,
40
41
  writeCsf
41
- } from "../_node-chunks/chunk-VJFHZL2T.js";
42
- import "../_node-chunks/chunk-TTGXODEY.js";
43
- import "../_node-chunks/chunk-5WQXPM6D.js";
42
+ } from "../_node-chunks/chunk-QL6L57W7.js";
43
+ import "../_node-chunks/chunk-BLGRU6F5.js";
44
+ import "../_node-chunks/chunk-AXDM43NU.js";
44
45
  export {
45
46
  BadMetaError,
46
47
  ConfigFile,
@@ -50,6 +51,7 @@ export {
50
51
  NoMetaError,
51
52
  babelParse,
52
53
  babelParseFile,
54
+ componentTransform,
53
55
  enrichCsf,
54
56
  enrichCsfMeta,
55
57
  enrichCsfStory,
@@ -15,8 +15,8 @@ interface JsDocTags {
15
15
  returns?: JsDocReturns | null;
16
16
  }
17
17
  interface PropSummaryValue {
18
- summary?: string;
19
- detail?: string;
18
+ summary?: string | undefined;
19
+ detail?: string | undefined;
20
20
  }
21
21
  type PropType = PropSummaryValue;
22
22
  type PropDefaultValue = PropSummaryValue;
@@ -24,12 +24,11 @@ import {
24
24
  normalizeNewlines,
25
25
  parseJsDoc,
26
26
  str
27
- } from "../_browser-chunks/chunk-LOTN4ZCW.js";
28
- import "../_browser-chunks/chunk-XCZK5QUJ.js";
29
- import "../_browser-chunks/chunk-CLSHX4VX.js";
30
- import "../_browser-chunks/chunk-HPYUT3WS.js";
31
- import "../_browser-chunks/chunk-2NDLAB5X.js";
27
+ } from "../_browser-chunks/chunk-SI6AKD4S.js";
28
+ import "../_browser-chunks/chunk-IYCKG66Y.js";
32
29
  import "../_browser-chunks/chunk-NZMVUW5T.js";
30
+ import "../_browser-chunks/chunk-YK43Z22A.js";
31
+ import "../_browser-chunks/chunk-LCHBOIHN.js";
33
32
  import "../_browser-chunks/chunk-A242L54C.js";
34
33
  export {
35
34
  ADDON_ID,