@storybook/angular 8.3.0-alpha.0 → 8.3.0-alpha.10

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 (78) hide show
  1. package/dist/builders/build-storybook/index.d.ts +2 -2
  2. package/dist/builders/build-storybook/index.js +6 -6
  3. package/dist/builders/build-storybook/index.spec.js +2 -3
  4. package/dist/builders/start-storybook/index.d.ts +2 -2
  5. package/dist/builders/start-storybook/index.js +6 -6
  6. package/dist/builders/start-storybook/index.spec.js +3 -27
  7. package/dist/builders/utils/run-compodoc.js +4 -27
  8. package/dist/builders/utils/run-compodoc.spec.js +1 -2
  9. package/dist/builders/utils/standalone-options.d.ts +1 -1
  10. package/dist/client/angular-beta/AbstractRenderer.d.ts +16 -15
  11. package/dist/client/angular-beta/AbstractRenderer.js +17 -16
  12. package/dist/client/angular-beta/CanvasRenderer.d.ts +1 -1
  13. package/dist/client/angular-beta/ComputesTemplateFromComponent.d.ts +8 -1
  14. package/dist/client/angular-beta/ComputesTemplateFromComponent.js +33 -5
  15. package/dist/client/angular-beta/ComputesTemplateFromComponent.test.js +340 -12
  16. package/dist/client/angular-beta/DocsRenderer.d.ts +1 -1
  17. package/dist/client/angular-beta/DocsRenderer.js +8 -11
  18. package/dist/client/angular-beta/RendererFactory.js +1 -1
  19. package/dist/client/angular-beta/StorybookModule.js +2 -4
  20. package/dist/client/angular-beta/StorybookModule.test.js +6 -6
  21. package/dist/client/angular-beta/StorybookProvider.d.ts +1 -1
  22. package/dist/client/angular-beta/StorybookWrapperComponent.d.ts +1 -3
  23. package/dist/client/angular-beta/StorybookWrapperComponent.js +1 -3
  24. package/dist/client/angular-beta/__testfixtures__/input.component.d.ts +3 -0
  25. package/dist/client/angular-beta/__testfixtures__/input.component.js +9 -0
  26. package/dist/client/angular-beta/utils/BootstrapQueue.d.ts +5 -7
  27. package/dist/client/angular-beta/utils/BootstrapQueue.js +8 -13
  28. package/dist/client/angular-beta/utils/BootstrapQueue.test.js +5 -4
  29. package/dist/client/angular-beta/utils/NgComponentAnalyzer.d.ts +4 -11
  30. package/dist/client/angular-beta/utils/NgComponentAnalyzer.js +3 -10
  31. package/dist/client/angular-beta/utils/PropertyExtractor.d.ts +1 -3
  32. package/dist/client/angular-beta/utils/PropertyExtractor.js +0 -2
  33. package/dist/client/angular-beta/utils/PropertyExtractor.test.js +2 -2
  34. package/dist/client/angular-beta/utils/StoryUID.d.ts +8 -9
  35. package/dist/client/angular-beta/utils/StoryUID.js +9 -12
  36. package/dist/client/argsToTemplate.d.ts +13 -12
  37. package/dist/client/argsToTemplate.js +12 -7
  38. package/dist/client/argsToTemplate.test.js +7 -1
  39. package/dist/client/decorators.d.ts +5 -6
  40. package/dist/client/decorators.js +3 -4
  41. package/dist/client/decorators.test.js +2 -0
  42. package/dist/client/docs/__testfixtures__/doc-button/input.d.ts +7 -8
  43. package/dist/client/docs/__testfixtures__/doc-button/input.js +7 -8
  44. package/dist/client/docs/angular-properties.test.js +9 -12
  45. package/dist/client/docs/compodoc.d.ts +1 -1
  46. package/dist/client/docs/compodoc.js +1 -1
  47. package/dist/client/docs/config.d.ts +1 -1
  48. package/dist/client/docs/sourceDecorator.d.ts +3 -2
  49. package/dist/client/docs/sourceDecorator.js +3 -2
  50. package/dist/client/globals.d.ts +9 -11
  51. package/dist/client/globals.js +16 -21
  52. package/dist/client/index.d.ts +1 -0
  53. package/dist/client/index.js +2 -1
  54. package/dist/client/portable-stories.d.ts +23 -0
  55. package/dist/client/portable-stories.js +53 -0
  56. package/dist/client/render.d.ts +2 -2
  57. package/dist/client/types.d.ts +7 -7
  58. package/dist/preset.js +2 -2
  59. package/dist/preset.mjs +1 -1
  60. package/dist/server/angular-cli-webpack.js +6 -10
  61. package/dist/server/framework-preset-angular-cli.js +7 -16
  62. package/dist/server/framework-preset-angular-ivy.d.ts +2 -2
  63. package/dist/server/framework-preset-angular-ivy.js +14 -40
  64. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.d.ts +4 -3
  65. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.js +4 -3
  66. package/dist/test-setup.js +3 -4
  67. package/dist/test-setup.mjs +1 -2
  68. package/dist/types.d.ts +3 -5
  69. package/package.json +10 -6
  70. package/scripts/postbuild.js +5 -4
  71. package/template/cli/button.component.ts +11 -19
  72. package/template/cli/button.stories.ts +1 -0
  73. package/template/cli/header.component.ts +47 -50
  74. package/template/cli/header.stories.ts +1 -1
  75. package/template/cli/page.component.ts +54 -54
  76. package/template/cli/page.stories.ts +1 -1
  77. package/template/components/index.js +1 -1
  78. package/.eslintrc.js +0 -16
