@storybook/tanstack-react 0.0.0 → 10.4.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.
@@ -0,0 +1,438 @@
1
+ import { ComponentType } from 'react';
2
+ import { PreviewAddon, InferTypes, AddonTypes } from 'storybook/internal/csf';
3
+ import { CompatibleString, ProjectAnnotations, Args, DecoratorFunction, ArgsStoryFn, Parameters as Parameters$1, ComponentAnnotations, Renderer, StoryAnnotations } from 'storybook/internal/types';
4
+ import { Register, AnyRoute, FileRoutesByPath } from '@tanstack/react-router';
5
+ import { Decorator, ReactTypes, ReactPreview, ReactMeta, ReactRenderer, Meta as Meta$1, StoryObj as StoryObj$1 } from '@storybook/react';
6
+ export * from '@storybook/react';
7
+ import { RoutesByPath, RouteOptions, ResolveParams, AnyContext } from '@tanstack/router-core';
8
+ import { BuilderOptions } from '@storybook/builder-vite';
9
+ import { StorybookConfig as StorybookConfig$1 } from '@storybook/react-vite';
10
+
11
+ declare global {
12
+ interface SymbolConstructor {
13
+ readonly observable: symbol;
14
+ }
15
+ }
16
+
17
+ /**
18
+ @see Simplify
19
+ */
20
+ interface SimplifyOptions {
21
+ /**
22
+ Do the simplification recursively.
23
+
24
+ @default false
25
+ */
26
+ deep?: boolean;
27
+ }
28
+
29
+ // Flatten a type without worrying about the result.
30
+ type Flatten<
31
+ AnyType,
32
+ Options extends SimplifyOptions = {},
33
+ > = Options['deep'] extends true
34
+ ? {[KeyType in keyof AnyType]: Simplify<AnyType[KeyType], Options>}
35
+ : {[KeyType in keyof AnyType]: AnyType[KeyType]};
36
+
37
+ /**
38
+ Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
39
+
40
+ @example
41
+ ```
42
+ import type {Simplify} from 'type-fest';
43
+
44
+ type PositionProps = {
45
+ top: number;
46
+ left: number;
47
+ };
48
+
49
+ type SizeProps = {
50
+ width: number;
51
+ height: number;
52
+ };
53
+
54
+ // In your editor, hovering over `Props` will show a flattened object with all the properties.
55
+ type Props = Simplify<PositionProps & SizeProps>;
56
+ ```
57
+
58
+ Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
59
+
60
+ If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
61
+
62
+ @example
63
+ ```
64
+ import type {Simplify} from 'type-fest';
65
+
66
+ interface SomeInterface {
67
+ foo: number;
68
+ bar?: string;
69
+ baz: number | undefined;
70
+ }
71
+
72
+ type SomeType = {
73
+ foo: number;
74
+ bar?: string;
75
+ baz: number | undefined;
76
+ };
77
+
78
+ const literal = {foo: 123, bar: 'hello', baz: 456};
79
+ const someType: SomeType = literal;
80
+ const someInterface: SomeInterface = literal;
81
+
82
+ function fn(object: Record<string, unknown>): void {}
83
+
84
+ fn(literal); // Good: literal object type is sealed
85
+ fn(someType); // Good: type is sealed
86
+ fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
87
+ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
88
+ ```
89
+
90
+ @link https://github.com/microsoft/TypeScript/issues/15300
91
+
92
+ @category Object
93
+ */
94
+ type Simplify<
95
+ AnyType,
96
+ Options extends SimplifyOptions = {},
97
+ > = Flatten<AnyType> extends AnyType
98
+ ? Flatten<AnyType, Options>
99
+ : AnyType;
100
+
101
+ /**
102
+ Remove any index signatures from the given object type, so that only explicitly defined properties remain.
103
+
104
+ Use-cases:
105
+ - Remove overly permissive signatures from third-party types.
106
+
107
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
108
+
109
+ 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>`.
110
+
111
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
112
+
113
+ ```
114
+ const indexed: Record<string, unknown> = {}; // Allowed
115
+
116
+ const keyed: Record<'foo', unknown> = {}; // Error
117
+ // => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
118
+ ```
119
+
120
+ 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:
121
+
122
+ ```
123
+ type Indexed = {} extends Record<string, unknown>
124
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
125
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
126
+ // => '✅ `{}` is assignable to `Record<string, unknown>`'
127
+
128
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
129
+ ? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
130
+ : "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
131
+ // => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
132
+ ```
133
+
134
+ 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`...
135
+
136
+ ```
137
+ import type {RemoveIndexSignature} from 'type-fest';
138
+
139
+ type RemoveIndexSignature<ObjectType> = {
140
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
141
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `RemoveIndexSignature<Foo> == Foo`.
142
+ };
143
+ ```
144
+
145
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
146
+
147
+ ```
148
+ import type {RemoveIndexSignature} from 'type-fest';
149
+
150
+ type RemoveIndexSignature<ObjectType> = {
151
+ [KeyType in keyof ObjectType
152
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
153
+ as {} extends Record<KeyType, unknown>
154
+ ? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
155
+ : ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
156
+ ]: ObjectType[KeyType];
157
+ };
158
+ ```
159
+
160
+ 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.
161
+
162
+ ```
163
+ import type {RemoveIndexSignature} from 'type-fest';
164
+
165
+ type RemoveIndexSignature<ObjectType> = {
166
+ [KeyType in keyof ObjectType
167
+ as {} extends Record<KeyType, unknown>
168
+ ? never // => Remove this `KeyType`.
169
+ : KeyType // => Keep this `KeyType` as it is.
170
+ ]: ObjectType[KeyType];
171
+ };
172
+ ```
173
+
174
+ @example
175
+ ```
176
+ import type {RemoveIndexSignature} from 'type-fest';
177
+
178
+ interface Example {
179
+ // These index signatures will be removed.
180
+ [x: string]: any
181
+ [x: number]: any
182
+ [x: symbol]: any
183
+ [x: `head-${string}`]: string
184
+ [x: `${string}-tail`]: string
185
+ [x: `head-${string}-tail`]: string
186
+ [x: `${bigint}`]: string
187
+ [x: `embedded-${number}`]: string
188
+
189
+ // These explicitly defined keys will remain.
190
+ foo: 'bar';
191
+ qux?: 'baz';
192
+ }
193
+
194
+ type ExampleWithoutIndexSignatures = RemoveIndexSignature<Example>;
195
+ // => { foo: 'bar'; qux?: 'baz' | undefined; }
196
+ ```
197
+
198
+ @category Object
199
+ */
200
+ type RemoveIndexSignature<ObjectType> = {
201
+ [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
202
+ ? never
203
+ : KeyType]: ObjectType[KeyType];
204
+ };
205
+
206
+ /**
207
+ 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).
208
+
209
+ Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
210
+
211
+ @example
212
+ ```
213
+ import type {UnionToIntersection} from 'type-fest';
214
+
215
+ type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
216
+
217
+ type Intersection = UnionToIntersection<Union>;
218
+ //=> {the(): void; great(arg: string): void; escape: boolean};
219
+ ```
220
+
221
+ A more applicable example which could make its way into your library code follows.
222
+
223
+ @example
224
+ ```
225
+ import type {UnionToIntersection} from 'type-fest';
226
+
227
+ class CommandOne {
228
+ commands: {
229
+ a1: () => undefined,
230
+ b1: () => undefined,
231
+ }
232
+ }
233
+
234
+ class CommandTwo {
235
+ commands: {
236
+ a2: (argA: string) => undefined,
237
+ b2: (argB: string) => undefined,
238
+ }
239
+ }
240
+
241
+ const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
242
+ type Union = typeof union;
243
+ //=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
244
+
245
+ type Intersection = UnionToIntersection<Union>;
246
+ //=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
247
+ ```
248
+
249
+ @category Type
250
+ */
251
+ type UnionToIntersection<Union> = (
252
+ // `extends unknown` is always going to be the case and is used to convert the
253
+ // `Union` into a [distributive conditional
254
+ // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
255
+ Union extends unknown
256
+ // The union type is used as the only argument to a function since the union
257
+ // of function arguments is an intersection.
258
+ ? (distributedUnion: Union) => void
259
+ // This won't happen.
260
+ : never
261
+ // Infer the `Intersection` type since TypeScript represents the positional
262
+ // arguments of unions of functions as an intersection of the union.
263
+ ) extends ((mergedIntersection: infer Intersection) => void)
264
+ ? Intersection
265
+ : never;
266
+
267
+ /** Union of every registered full path (e.g. `'/' | '/admin/users' | '/$libraryId/$version'`). */
268
+ type RegisteredFullPath = keyof Register['router']['routesByPath'];
269
+ type IsAppRouteTree<TRoute> = TRoute extends Register['router']['routeTree'] ? true : false;
270
+ type IsRoute<T> = T extends AnyRoute ? true : T extends FileRoutesByPath[keyof FileRoutesByPath] ? true : false;
271
+ type ExtractAllPathsFromFileRoutes<TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] | AnyRoute> = TRoute['path'];
272
+ type StoryRoutePath<TRoute = undefined> = TRoute extends FileRoutesByPath[keyof FileRoutesByPath] ? ExtractAllPathsFromFileRoutes<TRoute> : keyof FileRoutesByPath | `/${string}`;
273
+ type StoryRouteSearch<TRoute> = IsAppRouteTree<TRoute> extends true ? Record<string, unknown> : TRoute extends FileRoutesByPath[keyof FileRoutesByPath] ? TRoute['preLoaderRoute'] extends {
274
+ types: {
275
+ allSearch: infer A;
276
+ };
277
+ } ? A : never : Record<string, unknown>;
278
+ type StoryRouteFileOptions<TRoute = undefined> = IsRoute<TRoute> extends true ? TRoute extends {
279
+ options: infer O;
280
+ } ? Pick<O, Extract<keyof O, 'loader' | 'beforeLoad' | 'validateSearch' | 'loaderDeps' | 'context' | 'params' | 'head' | 'search' | 'parseParams' | 'context'>> : Pick<RouteOptions<unknown>, 'loader' | 'beforeLoad' | 'validateSearch' | 'loaderDeps' | 'context' | 'params' | 'head' | 'search' | 'parseParams' | 'context'> : Pick<RouteOptions<unknown>, 'loader' | 'beforeLoad' | 'validateSearch' | 'loaderDeps' | 'context' | 'params' | 'head' | 'search' | 'parseParams' | 'context'>;
281
+ type CreateStoryRouteOptions<TRoute = undefined> = StoryRouteFileOptions<TRoute> & {
282
+ path?: StoryRoutePath<TRoute>;
283
+ };
284
+ type StoryRouteOptions<TRoute = undefined> = CreateStoryRouteOptions<TRoute> | (TRoute extends AnyRoute ? TRoute : AnyRoute);
285
+ /**
286
+ * Per-route override options for use inside `RouteTreeOverrides`.
287
+ * Users can override `loader`, `beforeLoad`, etc. for a specific route.
288
+ */
289
+ interface RouteOverrideOptions<TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] | undefined = undefined> {
290
+ /** Override the route's loader function. */
291
+ loader?: TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] ? TRoute['options']['loader'] | ((ctx: unknown) => Promise<unknown> | unknown) : (ctx: unknown) => Promise<unknown> | unknown;
292
+ /** Override the route's beforeLoad function. */
293
+ beforeLoad?: TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] ? TRoute['options']['beforeLoad'] | ((ctx: unknown) => Promise<void> | void) : (ctx: unknown) => Promise<void> | void;
294
+ /** Override the route's search params validation. */
295
+ validateSearch?: TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] ? TRoute['options']['validateSearch'] | ((search: unknown) => Promise<void> | void) : (search: unknown) => Promise<void> | void;
296
+ /** Override the route's loader dependencies. */
297
+ loaderDeps?: TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] ? TRoute['options']['loaderDeps'] | string[] : string[];
298
+ /** Override the route's context function. */
299
+ context?: TRoute extends FileRoutesByPath[keyof FileRoutesByPath]['preLoaderRoute'] ? TRoute['options']['context'] | ((ctx: unknown) => Promise<unknown> | unknown) : (ctx: unknown) => Promise<unknown> | unknown;
300
+ }
301
+ /**
302
+ * A map of route overrides keyed by route ID.
303
+ * Each entry can override `loader`, `beforeLoad`, etc. for that route.
304
+ *
305
+ * @example
306
+ * ```ts
307
+ * routeOverrides: {
308
+ * '/_authed': { beforeLoad: () => {} },
309
+ * '/demo/form/simple/$id': {
310
+ * loader: async () => ({ name: 'Mock User' }),
311
+ * },
312
+ * }
313
+ * ```
314
+ */
315
+ type RouteTreeOverrides = Partial<{
316
+ [routePath in keyof FileRoutesByPath]: RouteOverrideOptions<FileRoutesByPath[routePath]['preLoaderRoute']> | undefined;
317
+ }>;
318
+ interface RouterParameters<TRoute = undefined, Path extends TRoute extends AnyRoute ? keyof RoutesByPath<TRoute> : RegisteredFullPath = TRoute extends AnyRoute ? keyof RoutesByPath<TRoute> : keyof FileRoutesByPath> {
319
+ route?: StoryRouteOptions<TRoute>;
320
+ /**
321
+ * Path to resolve the story route against.
322
+ * Constrained to known registered paths in route tree mode, but can be any string in app route mode (since the user may be passing a custom `route` that doesn't exist in the registered tree).
323
+ */
324
+ path?: Path;
325
+ /** URL params to interpolate into the path (e.g. `{ id: '42' }` for `/$id`). */
326
+ params?: ResolveParams<Path>;
327
+ /** Search/query params to append to the URL (e.g. `{ tab: 'details' }`). */
328
+ query?: Partial<StoryRouteSearch<TRoute>>;
329
+ /**
330
+ * Override options for specific routes in the app route tree (route tree mode only).
331
+ *
332
+ * Each key is a route ID (e.g. `'/about'`, `'__root__'`, `'/demo/form/simple/$id'`).
333
+ * Values can override `loader`, `beforeLoad`, etc. for that route.
334
+ *
335
+ * @example
336
+ * ```ts
337
+ * routeOverrides: {
338
+ * '/_authed': { beforeLoad: () => {} },
339
+ * '/demo/form/simple/$id': {
340
+ * loader: async () => ({ name: 'Mock User' }),
341
+ * },
342
+ * }
343
+ * ```
344
+ */
345
+ routeOverrides?: RouteTreeOverrides;
346
+ context?: Record<string, unknown>;
347
+ /**
348
+ *
349
+ */
350
+ useRouterContext?: ({ storyContext }: {
351
+ storyContext: Parameters<Decorator>[1];
352
+ }) => AnyContext;
353
+ }
354
+
355
+ type FrameworkName = CompatibleString<'@storybook/tanstack-react'>;
356
+ type BuilderName = CompatibleString<'@storybook/builder-vite'>;
357
+ type FrameworkOptions = {
358
+ /** Builder options passed through to @storybook/builder-vite. */
359
+ builder?: BuilderOptions;
360
+ };
361
+ type StorybookConfigFramework = {
362
+ framework: FrameworkName | {
363
+ name: FrameworkName;
364
+ options: FrameworkOptions;
365
+ };
366
+ core?: StorybookConfig$1['core'] & {
367
+ builder?: BuilderName | {
368
+ name: BuilderName;
369
+ options: BuilderOptions;
370
+ };
371
+ };
372
+ };
373
+ /** The interface for Storybook configuration in `main.ts` files. */
374
+ type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigFramework> & StorybookConfigFramework;
375
+ /** Path constraint mirroring `RouterParameters`'s second generic. */
376
+ type DefaultStoryPath<TRoute> = TRoute extends AnyRoute ? keyof RoutesByPath<TRoute> : RegisteredFullPath;
377
+ interface TanStackPreviewOptions<TRoute = undefined, Path extends DefaultStoryPath<TRoute> = DefaultStoryPath<TRoute>> {
378
+ /** Router configuration for stories */
379
+ router?: RouterParameters<TRoute, Path>;
380
+ }
381
+ interface TanStackParameters<TRoute = undefined, Path extends DefaultStoryPath<TRoute> = DefaultStoryPath<TRoute>> {
382
+ /** TanStack framework configuration (router integration). */
383
+ tanstack?: TanStackPreviewOptions<TRoute, Path>;
384
+ }
385
+ interface TanStackTypes<TRoute = undefined, Path extends DefaultStoryPath<TRoute> = DefaultStoryPath<TRoute>> {
386
+ parameters: TanStackParameters<TRoute, Path>;
387
+ }
388
+
389
+ /** Extracts and unions all args types from an array of decorators. */
390
+ type DecoratorsArgs<TRenderer extends Renderer, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
391
+ type InferCombinedTypes<T, TArgs, Decorators> = ReactTypes & T & {
392
+ args: Simplify<TArgs & Simplify<RemoveIndexSignature<DecoratorsArgs<ReactTypes & T, Decorators>>>>;
393
+ };
394
+ type Preview<TRoute extends AnyRoute | undefined = undefined> = ProjectAnnotations<ReactTypes & TanStackTypes<TRoute>>;
395
+ declare function definePreview<TRoute extends AnyRoute | undefined = undefined, const TPath extends DefaultStoryPath<TRoute> = DefaultStoryPath<TRoute>, Addons extends PreviewAddon<never>[] = []>(preview: {
396
+ addons?: Addons;
397
+ route?: TRoute;
398
+ } & ProjectAnnotations<ReactTypes & TanStackTypes<NoInfer<TRoute>, TPath> & InferTypes<Addons>>): TanStackPreview<InferTypes<Addons>, TRoute>;
399
+ /**
400
+ * Metadata to configure stories for a component or a TanStack Route.
401
+ *
402
+ * When `TCmpOrArgs` is a TanStack Route, the `component` field accepts the
403
+ * Route object directly and TanStack parameters (params, query, loader, etc.)
404
+ * are inferred from the route's types.
405
+ */
406
+ type Meta<TCmpOrArgs = Args> = IsRoute<TCmpOrArgs> extends true ? Omit<ComponentAnnotations<ReactRenderer, Args>, 'component'> & Partial<TanStackTypes<TCmpOrArgs>> : Meta$1<TCmpOrArgs>;
407
+ /**
408
+ * When the meta's `component` is a TanStack Route, the story inherits
409
+ * TanStack parameter types for type-safe params/query/loader configuration.
410
+ */
411
+ type StoryObj<TMetaOrCmpOrArgs = unknown> = [TMetaOrCmpOrArgs] extends [
412
+ {
413
+ component?: infer Component;
414
+ }
415
+ ] ? IsRoute<Component> extends true ? StoryAnnotations<ReactRenderer, Args, Partial<Args>> & Partial<TanStackTypes<Component>> : StoryObj$1<TMetaOrCmpOrArgs> & Partial<TanStackTypes> : IsRoute<TMetaOrCmpOrArgs> extends true ? StoryAnnotations<ReactRenderer, Args, Partial<Args>> & Partial<TanStackTypes<TMetaOrCmpOrArgs>> : StoryObj$1<TMetaOrCmpOrArgs> & Partial<TanStackTypes>;
416
+ interface TanStackPreview<T extends AddonTypes, TRoute extends AnyRoute | undefined = undefined> extends ReactPreview<TanStackTypes<TRoute> & T> {
417
+ type<R>(): TanStackPreview<T & R, TRoute>;
418
+ meta<TMetaRoute extends AnyRoute, const TPath extends DefaultStoryPath<TMetaRoute> = DefaultStoryPath<TMetaRoute>, TArgs extends Args = Args, Decorators extends DecoratorFunction<ReactTypes & TanStackTypes<TMetaRoute, TPath> & T, any> = DecoratorFunction<ReactTypes & TanStackTypes<TMetaRoute, TPath> & T, any>, TMetaArgs extends Partial<TArgs & (TanStackTypes<TMetaRoute, TPath> & T)['args']> = Partial<TArgs & (TanStackTypes<TMetaRoute, TPath> & T)['args']>>(meta: {
419
+ render?: ArgsStoryFn<ReactTypes & TanStackTypes<TMetaRoute, TPath> & T, TArgs & (TanStackTypes<TMetaRoute, TPath> & T)['args']>;
420
+ component?: ComponentType<TArgs>;
421
+ decorators?: Decorators | Decorators[];
422
+ args?: TMetaArgs;
423
+ parameters?: TanStackParameters<TMetaRoute, TPath> & Parameters$1 & (ReactTypes & T)['parameters'];
424
+ } & Omit<ComponentAnnotations<ReactTypes & TanStackTypes<TMetaRoute, TPath> & T, TArgs>, 'decorators' | 'component' | 'args' | 'render' | 'parameters'>): ReactMeta<InferCombinedTypes<TanStackTypes<TMetaRoute, TPath> & T, TArgs, Decorators>, Omit<ComponentAnnotations<InferCombinedTypes<TanStackTypes<TMetaRoute, TPath> & T, TArgs, Decorators>>, 'args'> & {
425
+ args: Partial<TArgs> extends TMetaArgs ? {} : TMetaArgs;
426
+ }>;
427
+ meta<const TPath extends DefaultStoryPath<TRoute> = DefaultStoryPath<TRoute>, TArgs extends Args = Args, Decorators extends DecoratorFunction<ReactTypes & TanStackTypes<TRoute, TPath> & T, any> = DecoratorFunction<ReactTypes & TanStackTypes<TRoute, TPath> & T, any>, TMetaArgs extends Partial<TArgs & (TanStackTypes<TRoute, TPath> & T)['args']> = Partial<TArgs & (TanStackTypes<TRoute, TPath> & T)['args']>>(meta: {
428
+ render?: ArgsStoryFn<ReactTypes & TanStackTypes<TRoute, TPath> & T, TArgs & (TanStackTypes<TRoute, TPath> & T)['args']>;
429
+ component?: ComponentType<TArgs>;
430
+ decorators?: Decorators | Decorators[];
431
+ args?: TMetaArgs;
432
+ parameters?: TanStackParameters<TRoute, TPath> & Parameters$1 & (ReactTypes & T)['parameters'];
433
+ } & Omit<ComponentAnnotations<ReactTypes & TanStackTypes<TRoute, TPath> & T, TArgs>, 'decorators' | 'component' | 'args' | 'render' | 'parameters'>): ReactMeta<InferCombinedTypes<TanStackTypes<TRoute, TPath> & T, TArgs, Decorators>, Omit<ComponentAnnotations<InferCombinedTypes<TanStackTypes<TRoute, TPath> & T, TArgs, Decorators>>, 'args'> & {
434
+ args: Partial<TArgs> extends TMetaArgs ? {} : TMetaArgs;
435
+ }>;
436
+ }
437
+
438
+ export { type CreateStoryRouteOptions, type DefaultStoryPath, type FrameworkOptions, type IsRoute, type Meta, type Preview, type RouterParameters, type StoryObj, type StoryRouteFileOptions, type StoryRouteOptions, type StorybookConfig, type TanStackParameters, type TanStackPreviewOptions, type TanStackTypes, definePreview };
package/dist/index.js ADDED
@@ -0,0 +1,17 @@
1
+ import {
2
+ preview_exports
3
+ } from "./_browser-chunks/chunk-73EPJ7AY.js";
4
+ import "./_browser-chunks/chunk-4BE7D4DS.js";
5
+
6
+ // src/index.ts
7
+ import { __definePreview } from "@storybook/react";
8
+ export * from "@storybook/react";
9
+ function definePreview(preview) {
10
+ return __definePreview({
11
+ ...preview,
12
+ addons: [preview_exports, ...preview.addons ?? []]
13
+ });
14
+ }
15
+ export {
16
+ definePreview
17
+ };
@@ -0,0 +1,28 @@
1
+ import { CompatibleString } from 'storybook/internal/types';
2
+ import { BuilderOptions } from '@storybook/builder-vite';
3
+ import { StorybookConfig as StorybookConfig$1 } from '@storybook/react-vite';
4
+
5
+ type FrameworkName = CompatibleString<'@storybook/tanstack-react'>;
6
+ type BuilderName = CompatibleString<'@storybook/builder-vite'>;
7
+ type FrameworkOptions = {
8
+ /** Builder options passed through to @storybook/builder-vite. */
9
+ builder?: BuilderOptions;
10
+ };
11
+ type StorybookConfigFramework = {
12
+ framework: FrameworkName | {
13
+ name: FrameworkName;
14
+ options: FrameworkOptions;
15
+ };
16
+ core?: StorybookConfig$1['core'] & {
17
+ builder?: BuilderName | {
18
+ name: BuilderName;
19
+ options: BuilderOptions;
20
+ };
21
+ };
22
+ };
23
+ /** The interface for Storybook configuration in `main.ts` files. */
24
+ type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigFramework> & StorybookConfigFramework;
25
+
26
+ declare function defineMain(config: StorybookConfig): StorybookConfig;
27
+
28
+ export { type StorybookConfig, defineMain };
@@ -0,0 +1,19 @@
1
+ import CJS_COMPAT_NODE_URL_fmhd7e5wemi from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_fmhd7e5wemi from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_fmhd7e5wemi from "node:module";
4
+
5
+ var __filename = CJS_COMPAT_NODE_URL_fmhd7e5wemi.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_fmhd7e5wemi.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_fmhd7e5wemi.createRequire(import.meta.url);
8
+
9
+ // ------------------------------------------------------------
10
+ // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
+ // ------------------------------------------------------------
12
+
13
+ // src/node/index.ts
14
+ function defineMain(config) {
15
+ return config;
16
+ }
17
+ export {
18
+ defineMain
19
+ };
@@ -0,0 +1,8 @@
1
+ import { PresetProperty } from 'storybook/internal/types';
2
+ import { StorybookConfigVite } from '@storybook/builder-vite';
3
+
4
+ declare const core: PresetProperty<'core'>;
5
+ declare const previewAnnotations: PresetProperty<'previewAnnotations'>;
6
+ declare const viteFinal: StorybookConfigVite['viteFinal'];
7
+
8
+ export { core, previewAnnotations, viteFinal };