@storybook/react 11.0.0-alpha.0 → 11.0.0-alpha.2

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/index.d.ts CHANGED
@@ -1,6 +1,869 @@
1
- import { _ as ReactRenderer, a as AddMocks, c as Decorator, d as Parameters, f as Preview, g as StrictArgs, h as StoryObj, i as __definePreview, l as Loader, m as StoryFn, n as ReactPreview, o as ArgTypes, p as StoryContext, r as ReactStory, s as Args, t as ReactMeta, u as Meta, v as ReactTypes } from "./chunk-ojHmM-yX.js";
2
- import { Args as Args$1, ComposedStoryFn, NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, ProjectAnnotations, Store_CSFExports, StoriesWithPartialProps, StoryAnnotationsOrFn } from "storybook/internal/types";
1
+ import { a as ReactRenderer, i as __definePreview, n as ReactPreview, o as ReactTypes, r as ReactStory, s as Simplify, t as ReactMeta } from "./chunk-DT7W2slC.js";
2
+ import { ComponentProps, ComponentType } from "react";
3
+ import { AnnotatedStoryFn, ArgTypes, Args, Args as Args$1, ArgsFromMeta, ArgsStoryFn, ComponentAnnotations, ComposedStoryFn, DecoratorFunction, LoaderFunction, NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, Parameters as Parameters$1, ProjectAnnotations, Store_CSFExports, StoriesWithPartialProps, StoryAnnotations, StoryAnnotationsOrFn, StoryContext as StoryContext$1, StrictArgs, StrictArgs as StrictArgs$1 } from "storybook/internal/types";
3
4
 