@@ -10,8 +10,309 @@ const core_1 = require("@angular/core");
10
10
  const vitest_1 = require("vitest");
11
11
  const ComputesTemplateFromComponent_1 = require("./ComputesTemplateFromComponent");
12
12
  const input_component_1 = require("./__testfixtures__/input.component");
13
+ (0, vitest_1.describe)('angular template decorator', () => {
14
+ (0, vitest_1.it)('with props should generate tag with properties', () => {
15
+ const component = input_component_1.InputComponent;
16
+ const props = {
17
+ isDisabled: true,
18
+ label: 'Hello world',
19
+ accent: input_component_1.ButtonAccent.High,
20
+ counter: 4,
21
+ 'aria-label': 'Hello world',
22
+ };
23
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
24
+ (0, vitest_1.expect)(source).toEqual(`<doc-button [counter]="counter" [accent]="accent" [isDisabled]="isDisabled" [label]="label" [aria-label]="this['aria-label']"></doc-button>`);
25
+ });
26
+ (0, vitest_1.it)('with props should generate tag with outputs', () => {
27
+ const component = input_component_1.InputComponent;
28
+ const props = {
29
+ isDisabled: true,
30
+ label: 'Hello world',
31
+ onClick: ($event) => { },
32
+ 'dash-out': ($event) => { },
33
+ };
34
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
35
+ (0, vitest_1.expect)(source).toEqual(`<doc-button [isDisabled]="isDisabled" [label]="label" (onClick)="onClick($event)" (dash-out)="this['dash-out']($event)"></doc-button>`);
36
+ });
37
+ (0, vitest_1.it)('with no props should generate simple tag', () => {
38
+ const component = input_component_1.InputComponent;
39
+ const props = {};
40
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
41
+ (0, vitest_1.expect)(source).toEqual('<doc-button></doc-button>');
42
+ });
43
+ (0, vitest_1.describe)('with component without selector', () => {
44
+ let WithoutSelectorComponent = class WithoutSelectorComponent {
45
+ };
46
+ WithoutSelectorComponent = __decorate([
47
+ (0, core_1.Component)({
48
+ template: `The content`,
49
+ })
50
+ ], WithoutSelectorComponent);
51
+ (0, vitest_1.it)('should add component ng-container', async () => {
52
+ const component = WithoutSelectorComponent;
53
+ const props = {};
54
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
55
+ (0, vitest_1.expect)(source).toEqual(`<ng-container *ngComponentOutlet="storyComponent"></ng-container>`);
56
+ });
57
+ });
58
+ (0, vitest_1.describe)('with component with attribute selector', () => {
59
+ let WithAttributeComponent = class WithAttributeComponent {
60
+ };
61
+ WithAttributeComponent = __decorate([
62
+ (0, core_1.Component)({
63
+ selector: 'doc-button[foo]',
64
+ template: '<button></button>',
65
+ })
66
+ ], WithAttributeComponent);
67
+ (0, vitest_1.it)('should add attribute to template', async () => {
68
+ const component = WithAttributeComponent;
69
+ const props = {};
70
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
71
+ (0, vitest_1.expect)(source).toEqual(`<doc-button foo></doc-button>`);
72
+ });
73
+ });
74
+ (0, vitest_1.describe)('with component with attribute and value selector', () => {
75
+ let WithAttributeValueComponent = class WithAttributeValueComponent {
76
+ };
77
+ WithAttributeValueComponent = __decorate([
78
+ (0, core_1.Component)({
79
+ selector: 'doc-button[foo="bar"]',
80
+ template: '<button></button>',
81
+ })
82
+ ], WithAttributeValueComponent);
83
+ (0, vitest_1.it)('should add attribute to template', async () => {
84
+ const component = WithAttributeValueComponent;
85
+ const props = {};
86
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
87
+ (0, vitest_1.expect)(source).toEqual(`<doc-button foo="bar"></doc-button>`);
88
+ });
89
+ });
90
+ (0, vitest_1.describe)('with component with attribute only selector', () => {
91
+ let WithAttributeOnlyComponent = class WithAttributeOnlyComponent {
92
+ };
93
+ WithAttributeOnlyComponent = __decorate([
94
+ (0, core_1.Component)({
95
+ selector: '[foo]',
96
+ template: '<button></button>',
97
+ })
98
+ ], WithAttributeOnlyComponent);
99
+ (0, vitest_1.it)('should create a div and add attribute to template', async () => {
100
+ const component = WithAttributeOnlyComponent;
101
+ const props = {};
102
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
103
+ (0, vitest_1.expect)(source).toEqual(`<div foo></div>`);
104
+ });
105
+ });
106
+ (0, vitest_1.describe)('with component with void element and attribute selector', () => {
107
+ let VoidElementWithAttributeComponent = class VoidElementWithAttributeComponent {
108
+ };
109
+ VoidElementWithAttributeComponent = __decorate([
110
+ (0, core_1.Component)({
111
+ selector: 'input[foo]',
112
+ template: '<button></button>',
113
+ })
114
+ ], VoidElementWithAttributeComponent);
115
+ (0, vitest_1.it)('should create without separate closing tag', async () => {
116
+ const component = VoidElementWithAttributeComponent;
117
+ const props = {};
118
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
119
+ (0, vitest_1.expect)(source).toEqual(`<input foo />`);
120
+ });
121
+ });
122
+ (0, vitest_1.describe)('with component with attribute and value only selector', () => {
123
+ let WithAttributeOnlyComponent = class WithAttributeOnlyComponent {
124
+ };
125
+ WithAttributeOnlyComponent = __decorate([
126
+ (0, core_1.Component)({
127
+ selector: '[foo="bar"]',
128
+ template: '<button></button>',
129
+ })
130
+ ], WithAttributeOnlyComponent);
131
+ (0, vitest_1.it)('should create a div and add attribute to template', async () => {
132
+ const component = WithAttributeOnlyComponent;
133
+ const props = {};
134
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
135
+ (0, vitest_1.expect)(source).toEqual(`<div foo="bar"></div>`);
136
+ });
137
+ });
138
+ (0, vitest_1.describe)('with component with void element, attribute and value only selector', () => {
139
+ let VoidElementWithAttributeComponent = class VoidElementWithAttributeComponent {
140
+ };
141
+ VoidElementWithAttributeComponent = __decorate([
142
+ (0, core_1.Component)({
143
+ selector: 'input[foo="bar"]',
144
+ template: '<button></button>',
145
+ })
146
+ ], VoidElementWithAttributeComponent);
147
+ (0, vitest_1.it)('should create and add attribute to template without separate closing tag', async () => {
148
+ const component = VoidElementWithAttributeComponent;
149
+ const props = {};
150
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
151
+ (0, vitest_1.expect)(source).toEqual(`<input foo="bar" />`);
152
+ });
153
+ });
154
+ (0, vitest_1.describe)('with component with class selector', () => {
155
+ let WithClassComponent = class WithClassComponent {
156
+ };
157
+ WithClassComponent = __decorate([
158
+ (0, core_1.Component)({
159
+ selector: 'doc-button.foo',
160
+ template: '<button></button>',
161
+ })
162
+ ], WithClassComponent);
163
+ (0, vitest_1.it)('should add class to template', async () => {
164
+ const component = WithClassComponent;
165
+ const props = {};
166
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
167
+ (0, vitest_1.expect)(source).toEqual(`<doc-button class="foo"></doc-button>`);
168
+ });
169
+ });
170
+ (0, vitest_1.describe)('with component with class only selector', () => {
171
+ let WithClassComponent = class WithClassComponent {
172
+ };
173
+ WithClassComponent = __decorate([
174
+ (0, core_1.Component)({
175
+ selector: '.foo',
176
+ template: '<button></button>',
177
+ })
178
+ ], WithClassComponent);
179
+ (0, vitest_1.it)('should create a div and add attribute to template', async () => {
180
+ const component = WithClassComponent;
181
+ const props = {};
182
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
183
+ (0, vitest_1.expect)(source).toEqual(`<div class="foo"></div>`);
184
+ });
185
+ });
186
+ (0, vitest_1.describe)('with component with multiple selectors', () => {
187
+ let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
188
+ };
189
+ WithMultipleSelectorsComponent = __decorate([
190
+ (0, core_1.Component)({
191
+ selector: 'doc-button, doc-button2',
192
+ template: '<button></button>',
193
+ })
194
+ ], WithMultipleSelectorsComponent);
195
+ (0, vitest_1.it)('should use the first selector', async () => {
196
+ const component = WithMultipleSelectorsComponent;
197
+ const props = {};
198
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
199
+ (0, vitest_1.expect)(source).toEqual(`<doc-button></doc-button>`);
200
+ });
201
+ });
202
+ (0, vitest_1.describe)('with component with multiple selectors starting with attribute', () => {
203
+ let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
204
+ };
205
+ WithMultipleSelectorsComponent = __decorate([
206
+ (0, core_1.Component)({
207
+ selector: 'doc-button[foo], doc-button2',
208
+ template: '<button></button>',
209
+ })
210
+ ], WithMultipleSelectorsComponent);
211
+ (0, vitest_1.it)('should use the first selector', async () => {
212
+ const component = WithMultipleSelectorsComponent;
213
+ const props = {};
214
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
215
+ (0, vitest_1.expect)(source).toEqual(`<doc-button foo></doc-button>`);
216
+ });
217
+ });
218
+ (0, vitest_1.describe)('with component with multiple selectors starting with attribute and value', () => {
219
+ let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
220
+ };
221
+ WithMultipleSelectorsComponent = __decorate([
222
+ (0, core_1.Component)({
223
+ selector: 'doc-button[foo="bar"], doc-button2',
224
+ template: '<button></button>',
225
+ })
226
+ ], WithMultipleSelectorsComponent);
227
+ (0, vitest_1.it)('should use the first selector', async () => {
228
+ const component = WithMultipleSelectorsComponent;
229
+ const props = {};
230
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
231
+ (0, vitest_1.expect)(source).toEqual(`<doc-button foo="bar"></doc-button>`);
232
+ });
233
+ });
234
+ (0, vitest_1.describe)('with component with multiple selectors including 2 attributes and a class', () => {
235
+ let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
236
+ };
237
+ WithMultipleSelectorsComponent = __decorate([
238
+ (0, core_1.Component)({
239
+ selector: 'doc-button, button[foo], .button[foo], button[baz]',
240
+ template: '<button></button>',
241
+ })
242
+ ], WithMultipleSelectorsComponent);
243
+ (0, vitest_1.it)('should use the first selector', async () => {
244
+ const component = WithMultipleSelectorsComponent;
245
+ const props = {};
246
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
247
+ (0, vitest_1.expect)(source).toEqual(`<doc-button></doc-button>`);
248
+ });
249
+ });
250
+ (0, vitest_1.describe)('with component with multiple selectors with line breaks', () => {
251
+ let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
252
+ };
253
+ WithMultipleSelectorsComponent = __decorate([
254
+ (0, core_1.Component)({
255
+ selector: `doc-button,
256
+ doc-button2`,
257
+ template: '<button></button>',
258
+ })
259
+ ], WithMultipleSelectorsComponent);
260
+ (0, vitest_1.it)('should use the first selector', async () => {
261
+ const component = WithMultipleSelectorsComponent;
262
+ const props = {};
263
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
264
+ (0, vitest_1.expect)(source).toEqual(`<doc-button></doc-button>`);
265
+ });
266
+ });
267
+ (0, vitest_1.describe)('with component with multiple selectors starting with attribute only with line breaks', () => {
268
+ let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
269
+ };
270
+ WithMultipleSelectorsComponent = __decorate([
271
+ (0, core_1.Component)({
272
+ selector: `[foo],
273
+ doc-button2`,
274
+ template: '<button></button>',
275
+ })
276
+ ], WithMultipleSelectorsComponent);
277
+ (0, vitest_1.it)('should use the first selector', async () => {
278
+ const component = WithMultipleSelectorsComponent;
279
+ const props = {};
280
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
281
+ (0, vitest_1.expect)(source).toEqual(`<div foo></div>`);
282
+ });
283
+ });
284
+ (0, vitest_1.it)('with props should generate tag with properties', () => {
285
+ const component = input_component_1.InputComponent;
286
+ const props = {
287
+ isDisabled: true,
288
+ label: 'Hello world',
289
+ accent: input_component_1.ButtonAccent.High,
290
+ counter: 4,
291
+ };
292
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
293
+ (0, vitest_1.expect)(source).toEqual(`<doc-button [counter]="counter" [accent]="accent" [isDisabled]="isDisabled" [label]="label"></doc-button>`);
294
+ });
295
+ (0, vitest_1.it)('with props should generate tag with outputs', () => {
296
+ const component = input_component_1.InputComponent;
297
+ const props = {
298
+ isDisabled: true,
299
+ label: 'Hello world',
300
+ onClick: ($event) => { },
301
+ };
302
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
303
+ (0, vitest_1.expect)(source).toEqual(`<doc-button [isDisabled]="isDisabled" [label]="label" (onClick)="onClick($event)"></doc-button>`);
304
+ });
305
+ (0, vitest_1.it)('should generate correct property for overridden name for Input', () => {
306
+ const component = input_component_1.InputComponent;
307
+ const props = {
308
+ color: '#ffffff',
309
+ };
310
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
311
+ (0, vitest_1.expect)(source).toEqual(`<doc-button [color]="color"></doc-button>`);
312
+ });
313
+ });
13
314
  (0, vitest_1.describe)('angular source decorator', () => {
14
- (0, vitest_1.it)('With no props should generate simple tag', () => {
315
+ (0, vitest_1.it)('with no props should generate simple tag', () => {
15
316
  const component = input_component_1.InputComponent;
16
317
  const props = {};
17
318
  const argTypes = {};
@@ -282,28 +583,30 @@ const input_component_1 = require("./__testfixtures__/input.component");
282
583
  const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
283
584
  (0, vitest_1.expect)(source).toEqual(`<doc-button></doc-button>`);
284
585
  });
285
- (0, vitest_1.it)('With props should generate tag with properties', () => {
586
+ (0, vitest_1.it)('with props should generate tag with properties', () => {
286
587
  const component = input_component_1.InputComponent;
287
588
  const props = {
288
589
  isDisabled: true,
289
590
  label: 'Hello world',
290
591
  accent: input_component_1.ButtonAccent.High,
291
592
  counter: 4,
593
+ 'aria-label': 'Hello world',
292
594
  };
293
595
  const argTypes = {};
294
596
  const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
295
- (0, vitest_1.expect)(source).toEqual(`<doc-button [counter]="4" [accent]="'High'" [isDisabled]="true" [label]="'Hello world'"></doc-button>`);
597
+ (0, vitest_1.expect)(source).toEqual(`<doc-button [counter]="4" [accent]="'High'" [isDisabled]="true" [label]="'Hello world'" [aria-label]="'Hello world'"></doc-button>`);
296
598
  });
297
- (0, vitest_1.it)('With props should generate tag with outputs', () => {
599
+ (0, vitest_1.it)('with props should generate tag with outputs', () => {
298
600
  const component = input_component_1.InputComponent;
299
601
  const props = {
300
602
  isDisabled: true,
301
603
  label: 'Hello world',
302
604
  onClick: ($event) => { },
605
+ 'dash-out': ($event) => { },
303
606
  };
304
607
  const argTypes = {};
305
608
  const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
306
- (0, vitest_1.expect)(source).toEqual(`<doc-button [isDisabled]="true" [label]="'Hello world'" (onClick)="onClick($event)"></doc-button>`);
609
+ (0, vitest_1.expect)(source).toEqual(`<doc-button [isDisabled]="true" [label]="'Hello world'" (onClick)="onClick($event)" (dash-out)="this['dash-out']($event)"></doc-button>`);
307
610
  });
308
611
  (0, vitest_1.it)('should generate correct property for overridden name for Input', () => {
309
612
  const component = input_component_1.InputComponent;
@@ -316,7 +619,7 @@ const input_component_1 = require("./__testfixtures__/input.component");
316
619
  });
317
620
  });
318
621
  (0, vitest_1.describe)('with argTypes (from compodoc)', () => {
319
- (0, vitest_1.it)('Should handle enum as strongly typed enum', () => {
622
+ (0, vitest_1.it)('should handle enum as strongly typed enum', () => {
320
623
  const component = input_component_1.InputComponent;
321
624
  const props = {
322
625
  isDisabled: false,
@@ -343,7 +646,7 @@ const input_component_1 = require("./__testfixtures__/input.component");
343
646
  const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
344
647
  (0, vitest_1.expect)(source).toEqual(`<doc-button [accent]="'High'" [isDisabled]="false" [label]="'Hello world'"></doc-button>`);
345
648
  });
346
- (0, vitest_1.it)('Should handle enum without values as string', () => {
649
+ (0, vitest_1.it)('should handle enum without values as string', () => {
347
650
  const component = input_component_1.InputComponent;
348
651
  const props = {
349
652
  isDisabled: false,
@@ -370,7 +673,7 @@ const input_component_1 = require("./__testfixtures__/input.component");
370
673
  const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
371
674
  (0, vitest_1.expect)(source).toEqual(`<doc-button [accent]="'High'" [isDisabled]="false" [label]="'Hello world'"></doc-button>`);
372
675
  });
373
- (0, vitest_1.it)('Should handle objects correctly', () => {
676
+ (0, vitest_1.it)('should handle simple object as stringified', () => {
374
677
  const component = input_component_1.InputComponent;
375
678
  const someDataObject = {
376
679
  one: 'Hello world',
@@ -380,10 +683,8 @@ const input_component_1 = require("./__testfixtures__/input.component");
380
683
  `a string literal with 'single quotes'`,
381
684
  'a single quoted string with "double quotes"',
382
685
  "a double quoted string with 'single quotes'",
383
- // eslint-disable-next-line prettier/prettier
384
- 'a single quoted string with escaped \'single quotes\'',
385
- // eslint-disable-next-line prettier/prettier
386
- "a double quoted string with escaped \"double quotes\"",
686
+ "a single quoted string with escaped 'single quotes'",
687
+ 'a double quoted string with escaped "double quotes"',
387
688
  `a string literal with \'escaped single quotes\'`,
388
689
  `a string literal with \"escaped double quotes\"`,
389
690
  ],
@@ -398,5 +699,32 @@ const input_component_1 = require("./__testfixtures__/input.component");
398
699
  // This will have to do for now
399
700
  (0, vitest_1.expect)(source).toEqual(`<doc-button [isDisabled]="false" [label]="'Hello world'" [someDataObject]="{one: 'Hello world', two: true, three: ['a string literal with \\'double quotes\\'', 'a string literal with \\'single quotes\\'', 'a single quoted string with \\'double quotes\\'', 'a double quoted string with \\'single quotes\\'', 'a single quoted string with escaped \\'single quotes\\'', 'a double quoted string with escaped \\'double quotes\\'', 'a string literal with \\'escaped single quotes\\'', 'a string literal with \\'escaped double quotes\\'']}"></doc-button>`);
400
701
  });
702
+ (0, vitest_1.it)('should handle circular object as stringified', () => {
703
+ const component = input_component_1.InputComponent;
704
+ const someDataObject = {
705
+ one: 'Hello world',
706
+ two: true,
707
+ three: [
708
+ `a string literal with "double quotes"`,
709
+ `a string literal with 'single quotes'`,
710
+ 'a single quoted string with "double quotes"',
711
+ "a double quoted string with 'single quotes'",
712
+ "a single quoted string with escaped 'single quotes'",
713
+ 'a double quoted string with escaped "double quotes"',
714
+ `a string literal with \'escaped single quotes\'`,
715
+ `a string literal with \"escaped double quotes\"`,
716
+ ],
717
+ };
718
+ someDataObject.ref = someDataObject;
719
+ const props = {
720
+ isDisabled: false,
721
+ label: 'Hello world',
722
+ someDataObject,
723
+ };
724
+ const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, null);
725
+ // Ideally we should stringify the object, but that could cause the story to break because of unescaped values in the JSON object.
726
+ // This will have to do for now
727
+ (0, vitest_1.expect)(source).toEqual(`<doc-button [isDisabled]="false" [label]="'Hello world'" [someDataObject]="{one: 'Hello world', two: true, three: ['a string literal with \\'double quotes\\'', 'a string literal with \\'single quotes\\'', 'a single quoted string with \\'double quotes\\'', 'a double quoted string with \\'single quotes\\'', 'a single quoted string with escaped \\'single quotes\\'', 'a double quoted string with escaped \\'double quotes\\'', 'a string literal with \\'escaped single quotes\\'', 'a string literal with \\'escaped double quotes\\''], ref: '[Circular]'}"></doc-button>`);
728
+ });
401
729
  });
402
730
  });
@@ -1,5 +1,5 @@
1
+ import { Parameters, StoryFnAngularReturnType } from '../types';
1
2
  import { AbstractRenderer } from './AbstractRenderer';
2
- import { StoryFnAngularReturnType, Parameters } from '../types';
3
3
  export declare class DocsRenderer extends AbstractRenderer {
4
4
  render(options: {
5
5
  storyFnAngular: StoryFnAngularReturnType;
@@ -1,30 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DocsRenderer = void 0;
4
- const preview_api_1 = require("storybook/internal/preview-api");
5
4
  const core_events_1 = require("storybook/internal/core-events");
6
- const StoryUID_1 = require("./utils/StoryUID");
5
+ const preview_api_1 = require("storybook/internal/preview-api");
7
6
  const AbstractRenderer_1 = require("./AbstractRenderer");
7
+ const StoryUID_1 = require("./utils/StoryUID");
8
8
  class DocsRenderer extends AbstractRenderer_1.AbstractRenderer {
9
9
  async render(options) {
10
10
  const channel = preview_api_1.addons.getChannel();
11
11
  /**
12
- * Destroy and recreate the PlatformBrowserDynamic of angular
13
- * For several stories to be rendered in the same docs we should
14
- * not destroy angular between each rendering but do it when the
12
+ * Destroy and recreate the PlatformBrowserDynamic of angular For several stories to be rendered
13
+ * in the same docs we should not destroy angular between each rendering but do it when the
15
14
  * rendered stories are not needed anymore.
16
15
  *
17
- * Note for improvement: currently there is one event per story
18
- * rendered in the doc. But one event could be enough for the whole docs
19
- *
16
+ * Note for improvement: currently there is one event per story rendered in the doc. But one
17
+ * event could be enough for the whole docs
20
18
  */
21
19
  channel.once(core_events_1.STORY_CHANGED, async () => {
22
20
  await DocsRenderer.resetApplications();
23
21
  });
24
22
  /**
25
- * Destroy and recreate the PlatformBrowserDynamic of angular
26
- * when doc re render. Allows to call ngOnDestroy of angular
27
- * for previous component
23
+ * Destroy and recreate the PlatformBrowserDynamic of angular when doc re render. Allows to call
24
+ * ngOnDestroy of angular for previous component
28
25
  */
29
26
  channel.once(core_events_1.DOCS_RENDERED, async () => {
30
27
  await DocsRenderer.resetApplications();
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.clearRootHTMLElement = exports.getRenderType = exports.RendererFactory = void 0;
4
4
  const AbstractRenderer_1 = require("./AbstractRenderer");
5
- const DocsRenderer_1 = require("./DocsRenderer");
6
5
  const CanvasRenderer_1 = require("./CanvasRenderer");
6
+ const DocsRenderer_1 = require("./DocsRenderer");
7
7
  class RendererFactory {
8
8
  constructor() {
9
9
  this.rendererMap = new Map();
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getApplication = void 0;
4
- const StorybookWrapperComponent_1 = require("./StorybookWrapperComponent");
5
4
  const ComputesTemplateFromComponent_1 = require("./ComputesTemplateFromComponent");
5
+ const StorybookWrapperComponent_1 = require("./StorybookWrapperComponent");
6
6
  const getApplication = ({ storyFnAngular, component, targetSelector, analyzedMetadata, }) => {
7
7
  const { props, styles, moduleMetadata = {} } = storyFnAngular;
8
8
  let { template } = storyFnAngular;
@@ -10,9 +10,7 @@ const getApplication = ({ storyFnAngular, component, targetSelector, analyzedMet
10
10
  if (!hasTemplate && component) {
11
11
  template = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props, '');
12
12
  }
13
- /**
14
- * Create a component that wraps generated template and gives it props
15
- */
13
+ /** Create a component that wraps generated template and gives it props */
16
14
  return (0, StorybookWrapperComponent_1.createStorybookWrapperComponent)({
17
15
  moduleMetadata,
18
16
  selector: targetSelector,
@@ -57,12 +57,12 @@ const PropertyExtractor_1 = require("./utils/PropertyExtractor");
57
57
  selector: 'foo',
58
58
  template: `
59
59
  <p id="input">{{ input }}</p>
60
- <p id="inputBindingPropertyName">{{ localPropertyName }}</p>
61
- <p id="setterCallNb">{{ setterCallNb }}</p>
62
- <p id="localProperty">{{ localProperty }}</p>
63
- <p id="localFunction">{{ localFunction() }}</p>
64
- <p id="output" (click)="output.emit('outputEmitted')"></p>
65
- <p id="outputBindingPropertyName" (click)="localOutput.emit('outputEmitted')"></p>
60
+ <p id="inputBindingPropertyName">{{ localPropertyName }}</p>
61
+ <p id="setterCallNb">{{ setterCallNb }}</p>
62
+ <p id="localProperty">{{ localProperty }}</p>
63
+ <p id="localFunction">{{ localFunction() }}</p>
64
+ <p id="output" (click)="output.emit('outputEmitted')"></p>
65
+ <p id="outputBindingPropertyName" (click)="localOutput.emit('outputEmitted')"></p>
66
66
  `,
67
67
  })
68
68
  ], FooComponent);
@@ -1,4 +1,4 @@
1
- import { Provider, InjectionToken } from '@angular/core';
1
+ import { InjectionToken, Provider } from '@angular/core';
2
2
  import { Subject } from 'rxjs';
3
3
  import { ICollection } from '../types';
4
4
  export declare const STORY_PROPS: InjectionToken<Subject<ICollection | undefined>>;
@@ -1,9 +1,7 @@
1
1
  import { Type } from '@angular/core';
2
2
  import { ICollection, NgModuleMetadata } from '../types';
3
3
  import { PropertyExtractor } from './utils/PropertyExtractor';
4
- /**
5
- * Wraps the story template into a component
6
- */
4
+ /** Wraps the story template into a component */
7
5
  export declare const createStorybookWrapperComponent: ({ selector, template, storyComponent, styles, moduleMetadata, initialProps, analyzedMetadata, }: {
8
6
  selector: string;
9
7
  template: string;
@@ -28,9 +28,7 @@ const getNonInputsOutputsProps = (ngComponentInputsOutputs, props = {}) => {
28
28
  .map((o) => o.templateName);
29
29
  return Object.keys(props).filter((k) => ![...inputs, ...outputs].includes(k));
30
30
  };
31
- /**
32
- * Wraps the story template into a component
33
- */
31
+ /** Wraps the story template into a component */
34
32
  const createStorybookWrapperComponent = ({ selector, template, storyComponent, styles, moduleMetadata, initialProps, analyzedMetadata, }) => {
35
33
  // In ivy, a '' selector is not allowed, therefore we need to just set it to anything if
36
34
  // storyComponent was not provided.
@@ -8,6 +8,7 @@ export interface ISomeInterface {
8
8
  one: string;
9
9
  two: boolean;
10
10
  three: any[];
11
+ ref?: ISomeInterface;
11
12
  }
12
13
  export declare class InputComponent<T> {
13
14
  /** Appearance style of the button. */
@@ -20,7 +21,9 @@ export declare class InputComponent<T> {
20
21
  /** Sets the button to a disabled state. */
21
22
  isDisabled: boolean;
22
23
  label: string;
24
+ ariaLabel: string;
23
25
  /** Specifies some arbitrary object */
24
26
  someDataObject: ISomeInterface;
25
27
  onClick: EventEmitter<Event>;
28
+ dashOut: EventEmitter<any>;
26
29
  }
@@ -24,6 +24,7 @@ let InputComponent = class InputComponent {
24
24
  /** Sets the button to a disabled state. */
25
25
  this.isDisabled = false;
26
26
  this.onClick = new core_1.EventEmitter();
27
+ this.dashOut = new core_1.EventEmitter();
27
28
  }
28
29
  };
29
30
  exports.InputComponent = InputComponent;
@@ -51,6 +52,10 @@ __decorate([
51
52
  (0, core_1.Input)(),
52
53
  __metadata("design:type", String)
53
54
  ], InputComponent.prototype, "label", void 0);
55
+ __decorate([
56
+ (0, core_1.Input)('aria-label'),
57
+ __metadata("design:type", String)
58
+ ], InputComponent.prototype, "ariaLabel", void 0);
54
59
  __decorate([
55
60
  (0, core_1.Input)(),
56
61
  __metadata("design:type", Object)
@@ -59,6 +64,10 @@ __decorate([
59
64
  (0, core_1.Output)(),
60
65
  __metadata("design:type", Object)
61
66
  ], InputComponent.prototype, "onClick", void 0);
67
+ __decorate([
68
+ (0, core_1.Output)('dash-out'),
69
+ __metadata("design:type", Object)
70
+ ], InputComponent.prototype, "dashOut", void 0);
62
71
  exports.InputComponent = InputComponent = __decorate([
63
72
  (0, core_1.Component)({
64
73
  selector: 'doc-button',
@@ -1,14 +1,12 @@
1
1
  import { ApplicationRef } from '@angular/core';
2
2
  /**
3
- * Queue bootstrapping, so that only one application can be bootstrapped at a
4
- * time.
3
+ * Queue bootstrapping, so that only one application can be bootstrapped at a time.
5
4
  *
6
- * Bootstrapping multiple applications at once can cause Angular to throw an
7
- * error that a component is declared in multiple modules. This avoids two
8
- * stories confusing the Angular compiler, by bootstrapping more that one
9
- * application at a time.
5
+ * Bootstrapping multiple applications at once can cause Angular to throw an error that a component
6
+ * is declared in multiple modules. This avoids two stories confusing the Angular compiler, by
7
+ * bootstrapping more that one application at a time.
10
8
  *
11
- * @param fn callback that should complete the bootstrap process
9
+ * @param fn Callback that should complete the bootstrap process
12
10
  * @returns ApplicationRef from the completed bootstrap process
13
11
  */
14
12
  export declare const queueBootstrapping: (fn: () => Promise<ApplicationRef>) => Promise<ApplicationRef>;