@storybook/angular 7.0.0-beta.3 → 7.0.0-beta.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/README.md +66 -0
  2. package/dist/builders/build-storybook/index.d.ts +5 -3
  3. package/dist/builders/build-storybook/index.js +7 -3
  4. package/dist/builders/build-storybook/schema.json +3 -3
  5. package/dist/builders/start-storybook/index.d.ts +5 -3
  6. package/dist/builders/start-storybook/index.js +9 -5
  7. package/dist/builders/start-storybook/schema.json +2 -2
  8. package/dist/builders/utils/run-compodoc.js +11 -27
  9. package/dist/builders/utils/run-compodoc.spec.js +42 -0
  10. package/dist/builders/utils/standalone-options.d.ts +2 -2
  11. package/dist/client/angular-beta/AbstractRenderer.d.ts +1 -1
  12. package/dist/client/angular-beta/AbstractRenderer.js +17 -26
  13. package/dist/client/angular-beta/CanvasRenderer.js +1 -1
  14. package/dist/client/angular-beta/DocsRenderer.js +5 -3
  15. package/dist/client/angular-beta/RendererFactory.js +1 -1
  16. package/dist/client/angular-beta/StorybookModule.d.ts +3 -6
  17. package/dist/client/angular-beta/StorybookModule.js +4 -45
  18. package/dist/client/angular-beta/StorybookModule.test.js +51 -36
  19. package/dist/client/angular-beta/StorybookWrapperComponent.d.ts +3 -2
  20. package/dist/client/angular-beta/StorybookWrapperComponent.js +47 -2
  21. package/dist/client/angular-beta/utils/NgComponentAnalyzer.js +1 -1
  22. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.js +43 -5
  23. package/dist/client/decorateStory.js +1 -1
  24. package/dist/client/docs/compodoc.js +5 -7
  25. package/dist/client/docs/config.js +1 -2
  26. package/dist/client/globals.js +2 -6
  27. package/dist/client/render.d.ts +1 -0
  28. package/dist/client/render.js +1 -5
  29. package/dist/client/types.d.ts +0 -2
  30. package/dist/index.mjs +13 -0
  31. package/dist/preset.mjs +26 -0
  32. package/dist/renderer.d.ts +2 -1
  33. package/dist/renderer.js +4 -2
  34. package/dist/renderer.mjs +5 -0
  35. package/dist/server/framework-preset-angular-cli.d.ts +2 -1
  36. package/dist/server/framework-preset-angular-cli.js +21 -92
  37. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.js +15 -13
  38. package/dist/server/preset-options.d.ts +3 -2
  39. package/dist/types.mjs +1 -0
  40. package/package.json +45 -44
  41. package/template/cli/Button.stories.ts +1 -1
  42. package/template/cli/Header.stories.ts +2 -2
  43. package/template/cli/button.component.ts +2 -0
  44. package/template/components/index.js +2 -2
  45. package/template/stories/angular-mdx.stories.mdx +1 -1
  46. package/template/stories/basics/component-without-selector/without-selector-ng-component-outlet.stories.ts +1 -1
  47. package/template/stories/basics/component-without-selector/without-selector-ng-factory-resolver.stories.ts +1 -1
  48. package/template/stories/basics/component-without-selector/without-selector.stories.ts +1 -1
  49. package/template/stories/basics/ng-module/import-module-chip.stories.ts +23 -0
  50. package/template/stories/basics/ng-module/import-module.stories.ts +2 -13
  51. package/template/stories/core/decorators/componentWrapperDecorator/decorators.stories.ts +0 -18
  52. package/template/stories/core/parameters/bootstrap-options.stories.ts +1 -5
  53. package/dist/client/angular/helpers.d.ts +0 -8
  54. package/dist/client/angular/helpers.js +0 -150
  55. package/dist/server/angular-read-workspace.d.ts +0 -13
  56. package/dist/server/angular-read-workspace.js +0 -78
  57. package/dist/server/utils/normalize-asset-patterns.d.ts +0 -7
  58. package/dist/server/utils/normalize-asset-patterns.js +0 -64
  59. package/dist/server/utils/normalize-optimization.d.ts +0 -3
  60. package/dist/server/utils/normalize-optimization.js +0 -21
@@ -11,9 +11,9 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const core_1 = require("@angular/core");
13
13
  const testing_1 = require("@angular/core/testing");