5
+ //#region node_modules/type-fest/source/union-to-intersection.d.ts
6
+ /**
7
+ Convert a union type to an intersection type.
8
+
9
+ Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
10
+
11
+ @example
12
+ ```
13
+ import type {UnionToIntersection} from 'type-fest';
14
+
15
+ type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
16
+
17
+ type Intersection = UnionToIntersection<Union>;
18
+ //=> {the(): void} & {great(arg: string): void} & {escape: boolean}
19
+ ```
20
+
21
+ @category Type
22
+ */
23
+ type UnionToIntersection<Union> = (// `extends unknown` is always going to be the case and is used to convert the
24
+ // `Union` into a [distributive conditional
25
+ // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
26
+ Union extends unknown // The union type is used as the only argument to a function since the union
27
+ // of function arguments is an intersection.
28
+ ? (distributedUnion: Union) => void // This won't happen.
29
+ : never // Infer the `Intersection` type since TypeScript represents the positional
30
+ // arguments of unions of functions as an intersection of the union.
31
+ ) extends ((mergedIntersection: infer Intersection) => void) // The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
32
+ ? Intersection & Union : never;
33
+ //#endregion
34
+ //#region node_modules/type-fest/source/keys-of-union.d.ts
35
+ /**
36
+ Create a union of all keys from a given type, even those exclusive to specific union members.
37
+
38
+ Unlike the native `keyof` keyword, which returns keys present in **all** union members, this type returns keys from **any** member.
39
+
40
+ @link https://stackoverflow.com/a/49402091
41
+
42
+ @example
43
+ ```
44
+ import type {KeysOfUnion} from 'type-fest';
45
+
46
+ type A = {
47
+ common: string;
48
+ a: number;
49
+ };
50
+
51
+ type B = {
52
+ common: string;
53
+ b: string;
54
+ };
55
+
56
+ type C = {
57
+ common: string;
58
+ c: boolean;
59
+ };
60
+
61
+ type Union = A | B | C;
62
+
63
+ type CommonKeys = keyof Union;
64
+ //=> 'common'
65
+
66
+ type AllKeys = KeysOfUnion<Union>;
67
+ //=> 'common' | 'a' | 'b' | 'c'
68
+ ```
69
+
70
+ @category Object
71
+ */
72
+ type KeysOfUnion<ObjectType> = // Hack to fix https://github.com/sindresorhus/type-fest/issues/1008
73
+ keyof UnionToIntersection<ObjectType extends unknown ? Record<keyof ObjectType, never> : never>;
74
+ //#endregion
75
+ //#region node_modules/type-fest/source/is-any.d.ts
76
+ /**
77
+ Returns a boolean for whether the given type is `any`.
78
+
79
+ @link https://stackoverflow.com/a/49928360/1490091
80
+
81
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
82
+
83
+ @example
84
+ ```
85
+ import type {IsAny} from 'type-fest';
86
+
87
+ const typedObject = {a: 1, b: 2} as const;
88
+ const anyObject: any = {a: 1, b: 2};
89
+
90
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
91
+ return object[key];
92
+ }
93
+
94
+ const typedA = get(typedObject, 'a');
95
+ //=> 1
96
+
97
+ const anyA = get(anyObject, 'a');
98
+ //=> any
99
+ ```
100
+
101
+ @category Type Guard
102
+ @category Utilities
103
+ */
104
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
105
+ //#endregion
106
+ //#region node_modules/type-fest/source/is-optional-key-of.d.ts
107
+ /**
108
+ Returns a boolean for whether the given key is an optional key of type.
109
+
110
+ This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
111
+
112
+ @example
113
+ ```
114
+ import type {IsOptionalKeyOf} from 'type-fest';
115
+
116
+ type User = {
117
+ name: string;
118
+ surname: string;
119
+
120
+ luckyNumber?: number;
121
+ };
122
+
123
+ type Admin = {
124
+ name: string;
125
+ surname?: string;
126
+ };
127
+
128
+ type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
129
+ //=> true
130
+
131
+ type T2 = IsOptionalKeyOf<User, 'name'>;
132
+ //=> false
133
+
134
+ type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
135
+ //=> boolean
136
+
137
+ type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
138
+ //=> false
139
+
140
+ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
141
+ //=> boolean
142
+ ```
143
+
144
+ @category Type Guard
145
+ @category Utilities
146
+ */
147
+ type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
148
+ //#endregion
149
+ //#region node_modules/type-fest/source/optional-keys-of.d.ts
150
+ /**
151
+ Extract all optional keys from the given type.
152
+
153
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
154
+
155
+ @example
156
+ ```
157
+ import type {OptionalKeysOf, Except} from 'type-fest';
158
+
159
+ type User = {
160
+ name: string;
161
+ surname: string;
162
+
163
+ luckyNumber?: number;
164
+ };
165
+
166
+ const REMOVE_FIELD = Symbol('remove field symbol');
167
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
168
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
169
+ };
170
+
171
+ const update1: UpdateOperation<User> = {
172
+ name: 'Alice',
173
+ };
174
+
175
+ const update2: UpdateOperation<User> = {
176
+ name: 'Bob',
177
+ luckyNumber: REMOVE_FIELD,
178
+ };
179
+ ```
180
+
181
+ @category Utilities
182
+ */
183
+ type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
184
+ ? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
185
+ : never;
186
+ //#endregion
187
+ //#region node_modules/type-fest/source/required-keys-of.d.ts
188
+ /**
189
+ Extract all required keys from the given type.
190
+
191
+ This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
192
+
193
+ @example
194
+ ```
195
+ import type {RequiredKeysOf} from 'type-fest';
196
+
197
+ declare function createValidation<
198
+ Entity extends object,
199
+ Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
200
+ >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
201
+
202
+ type User = {
203
+ name: string;
204
+ surname: string;
205
+ luckyNumber?: number;
206
+ };
207
+
208
+ const validator1 = createValidation<User>('name', value => value.length < 25);
209
+ const validator2 = createValidation<User>('surname', value => value.length < 25);
210
+
211
+ // @ts-expect-error
212
+ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
213
+ // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
214
+ ```
215
+
216
+ @category Utilities
217
+ */
218
+ type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
219
+ ? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
220
+ //#endregion
221
+ //#region node_modules/type-fest/source/is-never.d.ts
222
+ /**
223
+ Returns a boolean for whether the given type is `never`.
224
+
225
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
226
+ @link https://stackoverflow.com/a/53984913/10292952
227
+ @link https://www.zhenghao.io/posts/ts-never
228
+
229
+ Useful in type utilities, such as checking if something does not occur.
230
+
231
+ @example
232
+ ```
233
+ import type {IsNever, And} from 'type-fest';
234
+
235
+ type A = IsNever<never>;
236
+ //=> true
237
+
238
+ type B = IsNever<any>;
239
+ //=> false
240
+
241
+ type C = IsNever<unknown>;
242
+ //=> false
243
+
244
+ type D = IsNever<never[]>;
245
+ //=> false
246
+
247
+ type E = IsNever<object>;
248
+ //=> false
249
+
250
+ type F = IsNever<string>;
251
+ //=> false
252
+ ```
253
+
254
+ @example
255
+ ```
256
+ import type {IsNever} from 'type-fest';
257
+
258
+ type IsTrue<T> = T extends true ? true : false;
259
+
260
+ // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
261
+ type A = IsTrue<never>;
262
+ //=> never
263
+
264
+ // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
265
+ type IsTrueFixed<T> =
266
+ IsNever<T> extends true ? false : T extends true ? true : false;
267
+
268
+ type B = IsTrueFixed<never>;
269
+ //=> false
270
+ ```
271
+
272
+ @category Type Guard
273
+ @category Utilities
274
+ */
275
+ type IsNever<T> = [T] extends [never] ? true : false;
276
+ //#endregion
277
+ //#region node_modules/type-fest/source/if.d.ts
278
+ /**
279
+ An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
280
+
281
+ Use-cases:
282
+ - You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
283
+
284
+ Note:
285
+ - Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
286
+ - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
287
+
288
+ @example
289
+ ```
290
+ import type {If} from 'type-fest';
291
+
292
+ type A = If<true, 'yes', 'no'>;
293
+ //=> 'yes'
294
+
295
+ type B = If<false, 'yes', 'no'>;
296
+ //=> 'no'
297
+
298
+ type C = If<boolean, 'yes', 'no'>;
299
+ //=> 'yes' | 'no'
300
+
301
+ type D = If<any, 'yes', 'no'>;
302
+ //=> 'yes' | 'no'
303
+
304
+ type E = If<never, 'yes', 'no'>;
305
+ //=> 'no'
306
+ ```
307
+
308
+ @example
309
+ ```
310
+ import type {If, IsAny, IsNever} from 'type-fest';
311
+
312
+ type A = If<IsAny<unknown>, 'is any', 'not any'>;
313
+ //=> 'not any'
314
+
315
+ type B = If<IsNever<never>, 'is never', 'not never'>;
316
+ //=> 'is never'
317
+ ```
318
+
319
+ @example
320
+ ```
321
+ import type {If, IsEqual} from 'type-fest';
322
+
323
+ type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
324
+
325
+ type A = IfEqual<string, string, 'equal', 'not equal'>;
326
+ //=> 'equal'
327
+
328
+ type B = IfEqual<string, number, 'equal', 'not equal'>;
329
+ //=> 'not equal'
330
+ ```
331
+
332
+ Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
333
+
334
+ @example
335
+ ```
336
+ import type {If, IsEqual, StringRepeat} from 'type-fest';
337
+
338
+ type HundredZeroes = StringRepeat<'0', 100>;
339
+
340
+ // The following implementation is not tail recursive
341
+ type Includes<S extends string, Char extends string> =
342
+ S extends `${infer First}${infer Rest}`
343
+ ? If<IsEqual<First, Char>,
344
+ 'found',
345
+ Includes<Rest, Char>>
346
+ : 'not found';
347
+
348
+ // Hence, instantiations with long strings will fail
349
+ // @ts-expect-error
350
+ type Fails = Includes<HundredZeroes, '1'>;
351
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
352
+ // Error: Type instantiation is excessively deep and possibly infinite.
353
+
354
+ // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
355
+ type IncludesWithoutIf<S extends string, Char extends string> =
356
+ S extends `${infer First}${infer Rest}`
357
+ ? IsEqual<First, Char> extends true
358
+ ? 'found'
359
+ : IncludesWithoutIf<Rest, Char>
360
+ : 'not found';
361
+
362
+ // Now, instantiations with long strings will work
363
+ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
364
+ //=> 'not found'
365
+ ```
366
+
367
+ @category Type Guard
368
+ @category Utilities
369
+ */
370
+ type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
371
+ //#endregion
372
+ //#region node_modules/type-fest/source/is-equal.d.ts
373
+ /**
374
+ Returns a boolean for whether the two given types are equal.
375
+
376
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
377
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
378
+
379
+ Use-cases:
380
+ - If you want to make a conditional branch based on the result of a comparison of two types.
381
+
382
+ @example
383
+ ```
384
+ import type {IsEqual} from 'type-fest';
385
+
386
+ // This type returns a boolean for whether the given array includes the given item.
387
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
388
+ type Includes<Value extends readonly any[], Item> =
389
+ Value extends readonly [Value[0], ...infer rest]
390
+ ? IsEqual<Value[0], Item> extends true
391
+ ? true
392
+ : Includes<rest, Item>
393
+ : false;
394
+ ```
395
+
396
+ @category Type Guard
397
+ @category Utilities
398
+ */
399
+ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
400
+ // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
401
+ type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
402
+ //#endregion
403
+ //#region node_modules/type-fest/source/omit-index-signature.d.ts
404
+ /**
405
+ Omit any index signatures from the given object type, leaving only explicitly defined properties.
406
+
407
+ This is the counterpart of `PickIndexSignature`.
408
+
409
+ Use-cases:
410
+ - Remove overly permissive signatures from third-party types.
411
+
412
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
413
+
414
+ It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
415
+
416
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
417
+
418
+ ```
419
+ const indexed: Record<string, unknown> = {}; // Allowed
420
+
421
+ // @ts-expect-error
422
+ const keyed: Record<'foo', unknown> = {}; // Error
423
+ // TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
424
+ ```
425
+
426
+ Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
427
+
428
+ ```
429
+ type Indexed = {} extends Record<string, unknown>
430
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
431
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
432
+
433
+ type IndexedResult = Indexed;
434
+ //=> '✅ `{}` is assignable to `Record<string, unknown>`'
435
+
436
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
437
+ ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
438
+ : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
439
+
440
+ type KeyedResult = Keyed;
441
+ //=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
442
+ ```
443
+
444
+ Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
445
+
446
+ ```
447
+ type OmitIndexSignature<ObjectType> = {
448
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
449
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
450
+ };
451
+ ```
452
+
453
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
454
+
455
+ ```
456
+ type OmitIndexSignature<ObjectType> = {
457
+ [KeyType in keyof ObjectType
458
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
459
+ as {} extends Record<KeyType, unknown>
460
+ ? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
461
+ : KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
462
+ ]: ObjectType[KeyType];
463
+ };
464
+ ```
465
+
466
+ If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
467
+
468
+ @example
469
+ ```
470
+ import type {OmitIndexSignature} from 'type-fest';
471
+
472
+ type Example = {
473
+ // These index signatures will be removed.
474
+ [x: string]: any;
475
+ [x: number]: any;
476
+ [x: symbol]: any;
477
+ [x: `head-${string}`]: string;
478
+ [x: `${string}-tail`]: string;
479
+ [x: `head-${string}-tail`]: string;
480
+ [x: `${bigint}`]: string;
481
+ [x: `embedded-${number}`]: string;
482
+
483
+ // These explicitly defined keys will remain.
484
+ foo: 'bar';
485
+ qux?: 'baz';
486
+ };
487
+
488
+ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
489
+ //=> {foo: 'bar'; qux?: 'baz'}
490
+ ```
491
+
492
+ @see {@link PickIndexSignature}
493
+ @category Object
494
+ */
495
+ type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
496
+ //#endregion
497
+ //#region node_modules/type-fest/source/pick-index-signature.d.ts
498
+ /**
499
+ Pick only index signatures from the given object type, leaving out all explicitly defined properties.
500
+
501
+ This is the counterpart of `OmitIndexSignature`.
502
+
503
+ @example
504
+ ```
505
+ import type {PickIndexSignature} from 'type-fest';
506
+
507
+ declare const symbolKey: unique symbol;
508
+
509
+ type Example = {
510
+ // These index signatures will remain.
511
+ [x: string]: unknown;
512
+ [x: number]: unknown;
513
+ [x: symbol]: unknown;
514
+ [x: `head-${string}`]: string;
515
+ [x: `${string}-tail`]: string;
516
+ [x: `head-${string}-tail`]: string;
517
+ [x: `${bigint}`]: string;
518
+ [x: `embedded-${number}`]: string;
519
+
520
+ // These explicitly defined keys will be removed.
521
+ ['kebab-case-key']: string;
522
+ [symbolKey]: string;
523
+ foo: 'bar';
524
+ qux?: 'baz';
525
+ };
526
+
527
+ type ExampleIndexSignature = PickIndexSignature<Example>;
528
+ // {
529
+ // [x: string]: unknown;
530
+ // [x: number]: unknown;
531
+ // [x: symbol]: unknown;
532
+ // [x: `head-${string}`]: string;
533
+ // [x: `${string}-tail`]: string;
534
+ // [x: `head-${string}-tail`]: string;
535
+ // [x: `${bigint}`]: string;
536
+ // [x: `embedded-${number}`]: string;
537
+ // }
538
+ ```
539
+
540
+ @see {@link OmitIndexSignature}
541
+ @category Object
542
+ */
543
+ type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
544
+ //#endregion
545
+ //#region node_modules/type-fest/source/merge.d.ts
546
+ // Merges two objects without worrying about index signatures.
547
+ type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
548
+ /**
549
+ Merge two types into a new type. Keys of the second type overrides keys of the first type.
550
+
551
+ This is different from the TypeScript `&` (intersection) operator. With `&`, conflicting property types are intersected, which often results in `never`. For example, `{a: string} & {a: number}` makes `a` become `string & number`, which resolves to `never`. With `Merge`, the second type's keys cleanly override the first, so `Merge<{a: string}, {a: number}>` gives `{a: number}` as expected. `Merge` also produces a flattened type (via `Simplify`), making it more readable in IDE tooltips compared to `A & B`.
552
+
553
+ @example
554
+ ```
555
+ import type {Merge} from 'type-fest';
556
+
557
+ type Foo = {
558
+ a: string;
559
+ b: number;
560
+ };
561
+
562
+ type Bar = {
563
+ a: number; // Conflicts with Foo['a']
564
+ c: boolean;
565
+ };
566
+
567
+ // With `&`, `a` becomes `string & number` which is `never`. Not what you want.
568
+ type WithIntersection = (Foo & Bar)['a'];
569
+ //=> never
570
+
571
+ // With `Merge`, `a` is cleanly overridden to `number`.
572
+ type WithMerge = Merge<Foo, Bar>['a'];
573
+ //=> number
574
+ ```
575
+
576
+ @example
577
+ ```
578
+ import type {Merge} from 'type-fest';
579
+
580
+ type Foo = {
581
+ [x: string]: unknown;
582
+ [x: number]: unknown;
583
+ foo: string;
584
+ bar: symbol;
585
+ };
586
+
587
+ type Bar = {
588
+ [x: number]: number;
589
+ [x: symbol]: unknown;
590
+ bar: Date;
591
+ baz: boolean;
592
+ };
593
+
594
+ export type FooBar = Merge<Foo, Bar>;
595
+ //=> {
596
+ // [x: string]: unknown;
597
+ // [x: number]: number;
598
+ // [x: symbol]: unknown;
599
+ // foo: string;
600
+ // bar: Date;
601
+ // baz: boolean;
602
+ // }
603
+ ```
604
+
605
+ Note: If you want a merge type that more accurately reflects the runtime behavior of object spread or `Object.assign`, refer to the {@link ObjectMerge} type.
606
+
607
+ @see {@link ObjectMerge}
608
+ @category Object
609
+ */
610
+ type Merge<Destination, Source> = Destination extends unknown // For distributing `Destination`
611
+ ? Source extends unknown // For distributing `Source`
612
+ ? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
613
+ : never;
614
+ // Should never happen
615
+ type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
616
+ //#endregion
617
+ //#region node_modules/type-fest/source/internal/object.d.ts
618
+ /**
619
+ Works similar to the built-in `Pick` utility type, except for the following differences:
620
+ - Distributes over union types and allows picking keys from any member of the union type.
621
+ - Primitives types are returned as-is.
622
+ - Picks all keys if `Keys` is `any`.
623
+ - Doesn't pick `number` from a `string` index signature.
624
+
625
+ @example
626
+ ```
627
+ type ImageUpload = {
628
+ url: string;
629
+ size: number;
630
+ thumbnailUrl: string;
631
+ };
632
+
633
+ type VideoUpload = {
634
+ url: string;
635
+ duration: number;
636
+ encodingFormat: string;
637
+ };
638
+
639
+ // Distributes over union types and allows picking keys from any member of the union type
640
+ type MediaDisplay = HomomorphicPick<ImageUpload | VideoUpload, "url" | "size" | "duration">;
641
+ //=> {url: string; size: number} | {url: string; duration: number}
642
+
643
+ // Primitive types are returned as-is
644
+ type Primitive = HomomorphicPick<string | number, 'toUpperCase' | 'toString'>;
645
+ //=> string | number
646
+
647
+ // Picks all keys if `Keys` is `any`
648
+ type Any = HomomorphicPick<{a: 1; b: 2} | {c: 3}, any>;
649
+ //=> {a: 1; b: 2} | {c: 3}
650
+
651
+ // Doesn't pick `number` from a `string` index signature
652
+ type IndexSignature = HomomorphicPick<{[k: string]: unknown}, number>;
653
+ //=> {}
654
+ */
655
+ type HomomorphicPick<T, Keys extends KeysOfUnion<T>> = { [P in keyof T as Extract<P, Keys>]: T[P] };
656
+ /**
657
+ Merges user specified options with default options.
658
+
659
+ @example
660
+ ```
661
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
662
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
663
+ type SpecifiedOptions = {leavesOnly: true};
664
+
665
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
666
+ //=> {maxRecursionDepth: 10; leavesOnly: true}
667
+ ```
668
+
669
+ @example
670
+ ```
671
+ // Complains if default values are not provided for optional options
672
+
673
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
674
+ type DefaultPathsOptions = {maxRecursionDepth: 10};
675
+ type SpecifiedOptions = {};
676
+
677
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
678
+ // ~~~~~~~~~~~~~~~~~~~
679
+ // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
680
+ ```
681
+
682
+ @example
683
+ ```
684
+ // Complains if an option's default type does not conform to the expected type
685
+
686
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
687
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
688
+ type SpecifiedOptions = {};
689
+
690
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
691
+ // ~~~~~~~~~~~~~~~~~~~
692
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
693
+ ```
694
+
695
+ @example
696
+ ```
697
+ // Complains if an option's specified type does not conform to the expected type
698
+
699
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
700
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
701
+ type SpecifiedOptions = {leavesOnly: 'yes'};
702
+
703
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
704
+ // ~~~~~~~~~~~~~~~~
705
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
706
+ ```
707
+ */
708
+ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
709
+ //#endregion
710
+ //#region node_modules/type-fest/source/except.d.ts
711
+ /**
712
+ Filter out keys from an object.
713
+
714
+ Returns `never` if `Exclude` is strictly equal to `Key`.
715
+ Returns `never` if `Key` extends `Exclude`.
716
+ Returns `Key` otherwise.
717
+
718
+ @example
719
+ ```
720
+ type Filtered = Filter<'foo', 'foo'>;
721
+ //=> never
722
+ ```
723
+
724
+ @example
725
+ ```
726
+ type Filtered = Filter<'bar', string>;
727
+ //=> never
728
+ ```
729
+
730
+ @example
731
+ ```
732
+ type Filtered = Filter<'bar', 'foo'>;
733
+ //=> 'bar'
734
+ ```
735
+
736
+ @see {Except}
737
+ */
738
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
739
+ type ExceptOptions = {
740
+ /**
741
+ Disallow assigning non-specified properties.
742
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
743
+ @default false
744
+ */
745
+ requireExactProps?: boolean;
746
+ };
747
+ type DefaultExceptOptions = {
748
+ requireExactProps: false;
749
+ };
750
+ /**
751
+ Create a type from an object type without certain keys.
752
+
753
+ We recommend setting the `requireExactProps` option to `true`.
754
+
755
+ 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.
756
+
757
+ 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)).
758
+
759
+ @example
760
+ ```
761
+ import type {Except} from 'type-fest';
762
+
763
+ type Foo = {
764
+ a: number;
765
+ b: string;
766
+ };
767
+
768
+ type FooWithoutA = Except<Foo, 'a'>;
769
+ //=> {b: string}
770
+
771
+ // @ts-expect-error
772
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
773
+ // errors: 'a' does not exist in type '{ b: string; }'
774
+
775
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
776
+ //=> {a: number} & Partial<Record<'b', never>>
777
+
778
+ // @ts-expect-error
779
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
780
+ // errors at 'b': Type 'string' is not assignable to type 'undefined'.
781
+
782
+ // The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
783
+
784
+ // Consider the following example:
785
+
786
+ type UserData = {
787
+ [metadata: string]: string;
788
+ email: string;
789
+ name: string;
790
+ role: 'admin' | 'user';
791
+ };
792
+
793
+ // `Omit` clearly doesn't behave as expected in this case:
794
+ type PostPayload = Omit<UserData, 'email'>;
795
+ //=> {[x: string]: string; [x: number]: string}
796
+
797
+ // In situations like this, `Except` works better.
798
+ // It simply removes the `email` key while preserving all the other keys.
799
+ type PostPayloadFixed = Except<UserData, 'email'>;
800
+ //=> {[x: string]: string; name: string; role: 'admin' | 'user'}
801
+ ```
802
+
803
+ @category Object
804
+ */
805
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
806
+ type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
807
+ //#endregion
808
+ //#region node_modules/type-fest/source/set-optional.d.ts
809
+ /**
810
+ Create a type that makes the given keys optional, while keeping the remaining keys as is.
811
+
812
+ 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.
813
+
814
+ @example
815
+ ```
816
+ import type {SetOptional} from 'type-fest';
817
+
818
+ type Foo = {
819
+ a: number;
820
+ b?: string;
821
+ c: boolean;
822
+ };
823
+
824
+ type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
825
+ //=> {a: number; b?: string; c?: boolean}
826
+ ```
827
+
828
+ @category Object
829
+ */
830
+ type SetOptional<BaseType, Keys extends keyof BaseType> = (BaseType extends ((...arguments_: never) => any) ? (...arguments_: Parameters<BaseType>) => ReturnType<BaseType> : unknown) & _SetOptional<BaseType, Keys>;
831
+ type _SetOptional<BaseType, Keys extends keyof BaseType> = BaseType extends unknown // To distribute `BaseType` when it's a union type.
832
+ ? Simplify< // Pick just the keys that are readonly from the base type.
833
+ Except<BaseType, Keys> // Pick the keys that should be mutable from the base type and make them mutable.
834
+ & Partial<HomomorphicPick<BaseType, Keys>>> : never;
835
+ //#endregion
836
+ //#region code/renderers/react/.dts-emit/code/renderers/react/src/public-types.d.ts
837
+ /**
838
+ * Metadata to configure the stories for a component.
839
+ *
840
+ * @see [Default export](https://storybook.js.org/docs/api/csf#default-export)
841
+ */
842
+ type Meta<TCmpOrArgs = Args$1> = [TCmpOrArgs] extends [ComponentType<any>] ? ComponentAnnotations<ReactRenderer, ComponentProps<TCmpOrArgs>> : ComponentAnnotations<ReactRenderer, TCmpOrArgs>;
843
+ /**
844
+ * Story function that represents a CSFv2 component example.
845
+ *
846
+ * @see [Named Story exports](https://storybook.js.org/docs/api/csf#named-story-exports)
847
+ */
848
+ type StoryFn<TCmpOrArgs = Args$1> = [TCmpOrArgs] extends [ComponentType<any>] ? AnnotatedStoryFn<ReactRenderer, ComponentProps<TCmpOrArgs>> : AnnotatedStoryFn<ReactRenderer, TCmpOrArgs>;
849
+ /**
850
+ * Story object that represents a CSFv3 component example.
851
+ *
852
+ * @see [Named Story exports](https://storybook.js.org/docs/api/csf#named-story-exports)
853
+ */
854
+ type StoryObj<TMetaOrCmpOrArgs = Args$1> = [TMetaOrCmpOrArgs] extends [{
855
+ render?: ArgsStoryFn<ReactRenderer, any>;
856
+ component?: infer Component;
857
+ args?: infer DefaultArgs;
858
+ }] ? Simplify<(Component extends ComponentType<any> ? ComponentProps<Component> : unknown) & ArgsFromMeta<ReactRenderer, TMetaOrCmpOrArgs>> extends infer TArgs ? StoryAnnotations<ReactRenderer, AddMocks<TArgs, DefaultArgs>, SetOptional<TArgs, keyof TArgs & keyof DefaultArgs>> : never : TMetaOrCmpOrArgs extends ComponentType<any> ? StoryAnnotations<ReactRenderer, ComponentProps<TMetaOrCmpOrArgs>> : StoryAnnotations<ReactRenderer, TMetaOrCmpOrArgs>;
859
+ type AddMocks<TArgs, DefaultArgs> = Simplify<{ [T in keyof TArgs]: T extends keyof DefaultArgs ? DefaultArgs[T] extends ((...args: any) => any & {
860
+ mock: {};
861
+ }) ? DefaultArgs[T] : TArgs[T] : TArgs[T] }>;
862
+ type Decorator<TArgs = StrictArgs$1> = DecoratorFunction<ReactRenderer, TArgs>;
863
+ type Loader<TArgs = StrictArgs$1> = LoaderFunction<ReactRenderer, TArgs>;
864
+ type StoryContext<TArgs = StrictArgs$1> = StoryContext$1<ReactRenderer, TArgs>;
865
+ type Preview = ProjectAnnotations<ReactRenderer>;
866
+ //#endregion
4
867
  //#region code/renderers/react/.dts-emit/code/renderers/react/src/portable-stories.d.ts
5
868
  /**
6
869
  * Function that sets the globalConfig of your storybook. The global config is the preview module of
@@ -82,4 +945,4 @@ declare function composeStory<TArgs extends Args$1 = Args$1>(story: StoryAnnotat
82
945
  */
83
946
  declare function composeStories<TModule extends Store_CSFExports<ReactRenderer, any>>(csfExports: TModule, projectAnnotations?: ProjectAnnotations<ReactRenderer>): Omit<StoriesWithPartialProps<ReactRenderer, TModule>, keyof Store_CSFExports>;
84
947
  //#endregion
85
- export { AddMocks, type ArgTypes, type Args, Decorator, INTERNAL_DEFAULT_PROJECT_ANNOTATIONS, Loader, Meta, type Parameters, Preview, ReactMeta, ReactPreview, type ReactRenderer, ReactStory, type ReactTypes, StoryContext, StoryFn, StoryObj, type StrictArgs, __definePreview, composeStories, composeStory, setProjectAnnotations };
948
+ export { AddMocks, type ArgTypes, type Args, Decorator, INTERNAL_DEFAULT_PROJECT_ANNOTATIONS, Loader, Meta, type Parameters$1 as Parameters, Preview, ReactMeta, ReactPreview, type ReactRenderer, ReactStory, type ReactTypes, StoryContext, StoryFn, StoryObj, type StrictArgs, __definePreview, composeStories, composeStory, setProjectAnnotations };