storybook 10.2.0-alpha.14 → 10.2.0-alpha.16

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 (74) hide show
  1. package/dist/_browser-chunks/{chunk-3PJE6VLG.js → chunk-ASKQZAOS.js} +1 -12
  2. package/dist/_browser-chunks/{chunk-BGSDJMFM.js → chunk-NVLTWT3B.js} +18 -6
  3. package/dist/_node-chunks/{builder-manager-5XVPVHCY.js → builder-manager-DQ6DNDHX.js} +12 -12
  4. package/dist/_node-chunks/{camelcase-FFGUJRYA.js → camelcase-ILOVTISA.js} +7 -7
  5. package/dist/_node-chunks/{chunk-E6HZLFOP.js → chunk-3PMH6BEP.js} +6 -6
  6. package/dist/_node-chunks/{chunk-2YADPD4P.js → chunk-47ZRY4XW.js} +6 -6
  7. package/dist/_node-chunks/{chunk-CMIHYY2B.js → chunk-5E2HAJXY.js} +6 -6
  8. package/dist/_node-chunks/{chunk-YTUKBZV2.js → chunk-6QEWR44T.js} +7 -7
  9. package/dist/_node-chunks/{chunk-QMQVY3KQ.js → chunk-CFXIZS6A.js} +7 -7
  10. package/dist/_node-chunks/chunk-DGLVYUKY.js +61 -0
  11. package/dist/_node-chunks/{chunk-6GTCCSGS.js → chunk-FNQ5WLS5.js} +7 -7
  12. package/dist/_node-chunks/{chunk-QIMAARKG.js → chunk-IVYTDHSW.js} +7 -7
  13. package/dist/_node-chunks/{chunk-NTVADDN6.js → chunk-JXU4P6K3.js} +6 -6
  14. package/dist/_node-chunks/{chunk-JFZSVDUQ.js → chunk-K6FMM5LS.js} +6 -6
  15. package/dist/_node-chunks/{chunk-GCGJVMS3.js → chunk-KAAWGCHX.js} +12 -12
  16. package/dist/_node-chunks/{chunk-BVSGQAFJ.js → chunk-LOJ73E6E.js} +9 -9
  17. package/dist/_node-chunks/{chunk-5QADKW4W.js → chunk-M6AUSQA3.js} +20 -20
  18. package/dist/_node-chunks/chunk-MSK3YTQT.js +23 -0
  19. package/dist/_node-chunks/{chunk-3VHD3RGW.js → chunk-OKUHCLLJ.js} +8 -8
  20. package/dist/_node-chunks/{chunk-GCZN63RS.js → chunk-PGYIGHRK.js} +9 -9
  21. package/dist/_node-chunks/{chunk-AAS5TNPH.js → chunk-RIEIAV32.js} +7 -7
  22. package/dist/_node-chunks/chunk-SPPXK6CQ.js +18 -0
  23. package/dist/_node-chunks/{chunk-HCZ44VWL.js → chunk-SWN4HCJE.js} +6 -6
  24. package/dist/_node-chunks/{chunk-WSH26TMB.js → chunk-TDBTCAEB.js} +12 -12
  25. package/dist/_node-chunks/{chunk-TXHI4M3M.js → chunk-TLGG6YAX.js} +29 -26
  26. package/dist/_node-chunks/{chunk-OYPD7MWQ.js → chunk-TTACLBSG.js} +7 -7
  27. package/dist/_node-chunks/{chunk-HMYS7PGR.js → chunk-WIOSV6HC.js} +6 -6
  28. package/dist/_node-chunks/{chunk-MBD6J24T.js → chunk-WVXPIXUS.js} +7 -7
  29. package/dist/_node-chunks/{chunk-XDKXHH75.js → chunk-XJMJA2L4.js} +13 -13
  30. package/dist/_node-chunks/{chunk-AKBKA7MR.js → chunk-XWGABQX7.js} +6 -6
  31. package/dist/_node-chunks/{chunk-YUBIHW7G.js → chunk-YFUVKP3W.js} +7 -7
  32. package/dist/_node-chunks/{chunk-APXUJGPH.js → chunk-ZN5DGHF3.js} +10 -10
  33. package/dist/_node-chunks/{globby-WIEDAEV7.js → globby-A35XB3PP.js} +9 -9
  34. package/dist/_node-chunks/{lib-2RMM65EQ.js → lib-D5I6ETBH.js} +7 -7
  35. package/dist/_node-chunks/{mdx-N42X6CFJ-AFWG3A6F.js → mdx-N42X6CFJ-DZ4EAFAE.js} +8 -8
  36. package/dist/_node-chunks/{p-limit-JNVCICJD.js → p-limit-2CRKZRXN.js} +7 -7
  37. package/dist/babel/index.js +10 -10
  38. package/dist/bin/core.js +12 -12
  39. package/dist/bin/dispatcher.js +11 -11
  40. package/dist/bin/loader.js +9 -9
  41. package/dist/cli/index.d.ts +176 -176
  42. package/dist/cli/index.js +18 -18
  43. package/dist/common/index.js +19 -19
  44. package/dist/components/index.d.ts +1 -0
  45. package/dist/components/index.js +167 -166
  46. package/dist/core-events/index.d.ts +4 -4
  47. package/dist/core-server/index.d.ts +11 -1
  48. package/dist/core-server/index.js +217 -76
  49. package/dist/core-server/presets/common-manager.js +176 -134
  50. package/dist/core-server/presets/common-override-preset.js +9 -9
  51. package/dist/core-server/presets/common-preset.js +27 -26
  52. package/dist/csf/index.d.ts +132 -12
  53. package/dist/csf/index.js +5 -2
  54. package/dist/csf-tools/index.js +10 -10
  55. package/dist/docs-tools/index.d.ts +2 -2
  56. package/dist/manager/globals-runtime.js +97 -94
  57. package/dist/manager/runtime.js +1755 -985
  58. package/dist/manager-api/index.d.ts +1 -1
  59. package/dist/manager-api/index.js +10 -8
  60. package/dist/mocking-utils/index.js +8 -8
  61. package/dist/node-logger/index.js +9 -9
  62. package/dist/preview/runtime.js +18 -6
  63. package/dist/preview-api/index.d.ts +67 -68
  64. package/dist/preview-api/index.js +1 -1
  65. package/dist/server-errors.js +11 -11
  66. package/dist/telemetry/index.js +22 -22
  67. package/dist/types/index.d.ts +12 -6
  68. package/dist/viewport/index.d.ts +5 -3
  69. package/dist/viewport/index.js +12 -3
  70. package/package.json +2 -2
  71. package/dist/_node-chunks/chunk-N72VKZTH.js +0 -23
  72. package/dist/_node-chunks/chunk-NKHFAHA7.js +0 -18
  73. package/dist/_node-chunks/chunk-ZJ3OV7OO.js +0 -61
  74. package/dist/_node-chunks/dist-OBG2P3MZ.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
 
@@ -515,8 +616,9 @@ interface TestTypes {
515
616
  interface Viewport {
516
617
  name: string;
517
618
  styles: ViewportStyles;
518
- type?: 'desktop' | 'mobile' | 'tablet' | 'other';
619
+ type?: ViewportType;
519
620
  }
621
+ type ViewportType = 'desktop' | 'mobile' | 'tablet' | 'watch' | 'other';
520
622
  interface ViewportStyles {
521
623
  height: string;
522
624
  width: string;
@@ -524,7 +626,8 @@ interface ViewportStyles {
524
626
  type GlobalState = {
525
627
  /**
526
628
  * When set, the viewport is applied and cannot be changed using the toolbar. Must match the key
527
- * of one of the available viewports.
629
+ * of one of the available viewports or follow the format '{width}-{height}', e.g. '320-480' which
630
+ * may include a unit (e.g. '100vw' or '100pct').
528
631
  */
529
632
  value: string | undefined;
530
633
  /**
@@ -671,8 +774,8 @@ interface InputType {
671
774
  category?: string;
672
775
  /** @see https://storybook.js.org/docs/api/arg-types#tabledefaultvalue */
673
776
  defaultValue?: {
674
- summary?: string;
675
- detail?: string;
777
+ summary?: string | undefined;
778
+ detail?: string | undefined;
676
779
  };
677
780
  /** @see https://storybook.js.org/docs/api/arg-types#tabledisable */
678
781
  disable?: boolean;
@@ -680,8 +783,8 @@ interface InputType {
680
783
  subcategory?: string;
681
784
  /** @see https://storybook.js.org/docs/api/arg-types#tabletype */
682
785
  type?: {
683
- summary?: string;
684
- detail?: string;
786
+ summary?: string | undefined;
787
+ detail?: string | undefined;
685
788
  };
686
789
  };
687
790
  /** @see https://storybook.js.org/docs/api/arg-types#type */
@@ -719,7 +822,23 @@ interface GlobalTypes {
719
822
  interface StrictGlobalTypes {
720
823
  [name: string]: StrictInputType;
721
824
  }
825
+ /**
826
+ * AddonTypes allows addons to extend the type system with additional args, parameters, and globals.
827
+ *
828
+ * Addons can use `definePreviewAddon<AddonTypes>()` to declare additional types that will be merged
829
+ * into the story context. For example, an addon that provides a `theme` arg could declare:
830
+ *
831
+ * ```ts
832
+ * const themeAddon = definePreviewAddon<{ args: { theme: 'light' | 'dark' } }>({
833
+ * decorators: [(Story, { args }) => <ThemeProvider theme={args.theme}><Story /></ThemeProvider>]
834
+ * });
835
+ * ```
836
+ *
837
+ * When users include this addon in their preview config, the `theme` arg becomes available and
838
+ * type-checked across all stories.
839
+ */
722
840
  interface AddonTypes {
841
+ args?: unknown;
723
842
  parameters?: Record<string, any>;
724
843
  globals?: Record<string, any>;
725
844
  }
@@ -989,11 +1108,12 @@ interface Preview<TRenderer extends Renderer$1 = Renderer$1> {
989
1108
  addons?: PreviewAddon<never>[];
990
1109
  };
991
1110
  composed: NormalizedProjectAnnotations<TRenderer>;
992
- meta<TArgs extends Args$1, TInput extends ComponentAnnotations$1<TRenderer & {
1111
+ meta<TArgs, TInput extends ComponentAnnotations$1<TRenderer & {
993
1112
  args: TArgs;
994
- }, TArgs>>(input: TInput): Meta<TRenderer & {
1113
+ }, TArgs & TRenderer['args']>>(input: TInput): Meta<TRenderer & {
995
1114
  args: TArgs;
996
1115
  }, TInput>;
1116
+ type<T>(): Preview<TRenderer & T>;
997
1117
  }
998
1118
  type InferTypes<T extends PreviewAddon<never>[]> = T extends PreviewAddon<infer C>[] ? C & {
999
1119
  csf4: true;
@@ -1005,14 +1125,14 @@ interface PreviewAddon<in TExtraContext extends AddonTypes$1 = AddonTypes$1> ext
1005
1125
  }
1006
1126
  declare function definePreviewAddon<TExtraContext extends AddonTypes$1 = AddonTypes$1>(preview: ProjectAnnotations$1<Renderer$1>): PreviewAddon<TExtraContext>;
1007
1127
  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']>> {
1128
+ interface Meta<TRenderer extends Renderer$1, TMetaInput extends ComponentAnnotations$1<TRenderer, TRenderer['args']> = ComponentAnnotations$1<TRenderer, TRenderer['args']>> {
1009
1129
  readonly _tag: 'Meta';
1010
- input: TInput;
1130
+ input: TMetaInput;
1011
1131
  preview: Preview<TRenderer>;
1012
1132
  story(input?: () => TRenderer['storyResult']): Story<TRenderer, {
1013
1133
  render: () => TRenderer['storyResult'];
1014
1134
  }>;
1015
- story<TInput extends StoryAnnotations$1<TRenderer, TRenderer['args']>>(input?: TInput): Story<TRenderer, TInput>;
1135
+ story<TInput extends StoryAnnotations$1<TRenderer, TRenderer['args'], SetOptional<TRenderer['args'], keyof TRenderer['args'] & keyof TMetaInput['args']>>>(input?: TInput): Story<TRenderer, TInput>;
1016
1136
  }
1017
1137
  declare function isMeta(input: unknown): input is Meta<Renderer$1>;
1018
1138
  interface Story<TRenderer extends Renderer$1, TInput extends StoryAnnotations$1<TRenderer, TRenderer['args']> = StoryAnnotations$1<TRenderer, TRenderer['args']>> {
package/dist/csf/index.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  mountDestructured,
11
11
  normalizeArrays,
12
12
  normalizeProjectAnnotations
13
- } from "../_browser-chunks/chunk-BGSDJMFM.js";
13
+ } from "../_browser-chunks/chunk-NVLTWT3B.js";
14
14
  import "../_browser-chunks/chunk-MEXTPDJG.js";
15
15
  import {
16
16
  Tag
@@ -1825,6 +1825,9 @@ function definePreview(input) {
1825
1825
  composeConfigs([...getCoreAnnotations(), ...addons2 ?? [], rest])
1826
1826
  ), composed;
1827
1827
  },
1828
+ type() {
1829
+ return this;
1830
+ },
1828
1831
  meta(meta) {
1829
1832
  return defineMeta(meta, this);
1830
1833
  }
@@ -1843,7 +1846,7 @@ function isMeta(input) {
1843
1846
  function defineMeta(input, preview) {
1844
1847
  return {
1845
1848
  _tag: "Meta",
1846
- input,
1849
+ input: { ...input, parameters: { ...input.parameters, csfFactory: !0 } },
1847
1850
  preview,
1848
1851
  // @ts-expect-error hard
1849
1852
  story(story = {}) {
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_bgtyoteey4s from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_bgtyoteey4s from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_bgtyoteey4s from "node:module";
1
+ import CJS_COMPAT_NODE_URL_4zwbyhk64wx from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_4zwbyhk64wx from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_4zwbyhk64wx from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_bgtyoteey4s.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_bgtyoteey4s.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_bgtyoteey4s.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_4zwbyhk64wx.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_4zwbyhk64wx.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_4zwbyhk64wx.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -38,10 +38,10 @@ import {
38
38
  vitestTransform,
39
39
  writeConfig,
40
40
  writeCsf
41
- } from "../_node-chunks/chunk-TXHI4M3M.js";
42
- import "../_node-chunks/chunk-CMIHYY2B.js";
43
- import "../_node-chunks/chunk-YUBIHW7G.js";
44
- import "../_node-chunks/chunk-E6HZLFOP.js";
41
+ } from "../_node-chunks/chunk-TLGG6YAX.js";
42
+ import "../_node-chunks/chunk-5E2HAJXY.js";
43
+ import "../_node-chunks/chunk-YFUVKP3W.js";
44
+ import "../_node-chunks/chunk-3PMH6BEP.js";
45
45
  export {
46
46
  BadMetaError,
47
47
  ConfigFile,
@@ -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;