14
- const platform_browser_1 = require("@angular/platform-browser");
15
14
  const rxjs_1 = require("rxjs");
16
15
  const StorybookModule_1 = require("./StorybookModule");
16
+ const StorybookProvider_1 = require("./StorybookProvider");
17
17
  describe('StorybookModule', () => {
18
18
  describe('getStorybookModuleMetadata', () => {
19
19
  describe('with simple component', () => {
@@ -70,12 +70,15 @@ describe('StorybookModule', () => {
70
70
  localProperty: 'localProperty',
71
71
  localFunction: () => 'localFunction',
72
72
  };
73
- const ngModule = (0, StorybookModule_1.getStorybookModuleMetadata)({
73
+ const application = (0, StorybookModule_1.getApplication)({
74
74
  storyFnAngular: { props },
75
75
  component: FooComponent,
76
76
  targetSelector: 'my-selector',
77
- }, new rxjs_1.BehaviorSubject(props));
78
- const { fixture } = await configureTestingModule(ngModule);
77
+ });
78
+ const { fixture } = await configureTestingModule({
79
+ imports: [application],
80
+ providers: [(0, StorybookProvider_1.storyPropsProvider)(new rxjs_1.BehaviorSubject(props))],
81
+ });
79
82
  fixture.detectChanges();
80
83
  expect(fixture.nativeElement.querySelector('p#input').innerHTML).toEqual(props.input);
81
84
  expect(fixture.nativeElement.querySelector('p#inputBindingPropertyName').innerHTML).toEqual(props.inputBindingPropertyName);
@@ -93,12 +96,15 @@ describe('StorybookModule', () => {
93
96
  expectedOutputBindingValue = value;
94
97
  },
95
98
  };
96
- const ngModule = (0, StorybookModule_1.getStorybookModuleMetadata)({
99
+ const application = (0, StorybookModule_1.getApplication)({
97
100
  storyFnAngular: { props },
98
101
  component: FooComponent,
99
102
  targetSelector: 'my-selector',
100
- }, new rxjs_1.BehaviorSubject(props));
101
- const { fixture } = await configureTestingModule(ngModule);
103
+ });
104
+ const { fixture } = await configureTestingModule({
105
+ imports: [application],
106
+ providers: [(0, StorybookProvider_1.storyPropsProvider)(new rxjs_1.BehaviorSubject(props))],
107
+ });
102
108
  fixture.detectChanges();
103
109
  fixture.nativeElement.querySelector('p#output').click();
104
110
  fixture.nativeElement.querySelector('p#outputBindingPropertyName').click();
@@ -111,12 +117,15 @@ describe('StorybookModule', () => {
111
117
  inputBindingPropertyName: '',
112
118
  };
113
119
  const storyProps$ = new rxjs_1.BehaviorSubject(initialProps);
114
- const ngModule = (0, StorybookModule_1.getStorybookModuleMetadata)({
120
+ const application = (0, StorybookModule_1.getApplication)({
115
121
  storyFnAngular: { props: initialProps },
116
122
  component: FooComponent,
117
123
  targetSelector: 'my-selector',
118
- }, storyProps$);
119
- const { fixture } = await configureTestingModule(ngModule);
124
+ });
125
+ const { fixture } = await configureTestingModule({
126
+ imports: [application],
127
+ providers: [(0, StorybookProvider_1.storyPropsProvider)(storyProps$)],
128
+ });
120
129
  fixture.detectChanges();
121
130
  expect(fixture.nativeElement.querySelector('p#input').innerHTML).toEqual(initialProps.input);
122
131
  expect(fixture.nativeElement.querySelector('p#inputBindingPropertyName').innerHTML).toEqual('');
@@ -146,12 +155,15 @@ describe('StorybookModule', () => {
146
155
  },
147
156
  };
148
157
  const storyProps$ = new rxjs_1.BehaviorSubject(initialProps);
149
- const ngModule = (0, StorybookModule_1.getStorybookModuleMetadata)({
158
+ const application = (0, StorybookModule_1.getApplication)({
150
159
  storyFnAngular: { props: initialProps },
151
160
  component: FooComponent,
152
161
  targetSelector: 'my-selector',
153
- }, storyProps$);
154
- const { fixture } = await configureTestingModule(ngModule);
162
+ });
163
+ const { fixture } = await configureTestingModule({
164
+ imports: [application],
165
+ providers: [(0, StorybookProvider_1.storyPropsProvider)(storyProps$)],
166
+ });
155
167
  fixture.detectChanges();
156
168
  const newProps = {
157
169
  input: 'new input',
@@ -176,15 +188,18 @@ describe('StorybookModule', () => {
176
188
  input: 'input',
177
189
  };
178
190
  const storyProps$ = new rxjs_1.BehaviorSubject(initialProps);
179
- const ngModule = (0, StorybookModule_1.getStorybookModuleMetadata)({
191
+ const application = (0, StorybookModule_1.getApplication)({
180
192
  storyFnAngular: {
181
193
  props: initialProps,
182
194
  template: '<p [style.color]="color"><foo [input]="input"></foo></p>',
183
195
  },
184
196
  component: FooComponent,
185
197
  targetSelector: 'my-selector',
186
- }, storyProps$);
187
- const { fixture } = await configureTestingModule(ngModule);
198
+ });
199
+ const { fixture } = await configureTestingModule({
200
+ imports: [application],
201
+ providers: [(0, StorybookProvider_1.storyPropsProvider)(storyProps$)],
202
+ });
188
203
  fixture.detectChanges();
189
204
  expect(fixture.nativeElement.querySelector('p').style.color).toEqual('red');
190
205
  expect(fixture.nativeElement.querySelector('p#input').innerHTML).toEqual(initialProps.input);
@@ -202,12 +217,15 @@ describe('StorybookModule', () => {
202
217
  setter: 'init',
203
218
  };
204
219
  const storyProps$ = new rxjs_1.BehaviorSubject(initialProps);
205
- const ngModule = (0, StorybookModule_1.getStorybookModuleMetadata)({
220
+ const application = (0, StorybookModule_1.getApplication)({
206
221
  storyFnAngular: { props: initialProps },
207
222
  component: FooComponent,
208
223
  targetSelector: 'my-selector',
209
- }, storyProps$);
210
- const { fixture } = await configureTestingModule(ngModule);
224
+ });
225
+ const { fixture } = await configureTestingModule({
226
+ imports: [application],
227
+ providers: [(0, StorybookProvider_1.storyPropsProvider)(storyProps$)],
228
+ });
211
229
  fixture.detectChanges();
212
230
  expect(fixture.nativeElement.querySelector('p#setterCallNb').innerHTML).toEqual('1');
213
231
  const newProps = {
@@ -228,15 +246,18 @@ describe('StorybookModule', () => {
228
246
  ], WithoutSelectorComponent);
229
247
  it('should display the component', async () => {
230
248
  const props = {};
231
- const ngModule = (0, StorybookModule_1.getStorybookModuleMetadata)({
249
+ const application = (0, StorybookModule_1.getApplication)({
232
250
  storyFnAngular: {
233
251
  props,
234
252
  moduleMetadata: { entryComponents: [WithoutSelectorComponent] },
235
253
  },
236
254
  component: WithoutSelectorComponent,
237
255
  targetSelector: 'my-selector',
238
- }, new rxjs_1.BehaviorSubject(props));
239
- const { fixture } = await configureTestingModule(ngModule);
256
+ });
257
+ const { fixture } = await configureTestingModule({
258
+ imports: [application],
259
+ providers: [(0, StorybookProvider_1.storyPropsProvider)(new rxjs_1.BehaviorSubject(props))],
260
+ });
240
261
  fixture.detectChanges();
241
262
  expect(fixture.nativeElement.innerHTML).toContain('The content');
242
263
  });
@@ -250,28 +271,22 @@ describe('StorybookModule', () => {
250
271
  template: `Should not be displayed`,
251
272
  })
252
273
  ], FooComponent);
253
- const ngModule = (0, StorybookModule_1.getStorybookModuleMetadata)({
274
+ const application = (0, StorybookModule_1.getApplication)({
254
275
  storyFnAngular: { template: '' },
255
276
  component: FooComponent,
256
277
  targetSelector: 'my-selector',
257
- }, new rxjs_1.BehaviorSubject({}));
258
- const { fixture } = await configureTestingModule(ngModule);
278
+ });
279
+ const { fixture } = await configureTestingModule({
280
+ imports: [application],
281
+ providers: [(0, StorybookProvider_1.storyPropsProvider)(new rxjs_1.BehaviorSubject({}))],
282
+ });
259
283
  fixture.detectChanges();
260
284
  expect(fixture.nativeElement.innerHTML).toEqual('');
261
285
  });
262
286
  });
263
287
  async function configureTestingModule(ngModule) {
264
- await testing_1.TestBed.configureTestingModule({
265
- declarations: ngModule.declarations,
266
- providers: ngModule.providers,
267
- })
268
- .overrideModule(platform_browser_1.BrowserModule, {
269
- set: {
270
- entryComponents: [...ngModule.entryComponents],
271
- },
272
- })
273
- .compileComponents();
274
- const fixture = testing_1.TestBed.createComponent(ngModule.bootstrap[0]);
288
+ await testing_1.TestBed.configureTestingModule(ngModule).compileComponents();
289
+ const fixture = testing_1.TestBed.createComponent(ngModule.imports[0]);
275
290
  return {
276
291
  fixture,
277
292
  };
@@ -1,9 +1,10 @@
1
1
  import { Type } from '@angular/core';
2
- import { ICollection } from '../types';
2
+ import { ICollection, NgModuleMetadata } from '../types';
3
+ export declare const componentNgModules: Map<any, Type<any>>;
3
4
  /**
4
5
  * Wraps the story template into a component
5
6
  *
6
7
  * @param storyComponent
7
8
  * @param initialProps
8
9
  */
9
- export declare const createStorybookWrapperComponent: (selector: string, template: string, storyComponent: Type<unknown> | undefined, styles: string[], initialProps?: ICollection) => Type<any>;
10
+ export declare const createStorybookWrapperComponent: (selector: string, template: string, storyComponent: Type<unknown> | undefined, styles: string[], moduleMetadata: NgModuleMetadata, initialProps?: ICollection) => Type<any>;
@@ -12,12 +12,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.createStorybookWrapperComponent = void 0;
15
+ exports.createStorybookWrapperComponent = exports.componentNgModules = void 0;
16
+ const common_1 = require("@angular/common");
16
17
  const core_1 = require("@angular/core");
17
18
  const rxjs_1 = require("rxjs");
18
19
  const operators_1 = require("rxjs/operators");
19
20
  const StorybookProvider_1 = require("./StorybookProvider");
20
21
  const NgComponentAnalyzer_1 = require("./utils/NgComponentAnalyzer");
22
+ const NgModulesAnalyzer_1 = require("./utils/NgModulesAnalyzer");
21
23
  const getNonInputsOutputsProps = (ngComponentInputsOutputs, props = {}) => {
22
24
  const inputs = ngComponentInputsOutputs.inputs
23
25
  .filter((i) => i.templateName in props)
@@ -27,16 +29,51 @@ const getNonInputsOutputsProps = (ngComponentInputsOutputs, props = {}) => {
27
29
  .map((o) => o.templateName);
28
30
  return Object.keys(props).filter((k) => ![...inputs, ...outputs].includes(k));
29
31
  };
32
+ exports.componentNgModules = new Map();
30
33
  /**
31
34
  * Wraps the story template into a component
32
35
  *
33
36
  * @param storyComponent
34
37
  * @param initialProps
35
38
  */
36
- const createStorybookWrapperComponent = (selector, template, storyComponent, styles, initialProps) => {
39
+ const createStorybookWrapperComponent = (selector, template, storyComponent, styles, moduleMetadata, initialProps) => {
37
40
  // In ivy, a '' selector is not allowed, therefore we need to just set it to anything if
38
41
  // storyComponent was not provided.
39
42
  const viewChildSelector = storyComponent ?? '__storybook-noop';
43
+ const isStandalone = (0, NgComponentAnalyzer_1.isStandaloneComponent)(storyComponent);
44
+ // Look recursively (deep) if the component is not already declared by an import module
45
+ const requiresComponentDeclaration = (0, NgComponentAnalyzer_1.isDeclarable)(storyComponent) &&
46
+ !(0, NgModulesAnalyzer_1.isComponentAlreadyDeclaredInModules)(storyComponent, moduleMetadata.declarations, moduleMetadata.imports) &&
47
+ !isStandalone;
48
+ const providersNgModules = (moduleMetadata.providers ?? []).map((provider) => {
49
+ if (!exports.componentNgModules.get(provider)) {
50
+ let ProviderModule = class ProviderModule {
51
+ };
52
+ ProviderModule = __decorate([
53
+ (0, core_1.NgModule)({
54
+ providers: [provider],
55
+ })
56
+ ], ProviderModule);
57
+ exports.componentNgModules.set(provider, ProviderModule);
58
+ }
59
+ return exports.componentNgModules.get(provider);
60
+ });
61
+ if (!exports.componentNgModules.get(storyComponent)) {
62
+ const declarations = [
63
+ ...(requiresComponentDeclaration ? [storyComponent] : []),
64
+ ...(moduleMetadata.declarations ?? []),
65
+ ];
66
+ let StorybookComponentModule = class StorybookComponentModule {
67
+ };
68
+ StorybookComponentModule = __decorate([
69
+ (0, core_1.NgModule)({
70
+ declarations,
71
+ imports: [common_1.CommonModule, ...(moduleMetadata.imports ?? [])],
72
+ exports: [...declarations, ...(moduleMetadata.imports ?? [])],
73
+ })
74
+ ], StorybookComponentModule);
75
+ exports.componentNgModules.set(storyComponent, StorybookComponentModule);
76
+ }
40
77
  let StorybookWrapperComponent = class StorybookWrapperComponent {
41
78
  constructor(storyProps$, changeDetectorRef) {
42
79
  this.storyProps$ = storyProps$;
@@ -104,7 +141,15 @@ const createStorybookWrapperComponent = (selector, template, storyComponent, sty
104
141
  (0, core_1.Component)({
105
142
  selector,
106
143
  template,
144
+ standalone: true,
145
+ imports: [
146
+ common_1.CommonModule,
147
+ exports.componentNgModules.get(storyComponent),
148
+ ...providersNgModules,
149
+ ...(isStandalone ? [storyComponent] : []),
150
+ ],
107
151
  styles,
152
+ schemas: moduleMetadata.schemas,
108
153
  }),
109
154
  __param(0, (0, core_1.Inject)(StorybookProvider_1.STORY_PROPS)),
110
155
  __metadata("design:paramtypes", [rxjs_1.Subject,
@@ -76,7 +76,7 @@ const isStandaloneComponent = (component) => {
76
76
  const decorators = reflectionCapabilities.annotations(component);
77
77
  // TODO: `standalone` is only available in Angular v14. Remove cast to `any` once
78
78
  // Angular deps are updated to v14.x.x.
79
- return (decorators || []).some((d) => d instanceof core_1.Component && d.standalone);
79
+ return (decorators || []).some((d) => (d instanceof core_1.Component || d instanceof core_1.Directive || d instanceof core_1.Pipe) && d.standalone);
80
80
  };
81
81
  exports.isStandaloneComponent = isStandaloneComponent;
82
82
  /**
@@ -252,8 +252,6 @@ describe('isComponent', () => {
252
252
  });
253
253
  describe('isStandaloneComponent', () => {
254
254
  it('should return true with a Component with "standalone: true"', () => {
255
- // TODO: `standalone` is only available in Angular v14. Remove cast to `any` once
256
- // Angular deps are updated to v14.x.x.
257
255
  let FooComponent = class FooComponent {
258
256
  };
259
257
  FooComponent = __decorate([
@@ -262,8 +260,6 @@ describe('isStandaloneComponent', () => {
262
260
  expect((0, NgComponentAnalyzer_1.isStandaloneComponent)(FooComponent)).toEqual(true);
263
261
  });
264
262
  it('should return false with a Component with "standalone: false"', () => {
265
- // TODO: `standalone` is only available in Angular v14. Remove cast to `any` once
266
- // Angular deps are updated to v14.x.x.
267
263
  let FooComponent = class FooComponent {
268
264
  };
269
265
  FooComponent = __decorate([
@@ -284,7 +280,23 @@ describe('isStandaloneComponent', () => {
284
280
  }
285
281
  expect((0, NgComponentAnalyzer_1.isStandaloneComponent)(FooPipe)).toEqual(false);
286
282
  });
287
- it('should return false with Directive', () => {
283
+ it('should return true with a Directive with "standalone: true"', () => {
284
+ let FooDirective = class FooDirective {
285
+ };
286
+ FooDirective = __decorate([
287
+ (0, core_1.Directive)({ standalone: true })
288
+ ], FooDirective);
289
+ expect((0, NgComponentAnalyzer_1.isStandaloneComponent)(FooDirective)).toEqual(true);
290
+ });
291
+ it('should return false with a Directive with "standalone: false"', () => {
292
+ let FooDirective = class FooDirective {
293
+ };
294
+ FooDirective = __decorate([
295
+ (0, core_1.Directive)({ standalone: false })
296
+ ], FooDirective);
297
+ expect((0, NgComponentAnalyzer_1.isStandaloneComponent)(FooDirective)).toEqual(false);
298
+ });
299
+ it('should return false with Directive without the "standalone" property', () => {
288
300
  let FooDirective = class FooDirective {
289
301
  };
290
302
  FooDirective = __decorate([
@@ -292,6 +304,32 @@ describe('isStandaloneComponent', () => {
292
304
  ], FooDirective);
293
305
  expect((0, NgComponentAnalyzer_1.isStandaloneComponent)(FooDirective)).toEqual(false);
294
306
  });
307
+ it('should return true with a Pipe with "standalone: true"', () => {
308
+ let FooPipe = class FooPipe {
309
+ };
310
+ FooPipe = __decorate([
311
+ (0, core_1.Pipe)({ name: 'FooPipe', standalone: true })
312
+ ], FooPipe);
313
+ expect((0, NgComponentAnalyzer_1.isStandaloneComponent)(FooPipe)).toEqual(true);
314
+ });
315
+ it('should return false with a Pipe with "standalone: false"', () => {
316
+ let FooPipe = class FooPipe {
317
+ };
318
+ FooPipe = __decorate([
319
+ (0, core_1.Pipe)({ name: 'FooPipe', standalone: false })
320
+ ], FooPipe);
321
+ expect((0, NgComponentAnalyzer_1.isStandaloneComponent)(FooPipe)).toEqual(false);
322
+ });
323
+ it('should return false with Pipe without the "standalone" property', () => {
324
+ let FooPipe = class FooPipe {
325
+ };
326
+ FooPipe = __decorate([
327
+ (0, core_1.Pipe)({
328
+ name: 'fooPipe',
329
+ })
330
+ ], FooPipe);
331
+ expect((0, NgComponentAnalyzer_1.isStandaloneComponent)(FooPipe)).toEqual(false);
332
+ });
295
333
  });
296
334
  describe('getComponentDecoratorMetadata', () => {
297
335
  it('should return Component with a Component', () => {
@@ -19,7 +19,7 @@ exports.default = decorateStory;
19
19
  exports.decorateStory = decorateStory;
20
20
  const prepareMain = (story, context) => {
21
21
  let { template } = story;
22
- const component = story.component ?? context.component;
22
+ const { component } = context;
23
23
  const userDefinedTemplate = !hasNoTemplate(template);
24
24
  if (!userDefinedTemplate && component) {
25
25
  template = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, story.props, '');
@@ -1,20 +1,18 @@
1
1
  "use strict";
2
- /* eslint-disable no-underscore-dangle */
3
- /* global window */
4
2
  Object.defineProperty(exports, "__esModule", { value: true });
5
3
  exports.extractComponentDescription = exports.extractArgTypes = exports.extractArgTypesFromData = exports.extractType = exports.findComponentByName = exports.checkValidCompodocJson = exports.checkValidComponentOrDirective = exports.getCompodocJson = exports.setCompodocJson = exports.isMethod = void 0;
4
+ /* eslint-disable no-underscore-dangle */
5
+ const global_1 = require("@storybook/global");
6
6
  const client_logger_1 = require("@storybook/client-logger");
7
7
  const isMethod = (methodOrProp) => {
8
8
  return methodOrProp.args !== undefined;
9
9
  };
10
10
  exports.isMethod = isMethod;
11
11
  const setCompodocJson = (compodocJson) => {
12
- // @ts-expect-error (Converted from ts-ignore)
13
- window.__STORYBOOK_COMPODOC_JSON__ = compodocJson;
12
+ global_1.global.__STORYBOOK_COMPODOC_JSON__ = compodocJson;
14
13
  };
15
14
  exports.setCompodocJson = setCompodocJson;
16
- // @ts-expect-error (Converted from ts-ignore)
17
- const getCompodocJson = () => window.__STORYBOOK_COMPODOC_JSON__;
15
+ const getCompodocJson = () => global_1.global.__STORYBOOK_COMPODOC_JSON__;
18
16
  exports.getCompodocJson = getCompodocJson;
19
17
  const checkValidComponentOrDirective = (component) => {
20
18
  if (!component.name) {
@@ -167,7 +165,7 @@ const extractDefaultValueFromComments = (property, value) => {
167
165
  let commentValue = value;
168
166
  property.jsdoctags.forEach((tag) => {
169
167
  if (['default', 'defaultvalue'].includes(tag.tagName.escapedText)) {
170
- const dom = new window.DOMParser().parseFromString(tag.comment, 'text/html');
168
+ const dom = new global_1.global.DOMParser().parseFromString(tag.comment, 'text/html');
171
169
  commentValue = dom.body.textContent;
172
170
  }
173
171
  });
@@ -6,8 +6,7 @@ const compodoc_1 = require("./compodoc");
6
6
  const sourceDecorator_1 = require("./sourceDecorator");
7
7
  exports.parameters = {
8
8
  docs: {
9
- // probably set this to true by default once it's battle-tested
10
- inlineStories: false,
9
+ story: { inline: true },
11
10
  extractArgTypes: compodoc_1.extractArgTypes,
12
11
  extractComponentDescription: compodoc_1.extractComponentDescription,
13
12
  source: {
@@ -1,9 +1,6 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const global_1 = __importDefault(require("global"));
3
+ const global_1 = require("@storybook/global");
7
4
  /**
8
5
  * This file includes polyfills needed by Angular and is loaded before the app.
9
6
  * You can add your own extra polyfills to this file.
@@ -63,5 +60,4 @@ require("zone.js/dist/zone"); // Included with Angular CLI.
63
60
  * Need to import at least one locale-data with intl.
64
61
  */
65
62
  // import 'intl/locale-data/jsonp/en';
66
- const { window: globalWindow } = global_1.default;
67
- globalWindow.STORYBOOK_ENV = 'angular';
63
+ global_1.global.STORYBOOK_ENV = 'angular';
@@ -1,3 +1,4 @@
1
+ import '@angular/compiler';
1
2
  import { RenderContext, ArgsStoryFn } from '@storybook/types';
2
3
  import { AngularRenderer } from './types';
3
4
  import { RendererFactory } from './angular-beta/RendererFactory';
@@ -1,17 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.renderToCanvas = exports.render = exports.rendererFactory = void 0;
4
- const helpers_1 = require("./angular/helpers");
4
+ require("@angular/compiler");
5
5
  const RendererFactory_1 = require("./angular-beta/RendererFactory");
6
6
  exports.rendererFactory = new RendererFactory_1.RendererFactory();
7
7
  const render = (props) => ({ props });
8
8
  exports.render = render;
9
9
  async function renderToCanvas({ storyFn, showMain, forceRemount, storyContext: { parameters, component }, id, }, element) {
10
10
  showMain();
11
- if (parameters.angularLegacyRendering) {
12
- (0, helpers_1.renderNgApp)(storyFn, !forceRemount);
13
- return;
14
- }
15
11
  const renderer = await exports.rendererFactory.getRendererInstance(id, element);
16
12
  await renderer.render({
17
13
  storyFnAngular: storyFn(),
@@ -29,8 +29,6 @@ export interface AngularRenderer extends WebRenderer {
29
29
  storyResult: StoryFnAngularReturnType;
30
30
  }
31
31
  export type Parameters = DefaultParameters & {
32
- /** Uses legacy angular rendering engine that use dynamic component */
33
- angularLegacyRendering?: boolean;
34
32
  bootstrapModuleOptions?: unknown;
35
33
  };
36
34
  export type StoryContext = DefaultStoryContext<AngularRenderer> & {
package/dist/index.mjs ADDED
@@ -0,0 +1,13 @@
1
+ export * from './client/index';
2
+ export * from './types';
3
+ /*
4
+ * ATTENTION:
5
+ * - moduleMetadata
6
+ * - NgModuleMetadata
7
+ * - ICollection
8
+ *
9
+ * These typings are coped out of decorators.d.ts and types.d.ts in order to fix a bug with tsc
10
+ * It was imported out of dist before which was not the proper way of exporting public API
11
+ *
12
+ * This can be fixed by migrating app/angular to typescript
13
+ */
@@ -0,0 +1,26 @@
1
+ import path from 'path';
2
+ export const addons = [
3
+ require.resolve('./server/framework-preset-angular-cli'),
4
+ require.resolve('./server/framework-preset-angular-ivy'),
5
+ require.resolve('./server/framework-preset-angular-docs'),
6
+ ];
7
+ export const previewAnnotations = (entries = []) => [
8
+ ...entries,
9
+ require.resolve('./client/config'),
10
+ ];
11
+ export const core = async (config, options) => {
12
+ const framework = await options.presets.apply('framework');
13
+ return {
14
+ ...config,
15
+ builder: {
16
+ name: path.dirname(require.resolve(path.join('@storybook/builder-webpack5', 'package.json'))),
17
+ options: typeof framework === 'string' ? {} : framework.options.builder || {},
18
+ },
19
+ };
20
+ };
21
+ export const typescript = async (config) => {
22
+ return {
23
+ ...config,
24
+ skipBabel: true,
25
+ };
26
+ };
@@ -1,4 +1,5 @@
1
+ export { storyPropsProvider } from './client/angular-beta/StorybookProvider';
1
2
  export { computesTemplateSourceFromComponent } from './client/angular-beta/ComputesTemplateFromComponent';
2
3
  export { rendererFactory } from './client/render';
3
4
  export { AbstractRenderer } from './client/angular-beta/AbstractRenderer';
4
- export { getStorybookModuleMetadata } from './client/angular-beta/StorybookModule';
5
+ export { getApplication } from './client/angular-beta/StorybookModule';
package/dist/renderer.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getStorybookModuleMetadata = exports.AbstractRenderer = exports.rendererFactory = exports.computesTemplateSourceFromComponent = void 0;
3
+ exports.getApplication = exports.AbstractRenderer = exports.rendererFactory = exports.computesTemplateSourceFromComponent = exports.storyPropsProvider = void 0;
4
+ var StorybookProvider_1 = require("./client/angular-beta/StorybookProvider");
5
+ Object.defineProperty(exports, "storyPropsProvider", { enumerable: true, get: function () { return StorybookProvider_1.storyPropsProvider; } });
4
6
  var ComputesTemplateFromComponent_1 = require("./client/angular-beta/ComputesTemplateFromComponent");
5
7
  Object.defineProperty(exports, "computesTemplateSourceFromComponent", { enumerable: true, get: function () { return ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent; } });
6
8
  var render_1 = require("./client/render");
@@ -8,4 +10,4 @@ Object.defineProperty(exports, "rendererFactory", { enumerable: true, get: funct
8
10
  var AbstractRenderer_1 = require("./client/angular-beta/AbstractRenderer");
9
11
  Object.defineProperty(exports, "AbstractRenderer", { enumerable: true, get: function () { return AbstractRenderer_1.AbstractRenderer; } });
10
12
  var StorybookModule_1 = require("./client/angular-beta/StorybookModule");
11
- Object.defineProperty(exports, "getStorybookModuleMetadata", { enumerable: true, get: function () { return StorybookModule_1.getStorybookModuleMetadata; } });
13
+ Object.defineProperty(exports, "getApplication", { enumerable: true, get: function () { return StorybookModule_1.getApplication; } });
@@ -0,0 +1,5 @@
1
+ export { storyPropsProvider } from './client/angular-beta/StorybookProvider';
2
+ export { computesTemplateSourceFromComponent } from './client/angular-beta/ComputesTemplateFromComponent';
3
+ export { rendererFactory } from './client/render';
4
+ export { AbstractRenderer } from './client/angular-beta/AbstractRenderer';
5
+ export { getApplication } from './client/angular-beta/StorybookModule';
@@ -1,3 +1,4 @@
1
1
  import webpack from 'webpack';
2
2
  import { PresetOptions } from './preset-options';
3
- export declare function webpackFinal(baseConfig: webpack.Configuration, options: PresetOptions): Promise<webpack.Configuration>;
3
+ export declare function webpackFinal(baseConfig: webpack.Configuration, options: PresetOptions): Promise<any>;
4
+ export declare const migrationToBuilderReferrenceMessage: string;