@storybook/angular 10.2.0-alpha.9 → 10.2.0-beta.1

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.
@@ -1,38 +1,8 @@
1
1
  import {
2
- computesTemplateSourceFromComponent
3
- } from "../../_browser-chunks/chunk-6CHBWP5J.js";
4
-
5
- // src/client/docs/config.ts
6
- import { SourceType as SourceType2 } from "storybook/internal/docs-tools";
7
-
8
- // src/client/docs/sourceDecorator.ts
9
- import { SourceType } from "storybook/internal/docs-tools";
10
- import { useRef, emitTransformCode, useEffect } from "storybook/preview-api";
11
- var skipSourceRender = (context) => {
12
- let sourceParams = context?.parameters.docs?.source;
13
- return sourceParams?.type === SourceType.DYNAMIC ? !1 : sourceParams?.code || sourceParams?.type === SourceType.CODE;
14
- }, sourceDecorator = (storyFn, context) => {
15
- let story = storyFn(), source = useRef(void 0);
16
- return useEffect(() => {
17
- if (skipSourceRender(context))
18
- return;
19
- let { props, userDefinedTemplate } = story, { component, argTypes, parameters: parameters2 } = context, template = parameters2.docs?.source?.excludeDecorators ? context.originalStoryFn(context.args, context).template : story.template;
20
- if (component && !userDefinedTemplate) {
21
- let newSource = computesTemplateSourceFromComponent(component, props, argTypes) || template;
22
- newSource && newSource !== source.current && (emitTransformCode(newSource, context), source.current = newSource);
23
- } else template && template !== source.current && (emitTransformCode(template, context), source.current = template);
24
- }), story;
25
- };
26
-
27
- // src/client/docs/config.ts
28
- var parameters = {
29
- docs: {
30
- source: {
31
- type: SourceType2.DYNAMIC,
32
- language: "html"
33
- }
34
- }
35
- }, decorators = [sourceDecorator];
2
+ decorators,
3
+ parameters
4
+ } from "../../_browser-chunks/chunk-CT6JF2ND.js";
5
+ import "../../_browser-chunks/chunk-34GOABUT.js";
36
6
  export {
37
7
  decorators,
38
8
  parameters
@@ -1,13 +1,16 @@
1
1
  import {
2
+ __definePreview,
2
3
  applicationConfig,
3
4
  argsToTemplate,
4
5
  componentWrapperDecorator,
5
6
  moduleMetadata,
6
7
  setProjectAnnotations
7
- } from "../_browser-chunks/chunk-T32Z4CGF.js";
8
- import "../_browser-chunks/chunk-DAHG2CDK.js";
9
- import "../_browser-chunks/chunk-6CHBWP5J.js";
8
+ } from "../_browser-chunks/chunk-XYAB765U.js";
9
+ import "../_browser-chunks/chunk-XA6C6Y3S.js";
10
+ import "../_browser-chunks/chunk-CT6JF2ND.js";
11
+ import "../_browser-chunks/chunk-34GOABUT.js";
10
12
  export {
13
+ __definePreview,
11
14
  applicationConfig,
12
15
  argsToTemplate,
13
16
  componentWrapperDecorator,
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { WebRenderer, Parameters as Parameters$1, Args, ComponentAnnotations, AnnotatedStoryFn, StoryAnnotations, StrictArgs, DecoratorFunction, LoaderFunction, StoryContext as StoryContext$1, ProjectAnnotations, NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, StorybookConfig as StorybookConfig$2, Options, CompatibleString, TypescriptOptions as TypescriptOptions$1 } from 'storybook/internal/types';
1
+ import { WebRenderer, Parameters as Parameters$1, Args, ComponentAnnotations, AnnotatedStoryFn, StoryAnnotations, StrictArgs, DecoratorFunction, LoaderFunction, StoryContext as StoryContext$1, ProjectAnnotations, NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, Renderer, ArgsStoryFn, StorybookConfig as StorybookConfig$2, Options, CompatibleString, TypescriptOptions as TypescriptOptions$1 } from 'storybook/internal/types';
2
2
  export { ArgTypes, Args, Parameters, StrictArgs } from 'storybook/internal/types';
3
3
  import * as AngularCore from '@angular/core';
4
4
  import { Provider, ApplicationConfig, Type } from '@angular/core';
5
+ import { PreviewAddon, InferTypes, AddonTypes, Preview as Preview$1, Meta as Meta$1, Story } from 'storybook/internal/csf';
5
6
  import { BuilderOptions, StorybookConfigWebpack, TypescriptOptions } from '@storybook/builder-webpack5';
6
7
 
7
8
  interface NgModuleMetadata {
@@ -109,6 +110,519 @@ type TransformEventType<T> = {
109
110
  */
110
111
  declare function setProjectAnnotations(projectAnnotations: NamedOrDefaultProjectAnnotations<any> | NamedOrDefaultProjectAnnotations<any>[]): NormalizedProjectAnnotations<AngularRenderer>;
111
112
 
113
+ declare global {
114
+ interface SymbolConstructor {
115
+ readonly observable: symbol;
116
+ }
117
+ }
118
+
119
+ /**
120
+ Returns a boolean for whether the two given types are equal.
121
+
122
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
123
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
124
+ */
125
+ type IsEqual<T, U> =
126
+ (<G>() => G extends T ? 1 : 2) extends
127
+ (<G>() => G extends U ? 1 : 2)
128
+ ? true
129
+ : false;
130
+
131
+ /**
132
+ Filter out keys from an object.
133
+
134
+ Returns `never` if `Exclude` is strictly equal to `Key`.
135
+ Returns `never` if `Key` extends `Exclude`.
136
+ Returns `Key` otherwise.
137
+
138
+ @example
139
+ ```
140
+ type Filtered = Filter<'foo', 'foo'>;
141
+ //=> never
142
+ ```
143
+
144
+ @example
145
+ ```
146
+ type Filtered = Filter<'bar', string>;
147
+ //=> never
148
+ ```
149
+
150
+ @example
151
+ ```
152
+ type Filtered = Filter<'bar', 'foo'>;
153
+ //=> 'bar'
154
+ ```
155
+
156
+ @see {Except}
157
+ */
158
+ type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
159
+
160
+ /**
161
+ Create a type from an object type without certain keys.
162
+
163
+ 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.
164
+
165
+ 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)).
166
+
167
+ @example
168
+ ```
169
+ import type {Except} from 'type-fest';
170
+
171
+ type Foo = {
172
+ a: number;
173
+ b: string;
174
+ c: boolean;
175
+ };
176
+
177
+ type FooWithoutA = Except<Foo, 'a' | 'c'>;
178
+ //=> {b: string};
179
+ ```
180
+
181
+ @category Object
182
+ */
183
+ type Except<ObjectType, KeysType extends keyof ObjectType> = {
184
+ [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
185
+ };
186
+
187
+ /**
188
+ @see Simplify
189
+ */
190
+ interface SimplifyOptions {
191
+ /**
192
+ Do the simplification recursively.
193
+
194
+ @default false
195
+ */
196
+ deep?: boolean;
197
+ }
198
+
199
+ // Flatten a type without worrying about the result.
200
+ type Flatten<
201
+ AnyType,
202
+ Options extends SimplifyOptions = {},
203
+ > = Options['deep'] extends true
204
+ ? {[KeyType in keyof AnyType]: Simplify<AnyType[KeyType], Options>}
205
+ : {[KeyType in keyof AnyType]: AnyType[KeyType]};
206
+
207
+ /**
208
+ 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.
209
+
210
+ @example
211
+ ```
212
+ import type {Simplify} from 'type-fest';
213
+
214
+ type PositionProps = {
215
+ top: number;
216
+ left: number;
217
+ };
218
+
219
+ type SizeProps = {
220
+ width: number;
221
+ height: number;
222
+ };
223
+
224
+ // In your editor, hovering over `Props` will show a flattened object with all the properties.
225
+ type Props = Simplify<PositionProps & SizeProps>;
226
+ ```
227
+
228
+ 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.
229
+
230
+ 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`.
231
+
232
+ @example
233
+ ```
234
+ import type {Simplify} from 'type-fest';
235
+
236
+ interface SomeInterface {
237
+ foo: number;
238
+ bar?: string;
239
+ baz: number | undefined;
240
+ }
241
+
242
+ type SomeType = {
243
+ foo: number;
244
+ bar?: string;
245
+ baz: number | undefined;
246
+ };
247
+
248
+ const literal = {foo: 123, bar: 'hello', baz: 456};
249
+ const someType: SomeType = literal;
250
+ const someInterface: SomeInterface = literal;
251
+
252
+ function fn(object: Record<string, unknown>): void {}
253
+
254
+ fn(literal); // Good: literal object type is sealed
255
+ fn(someType); // Good: type is sealed
256
+ fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
257
+ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
258
+ ```
259
+
260
+ @link https://github.com/microsoft/TypeScript/issues/15300
261
+
262
+ @category Object
263
+ */
264
+ type Simplify<
265
+ AnyType,
266
+ Options extends SimplifyOptions = {},
267
+ > = Flatten<AnyType> extends AnyType
268
+ ? Flatten<AnyType, Options>
269
+ : AnyType;
270
+
271
+ /**
272
+ Remove any index signatures from the given object type, so that only explicitly defined properties remain.
273
+
274
+ Use-cases:
275
+ - Remove overly permissive signatures from third-party types.
276
+
277
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
278
+
279
+ 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>`.
280
+
281
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
282
+
283
+ ```
284
+ const indexed: Record<string, unknown> = {}; // Allowed
285
+
286
+ const keyed: Record<'foo', unknown> = {}; // Error
287
+ // => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
288
+ ```
289
+
290
+ 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:
291
+
292
+ ```
293
+ type Indexed = {} extends Record<string, unknown>
294
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
295
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
296
+ // => '✅ `{}` is assignable to `Record<string, unknown>`'
297
+
298
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
299
+ ? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
300
+ : "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
301
+ // => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
302
+ ```
303
+
304
+ 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`...
305
+
306
+ ```
307
+ import type {RemoveIndexSignature} from 'type-fest';
308
+
309
+ type RemoveIndexSignature<ObjectType> = {
310
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
311
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `RemoveIndexSignature<Foo> == Foo`.
312
+ };
313
+ ```
314
+
315
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
316
+
317
+ ```
318
+ import type {RemoveIndexSignature} from 'type-fest';
319
+
320
+ type RemoveIndexSignature<ObjectType> = {
321
+ [KeyType in keyof ObjectType
322
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
323
+ as {} extends Record<KeyType, unknown>
324
+ ? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
325
+ : ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
326
+ ]: ObjectType[KeyType];
327
+ };
328
+ ```
329
+
330
+ 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.
331
+
332
+ ```
333
+ import type {RemoveIndexSignature} from 'type-fest';
334
+
335
+ type RemoveIndexSignature<ObjectType> = {
336
+ [KeyType in keyof ObjectType
337
+ as {} extends Record<KeyType, unknown>
338
+ ? never // => Remove this `KeyType`.
339
+ : KeyType // => Keep this `KeyType` as it is.
340
+ ]: ObjectType[KeyType];
341
+ };
342
+ ```
343
+
344
+ @example
345
+ ```
346
+ import type {RemoveIndexSignature} from 'type-fest';
347
+
348
+ interface Example {
349
+ // These index signatures will be removed.
350
+ [x: string]: any
351
+ [x: number]: any
352
+ [x: symbol]: any
353
+ [x: `head-${string}`]: string
354
+ [x: `${string}-tail`]: string
355
+ [x: `head-${string}-tail`]: string
356
+ [x: `${bigint}`]: string
357
+ [x: `embedded-${number}`]: string
358
+
359
+ // These explicitly defined keys will remain.
360
+ foo: 'bar';
361
+ qux?: 'baz';
362
+ }
363
+
364
+ type ExampleWithoutIndexSignatures = RemoveIndexSignature<Example>;
365
+ // => { foo: 'bar'; qux?: 'baz' | undefined; }
366
+ ```
367
+
368
+ @category Object
369
+ */
370
+ type RemoveIndexSignature<ObjectType> = {
371
+ [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
372
+ ? never
373
+ : KeyType]: ObjectType[KeyType];
374
+ };
375
+
376
+ /**
377
+ Create a type that makes the given keys optional. The remaining keys are kept as is. The sister of the `SetRequired` type.
378
+
379
+ 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.
380
+
381
+ @example
382
+ ```
383
+ import type {SetOptional} from 'type-fest';
384
+
385
+ type Foo = {
386
+ a: number;
387
+ b?: string;
388
+ c: boolean;
389
+ }
390
+
391
+ type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
392
+ // type SomeOptional = {
393
+ // a: number;
394
+ // b?: string; // Was already optional and still is.
395
+ // c?: boolean; // Is now optional.
396
+ // }
397
+ ```
398
+
399
+ @category Object
400
+ */
401
+ type SetOptional<BaseType, Keys extends keyof BaseType> =
402
+ Simplify<
403
+ // Pick just the keys that are readonly from the base type.
404
+ Except<BaseType, Keys> &
405
+ // Pick the keys that should be mutable from the base type and make them mutable.
406
+ Partial<Pick<BaseType, Keys>>
407
+ >;
408
+
409
+ /**
410
+ 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).
411
+
412
+ Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
413
+
414
+ @example
415
+ ```
416
+ import type {UnionToIntersection} from 'type-fest';
417
+
418
+ type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
419
+
420
+ type Intersection = UnionToIntersection<Union>;
421
+ //=> {the(): void; great(arg: string): void; escape: boolean};
422
+ ```
423
+
424
+ A more applicable example which could make its way into your library code follows.
425
+
426
+ @example
427
+ ```
428
+ import type {UnionToIntersection} from 'type-fest';
429
+
430
+ class CommandOne {
431
+ commands: {
432
+ a1: () => undefined,
433
+ b1: () => undefined,
434
+ }
435
+ }
436
+
437
+ class CommandTwo {
438
+ commands: {
439
+ a2: (argA: string) => undefined,
440
+ b2: (argB: string) => undefined,
441
+ }
442
+ }
443
+
444
+ const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
445
+ type Union = typeof union;
446
+ //=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
447
+
448
+ type Intersection = UnionToIntersection<Union>;
449
+ //=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
450
+ ```
451
+
452
+ @category Type
453
+ */
454
+ type UnionToIntersection<Union> = (
455
+ // `extends unknown` is always going to be the case and is used to convert the
456
+ // `Union` into a [distributive conditional
457
+ // type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
458
+ Union extends unknown
459
+ // The union type is used as the only argument to a function since the union
460
+ // of function arguments is an intersection.
461
+ ? (distributedUnion: Union) => void
462
+ // This won't happen.
463
+ : never
464
+ // Infer the `Intersection` type since TypeScript represents the positional
465
+ // arguments of unions of functions as an intersection of the union.
466
+ ) extends ((mergedIntersection: infer Intersection) => void)
467
+ ? Intersection
468
+ : never;
469
+
470
+ /**
471
+ * Creates an Angular-specific preview configuration with CSF factories support.
472
+ *
473
+ * This function wraps the base `definePreview` and adds Angular-specific annotations for rendering
474
+ * and documentation. It returns an `AngularPreview` that provides type-safe `meta()` and `story()`
475
+ * factory methods.
476
+ *
477
+ * @example
478
+ *
479
+ * ```ts
480
+ * // .storybook/preview.ts
481
+ * import { definePreview } from '@storybook/angular';
482
+ *
483
+ * export const preview = definePreview({
484
+ * addons: [],
485
+ * parameters: { layout: 'centered' },
486
+ * });
487
+ * ```
488
+ */
489
+ declare function __definePreview<Addons extends PreviewAddon<never>[]>(input: {
490
+ addons: Addons;
491
+ } & ProjectAnnotations<AngularRenderer & InferTypes<Addons>>): AngularPreview<AngularRenderer & InferTypes<Addons>>;
492
+ type InferArgs<TArgs, T, Decorators> = Simplify<TArgs & Simplify<RemoveIndexSignature<DecoratorsArgs<AngularRenderer & T, Decorators>>>>;
493
+ type InferComponentArgs<C extends abstract new (...args: any) => any> = Partial<TransformComponentType<InstanceType<C>>>;
494
+ type InferAngularTypes<T, TArgs, Decorators> = AngularRenderer & T & {
495
+ args: Simplify<InferArgs<TArgs, T, Decorators>>;
496
+ };
497
+ /**
498
+ * Angular-specific Preview interface that provides type-safe CSF factory methods.
499
+ *
500
+ * Use `preview.meta()` to create a meta configuration for a component, and then `meta.story()` to
501
+ * create individual stories. The type system will infer args from the component, decorators, and
502
+ * any addon types.
503
+ *
504
+ * @example
505
+ *
506
+ * ```ts
507
+ * const meta = preview.meta({ component: ButtonComponent });
508
+ * export const Primary = meta.story({ args: { label: 'Click me' } });
509
+ * ```
510
+ */
511
+ interface AngularPreview<T extends AddonTypes> extends Preview$1<AngularRenderer & T> {
512
+ /**
513
+ * Narrows the type of the preview to include additional type information. This is useful when you
514
+ * need to add args that aren't inferred from the component.
515
+ *
516
+ * @example
517
+ *
518
+ * ```ts
519
+ * const meta = preview.type<{ args: { theme: 'light' | 'dark' } }>().meta({
520
+ * component: ButtonComponent,
521
+ * });
522
+ * ```
523
+ */
524
+ type<S>(): AngularPreview<T & S>;
525
+ meta<C extends abstract new (...args: any) => any, Decorators extends DecoratorFunction<AngularRenderer & T, any>, TMetaArgs extends Partial<InferComponentArgs<C> & T['args']>>(meta: {
526
+ component?: C;
527
+ args?: TMetaArgs;
528
+ decorators?: Decorators | Decorators[];
529
+ } & Omit<ComponentAnnotations<AngularRenderer & T, InferComponentArgs<C> & T['args']>, 'decorators' | 'component' | 'args'>): AngularMeta<InferAngularTypes<T, InferComponentArgs<C>, Decorators>, Omit<ComponentAnnotations<InferAngularTypes<T, InferComponentArgs<C>, Decorators>>, 'args'> & {
530
+ args: {} extends TMetaArgs ? {} : TMetaArgs;
531
+ }>;
532
+ meta<TArgs, Decorators extends DecoratorFunction<AngularRenderer & T, any>, TMetaArgs extends Partial<TArgs & T['args']>>(meta: {
533
+ render?: ArgsStoryFn<AngularRenderer & T, TArgs & T['args']>;
534
+ args?: TMetaArgs;
535
+ decorators?: Decorators | Decorators[];
536
+ } & Omit<ComponentAnnotations<AngularRenderer & T, TArgs & T['args']>, 'decorators' | 'args' | 'render' | 'component'>): AngularMeta<InferAngularTypes<T, TArgs, Decorators>, Omit<ComponentAnnotations<InferAngularTypes<T, TArgs, Decorators>>, 'args'> & {
537
+ args: {} extends TMetaArgs ? {} : TMetaArgs;
538
+ }>;
539
+ }
540
+ /** Extracts and unions all args types from an array of decorators. */
541
+ type DecoratorsArgs<TRenderer extends Renderer, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
542
+ /**
543
+ * Angular-specific Meta interface returned by `preview.meta()`.
544
+ *
545
+ * Provides the `story()` method to create individual stories with proper type inference. Args
546
+ * provided in meta become optional in stories, while missing required args must be provided at the
547
+ * story level.
548
+ */
549
+ interface AngularMeta<T extends AngularRenderer, MetaInput extends ComponentAnnotations<T>> extends Meta$1<T, MetaInput> {
550
+ /**
551
+ * Creates a story with a custom render function that takes no args.
552
+ *
553
+ * This overload allows you to define a story using just a render function or an object with a
554
+ * render function that doesn't depend on args. Since the render function doesn't use args, no
555
+ * args need to be provided regardless of what's required by the component.
556
+ *
557
+ * @example
558
+ *
559
+ * ```ts
560
+ * // Using just a render function
561
+ * export const CustomTemplate = meta.story(() => ({
562
+ * template: '<div>Custom static content</div>',
563
+ * }));
564
+ *
565
+ * // Using an object with render
566
+ * export const WithRender = meta.story({
567
+ * render: () => ({ template: '<my-component></my-component>' }),
568
+ * });
569
+ * ```
570
+ */
571
+ story<TInput extends (() => AngularRenderer['storyResult']) | (StoryAnnotations<T, T['args']> & {
572
+ render: () => AngularRenderer['storyResult'];
573
+ })>(story: TInput): AngularStory<T, TInput extends () => AngularRenderer['storyResult'] ? {
574
+ render: TInput;
575
+ } : TInput>;
576
+ /**
577
+ * Creates a story with custom configuration including args, decorators, or other annotations.
578
+ *
579
+ * This is the primary overload for defining stories. Args that were already provided in meta
580
+ * become optional, while any remaining required args must be specified here.
581
+ *
582
+ * @example
583
+ *
584
+ * ```ts
585
+ * // Provide required args not in meta
586
+ * export const Primary = meta.story({
587
+ * args: { label: 'Click me', disabled: false },
588
+ * });
589
+ *
590
+ * // Override meta args and add story-specific configuration
591
+ * export const Disabled = meta.story({
592
+ * args: { disabled: true },
593
+ * decorators: [withCustomWrapper],
594
+ * });
595
+ * ```
596
+ */
597
+ story<TInput extends Simplify<StoryAnnotations<T, T['args'], SetOptional<T['args'], keyof T['args'] & keyof MetaInput['args']>>>>(story: TInput): AngularStory<T, TInput>;
598
+ /**
599
+ * Creates a story with no additional configuration.
600
+ *
601
+ * This overload is only available when all required args have been provided in meta. The
602
+ * conditional type `Partial<T['args']> extends SetOptional<...>` checks if the remaining required
603
+ * args (after accounting for args provided in meta) are all optional. If so, the function accepts
604
+ * zero arguments `[]`. Otherwise, it requires `[never]` which makes this overload unmatchable,
605
+ * forcing the user to provide args.
606
+ *
607
+ * @example
608
+ *
609
+ * ```ts
610
+ * // When meta provides all required args, story() can be called with no arguments
611
+ * const meta = preview.meta({ component: Button, args: { label: 'Hi', disabled: false } });
612
+ * export const Default = meta.story(); // Valid - all args provided in meta
613
+ * ```
614
+ */
615
+ story(..._args: Partial<T['args']> extends SetOptional<T['args'], keyof T['args'] & keyof MetaInput['args']> ? [] : [never]): AngularStory<T, {}>;
616
+ }
617
+ /**
618
+ * Angular-specific Story interface returned by `meta.story()`.
619
+ *
620
+ * Represents a single story with its configuration and provides access to the composed story for
621
+ * testing via `story.run()`.
622
+ */
623
+ interface AngularStory<T extends AngularRenderer, TInput extends StoryAnnotations<T, T['args']>> extends Story<T, TInput> {
624
+ }
625
+
112
626
  declare const moduleMetadata: <TArgs = any>(metadata: Partial<NgModuleMetadata>) => DecoratorFunction<AngularRenderer, TArgs>;
113
627
  /**
114
628
  * Decorator to set the config options which are available during the application bootstrap
@@ -226,4 +740,4 @@ interface AngularOptions {
226
740
  enableIvy?: boolean;
227
741
  }
228
742
 
229
- export { type AngularOptions, type Parameters as AngularParameters, type AngularRenderer, type Decorator, type FrameworkOptions, type StoryFnAngularReturnType as IStory, type Loader, type Meta, type Preview, type StoryContext, type StoryFn, type StoryObj, type StorybookConfig, applicationConfig, argsToTemplate, componentWrapperDecorator, moduleMetadata, setProjectAnnotations };
743
+ export { type AngularMeta, type AngularOptions, type Parameters as AngularParameters, type AngularPreview, type AngularRenderer, type AngularStory, type Decorator, type FrameworkOptions, type StoryFnAngularReturnType as IStory, type Loader, type Meta, type Preview, type StoryContext, type StoryFn, type StoryObj, type StorybookConfig, type TransformComponentType, __definePreview, applicationConfig, argsToTemplate, componentWrapperDecorator, __definePreview as definePreview, moduleMetadata, setProjectAnnotations };
package/dist/index.js CHANGED
@@ -1,16 +1,20 @@
1
1
  import {
2
+ __definePreview,
2
3
  applicationConfig,
3
4
  argsToTemplate,
4
5
  componentWrapperDecorator,
5
6
  moduleMetadata,
6
7
  setProjectAnnotations
7
- } from "./_browser-chunks/chunk-T32Z4CGF.js";
8
- import "./_browser-chunks/chunk-DAHG2CDK.js";
9
- import "./_browser-chunks/chunk-6CHBWP5J.js";
8
+ } from "./_browser-chunks/chunk-XYAB765U.js";
9
+ import "./_browser-chunks/chunk-XA6C6Y3S.js";
10
+ import "./_browser-chunks/chunk-CT6JF2ND.js";
11
+ import "./_browser-chunks/chunk-34GOABUT.js";
10
12
  export {
13
+ __definePreview,
11
14
  applicationConfig,
12
15
  argsToTemplate,
13
16
  componentWrapperDecorator,
17
+ __definePreview as definePreview,
14
18
  moduleMetadata,
15
19
  setProjectAnnotations
16
20
  };
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_fsfr5ylks9c from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_fsfr5ylks9c from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_fsfr5ylks9c from "node:module";
1
+ import CJS_COMPAT_NODE_URL_uphhvkl4339 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_uphhvkl4339 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_uphhvkl4339 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_fsfr5ylks9c.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_fsfr5ylks9c.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_fsfr5ylks9c.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_uphhvkl4339.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_uphhvkl4339.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_uphhvkl4339.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
package/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_fsfr5ylks9c from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_fsfr5ylks9c from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_fsfr5ylks9c from "node:module";
1
+ import CJS_COMPAT_NODE_URL_uphhvkl4339 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_uphhvkl4339 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_uphhvkl4339 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_fsfr5ylks9c.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_fsfr5ylks9c.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_fsfr5ylks9c.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_uphhvkl4339.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_uphhvkl4339.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_uphhvkl4339.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration