@storybook/angular 9.1.0-alpha.5 → 9.1.0-alpha.7

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 (266) hide show
  1. package/build-schema.json +199 -0
  2. package/builders.json +14 -0
  3. package/dist/builders/build-storybook/index.js +31 -80
  4. package/dist/builders/start-storybook/index.js +31 -101
  5. package/dist/chunk-CUDJAP6K.mjs +3 -0
  6. package/dist/chunk-KMSSK3DZ.mjs +6 -0
  7. package/dist/chunk-LXSTVAFF.mjs +40 -0
  8. package/dist/client/config.d.ts +20 -6
  9. package/dist/client/config.js +49 -20
  10. package/dist/client/config.mjs +10 -13
  11. package/dist/client/docs/config.d.ts +6 -3
  12. package/dist/client/docs/config.js +18 -14
  13. package/dist/client/docs/config.mjs +6 -10
  14. package/dist/client/index.d.ts +144 -6
  15. package/dist/client/index.js +47 -30
  16. package/dist/client/index.mjs +3 -9
  17. package/dist/client/preview-prod.d.ts +2 -1
  18. package/dist/client/preview-prod.js +5 -4
  19. package/dist/client/preview-prod.mjs +1 -0
  20. package/dist/index.d.ts +59 -2
  21. package/dist/index.js +47 -29
  22. package/dist/index.mjs +3 -13
  23. package/dist/preset.js +8 -38
  24. package/dist/server/framework-preset-angular-cli.js +20 -83
  25. package/dist/server/framework-preset-angular-ivy.js +6 -59
  26. package/dist/{client/types.d.ts → types-3b0b7107.d.ts} +9 -9
  27. package/package.json +59 -12
  28. package/start-schema.json +234 -0
  29. package/dist/builders/build-storybook/index.d.ts +0 -25
  30. package/dist/builders/build-storybook/index.mjs +0 -78
  31. package/dist/builders/build-storybook/index.spec.d.ts +0 -1
  32. package/dist/builders/build-storybook/index.spec.js +0 -222
  33. package/dist/builders/build-storybook/index.spec.mjs +0 -187
  34. package/dist/builders/build-storybook/schema.json +0 -199
  35. package/dist/builders/builders.json +0 -14
  36. package/dist/builders/start-storybook/index.d.ts +0 -21
  37. package/dist/builders/start-storybook/index.mjs +0 -99
  38. package/dist/builders/start-storybook/index.spec.d.ts +0 -1
  39. package/dist/builders/start-storybook/index.spec.js +0 -188
  40. package/dist/builders/start-storybook/index.spec.mjs +0 -186
  41. package/dist/builders/start-storybook/schema.json +0 -234
  42. package/dist/builders/utils/error-handler.d.ts +0 -2
  43. package/dist/builders/utils/error-handler.js +0 -38
  44. package/dist/builders/utils/error-handler.mjs +0 -33
  45. package/dist/builders/utils/run-compodoc.d.ts +0 -6
  46. package/dist/builders/utils/run-compodoc.js +0 -35
  47. package/dist/builders/utils/run-compodoc.mjs +0 -31
  48. package/dist/builders/utils/run-compodoc.spec.d.ts +0 -1
  49. package/dist/builders/utils/run-compodoc.spec.js +0 -76
  50. package/dist/builders/utils/run-compodoc.spec.mjs +0 -74
  51. package/dist/builders/utils/standalone-options.d.ts +0 -18
  52. package/dist/builders/utils/standalone-options.js +0 -2
  53. package/dist/builders/utils/standalone-options.mjs +0 -1
  54. package/dist/client/angular-beta/AbstractRenderer.d.ts +0 -75
  55. package/dist/client/angular-beta/AbstractRenderer.js +0 -201
  56. package/dist/client/angular-beta/AbstractRenderer.mjs +0 -164
  57. package/dist/client/angular-beta/CanvasRenderer.d.ts +0 -12
  58. package/dist/client/angular-beta/CanvasRenderer.js +0 -13
  59. package/dist/client/angular-beta/CanvasRenderer.mjs +0 -9
  60. package/dist/client/angular-beta/ComputesTemplateFromComponent.d.ts +0 -24
  61. package/dist/client/angular-beta/ComputesTemplateFromComponent.js +0 -160
  62. package/dist/client/angular-beta/ComputesTemplateFromComponent.mjs +0 -154
  63. package/dist/client/angular-beta/ComputesTemplateFromComponent.test.d.ts +0 -1
  64. package/dist/client/angular-beta/ComputesTemplateFromComponent.test.js +0 -730
  65. package/dist/client/angular-beta/ComputesTemplateFromComponent.test.mjs +0 -728
  66. package/dist/client/angular-beta/DocsRenderer.d.ts +0 -13
  67. package/dist/client/angular-beta/DocsRenderer.js +0 -39
  68. package/dist/client/angular-beta/DocsRenderer.mjs +0 -35
  69. package/dist/client/angular-beta/RendererFactory.d.ts +0 -11
  70. package/dist/client/angular-beta/RendererFactory.js +0 -56
  71. package/dist/client/angular-beta/RendererFactory.mjs +0 -50
  72. package/dist/client/angular-beta/RendererFactory.test.d.ts +0 -1
  73. package/dist/client/angular-beta/RendererFactory.test.js +0 -235
  74. package/dist/client/angular-beta/RendererFactory.test.mjs +0 -233
  75. package/dist/client/angular-beta/StorybookModule.d.ts +0 -8
  76. package/dist/client/angular-beta/StorybookModule.js +0 -27
  77. package/dist/client/angular-beta/StorybookModule.mjs +0 -23
  78. package/dist/client/angular-beta/StorybookModule.test.d.ts +0 -1
  79. package/dist/client/angular-beta/StorybookModule.test.js +0 -321
  80. package/dist/client/angular-beta/StorybookModule.test.mjs +0 -319
  81. package/dist/client/angular-beta/StorybookProvider.d.ts +0 -5
  82. package/dist/client/angular-beta/StorybookProvider.js +0 -26
  83. package/dist/client/angular-beta/StorybookProvider.mjs +0 -22
  84. package/dist/client/angular-beta/StorybookWrapperComponent.d.ts +0 -13
  85. package/dist/client/angular-beta/StorybookWrapperComponent.js +0 -127
  86. package/dist/client/angular-beta/StorybookWrapperComponent.mjs +0 -123
  87. package/dist/client/angular-beta/__testfixtures__/input.component.d.ts +0 -29
  88. package/dist/client/angular-beta/__testfixtures__/input.component.js +0 -76
  89. package/dist/client/angular-beta/__testfixtures__/input.component.mjs +0 -73
  90. package/dist/client/angular-beta/__testfixtures__/test.module.d.ts +0 -2
  91. package/dist/client/angular-beta/__testfixtures__/test.module.js +0 -20
  92. package/dist/client/angular-beta/__testfixtures__/test.module.mjs +0 -17
  93. package/dist/client/angular-beta/utils/BootstrapQueue.d.ts +0 -12
  94. package/dist/client/angular-beta/utils/BootstrapQueue.js +0 -86
  95. package/dist/client/angular-beta/utils/BootstrapQueue.mjs +0 -49
  96. package/dist/client/angular-beta/utils/BootstrapQueue.test.d.ts +0 -1
  97. package/dist/client/angular-beta/utils/BootstrapQueue.test.js +0 -164
  98. package/dist/client/angular-beta/utils/BootstrapQueue.test.mjs +0 -162
  99. package/dist/client/angular-beta/utils/NgComponentAnalyzer.d.ts +0 -22
  100. package/dist/client/angular-beta/utils/NgComponentAnalyzer.js +0 -93
  101. package/dist/client/angular-beta/utils/NgComponentAnalyzer.mjs +0 -84
  102. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.d.ts +0 -1
  103. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.js +0 -388
  104. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.mjs +0 -386
  105. package/dist/client/angular-beta/utils/NgModulesAnalyzer.d.ts +0 -6
  106. package/dist/client/angular-beta/utils/NgModulesAnalyzer.js +0 -41
  107. package/dist/client/angular-beta/utils/NgModulesAnalyzer.mjs +0 -37
  108. package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.d.ts +0 -1
  109. package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.js +0 -24
  110. package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.mjs +0 -22
  111. package/dist/client/angular-beta/utils/PropertyExtractor.d.ts +0 -30
  112. package/dist/client/angular-beta/utils/PropertyExtractor.js +0 -196
  113. package/dist/client/angular-beta/utils/PropertyExtractor.mjs +0 -158
  114. package/dist/client/angular-beta/utils/PropertyExtractor.test.d.ts +0 -1
  115. package/dist/client/angular-beta/utils/PropertyExtractor.test.js +0 -177
  116. package/dist/client/angular-beta/utils/PropertyExtractor.test.mjs +0 -175
  117. package/dist/client/angular-beta/utils/StoryUID.d.ts +0 -22
  118. package/dist/client/angular-beta/utils/StoryUID.js +0 -43
  119. package/dist/client/angular-beta/utils/StoryUID.mjs +0 -38
  120. package/dist/client/argsToTemplate.d.ts +0 -56
  121. package/dist/client/argsToTemplate.js +0 -58
  122. package/dist/client/argsToTemplate.mjs +0 -55
  123. package/dist/client/argsToTemplate.test.d.ts +0 -1
  124. package/dist/client/argsToTemplate.test.js +0 -102
  125. package/dist/client/argsToTemplate.test.mjs +0 -100
  126. package/dist/client/compodoc-types.d.ts +0 -102
  127. package/dist/client/compodoc-types.js +0 -2
  128. package/dist/client/compodoc-types.mjs +0 -1
  129. package/dist/client/compodoc.d.ts +0 -12
  130. package/dist/client/compodoc.js +0 -261
  131. package/dist/client/compodoc.mjs +0 -248
  132. package/dist/client/compodoc.test.d.ts +0 -1
  133. package/dist/client/compodoc.test.js +0 -132
  134. package/dist/client/compodoc.test.mjs +0 -130
  135. package/dist/client/decorateStory.d.ts +0 -4
  136. package/dist/client/decorateStory.js +0 -48
  137. package/dist/client/decorateStory.mjs +0 -45
  138. package/dist/client/decorateStory.test.d.ts +0 -1
  139. package/dist/client/decorateStory.test.js +0 -306
  140. package/dist/client/decorateStory.test.mjs +0 -301
  141. package/dist/client/decorators.d.ts +0 -13
  142. package/dist/client/decorators.js +0 -69
  143. package/dist/client/decorators.mjs +0 -63
  144. package/dist/client/decorators.test.d.ts +0 -1
  145. package/dist/client/decorators.test.js +0 -159
  146. package/dist/client/decorators.test.mjs +0 -157
  147. package/dist/client/docs/__testfixtures__/doc-button/input.d.ts +0 -110
  148. package/dist/client/docs/__testfixtures__/doc-button/input.js +0 -204
  149. package/dist/client/docs/__testfixtures__/doc-button/input.mjs +0 -201
  150. package/dist/client/docs/__testfixtures__/doc-button/tsconfig.json +0 -7
  151. package/dist/client/docs/angular-properties.test.d.ts +0 -1
  152. package/dist/client/docs/angular-properties.test.js +0 -36
  153. package/dist/client/docs/angular-properties.test.mjs +0 -34
  154. package/dist/client/docs/sourceDecorator.d.ts +0 -10
  155. package/dist/client/docs/sourceDecorator.js +0 -53
  156. package/dist/client/docs/sourceDecorator.mjs +0 -48
  157. package/dist/client/globals.d.ts +0 -1
  158. package/dist/client/globals.js +0 -33
  159. package/dist/client/globals.mjs +0 -31
  160. package/dist/client/portable-stories.d.ts +0 -23
  161. package/dist/client/portable-stories.js +0 -62
  162. package/dist/client/portable-stories.mjs +0 -26
  163. package/dist/client/public-types.d.ts +0 -54
  164. package/dist/client/public-types.js +0 -2
  165. package/dist/client/public-types.mjs +0 -1
  166. package/dist/client/render.d.ts +0 -7
  167. package/dist/client/render.js +0 -19
  168. package/dist/client/render.mjs +0 -14
  169. package/dist/client/types.js +0 -2
  170. package/dist/client/types.mjs +0 -1
  171. package/dist/node/index.d.ts +0 -2
  172. package/dist/node/index.js +0 -6
  173. package/dist/node/index.mjs +0 -3
  174. package/dist/preset.d.ts +0 -5
  175. package/dist/preset.mjs +0 -34
  176. package/dist/renderer.d.ts +0 -6
  177. package/dist/renderer.js +0 -15
  178. package/dist/renderer.mjs +0 -6
  179. package/dist/server/__mocks-ng-workspace__/empty-projects-entry/angular.json +0 -4
  180. package/dist/server/__mocks-ng-workspace__/minimal-config/angular.json +0 -18
  181. package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.d.ts +0 -1
  182. package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.js +0 -5
  183. package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.mjs +0 -2
  184. package/dist/server/__mocks-ng-workspace__/minimal-config/src/tsconfig.app.json +0 -9
  185. package/dist/server/__mocks-ng-workspace__/minimal-config/tsconfig.json +0 -13
  186. package/dist/server/__mocks-ng-workspace__/some-config/angular.json +0 -19
  187. package/dist/server/__mocks-ng-workspace__/some-config/src/main.d.ts +0 -1
  188. package/dist/server/__mocks-ng-workspace__/some-config/src/main.js +0 -5
  189. package/dist/server/__mocks-ng-workspace__/some-config/src/main.mjs +0 -2
  190. package/dist/server/__mocks-ng-workspace__/some-config/src/tsconfig.app.json +0 -9
  191. package/dist/server/__mocks-ng-workspace__/some-config/tsconfig.json +0 -13
  192. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/angular.json +0 -64
  193. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.d.ts +0 -1
  194. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.js +0 -5
  195. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.mjs +0 -2
  196. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/tsconfig.app.json +0 -9
  197. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/tsconfig.json +0 -13
  198. package/dist/server/__mocks-ng-workspace__/with-lib/angular.json +0 -28
  199. package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.d.ts +0 -1
  200. package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.js +0 -5
  201. package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.mjs +0 -2
  202. package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/tsconfig.lib.json +0 -20
  203. package/dist/server/__mocks-ng-workspace__/with-lib/tsconfig.json +0 -13
  204. package/dist/server/__mocks-ng-workspace__/with-nx/angular.json +0 -18
  205. package/dist/server/__mocks-ng-workspace__/with-nx/nx.json +0 -3
  206. package/dist/server/__mocks-ng-workspace__/with-nx/src/main.d.ts +0 -1
  207. package/dist/server/__mocks-ng-workspace__/with-nx/src/main.js +0 -5
  208. package/dist/server/__mocks-ng-workspace__/with-nx/src/main.mjs +0 -2
  209. package/dist/server/__mocks-ng-workspace__/with-nx/src/tsconfig.app.json +0 -8
  210. package/dist/server/__mocks-ng-workspace__/with-nx/tsconfig.json +0 -14
  211. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/nx.json +0 -3
  212. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.d.ts +0 -1
  213. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.js +0 -5
  214. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.mjs +0 -2
  215. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/tsconfig.app.json +0 -8
  216. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/tsconfig.json +0 -14
  217. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/workspace.json +0 -18
  218. package/dist/server/__mocks-ng-workspace__/with-options-styles/angular.json +0 -18
  219. package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.d.ts +0 -1
  220. package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.js +0 -5
  221. package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.mjs +0 -2
  222. package/dist/server/__mocks-ng-workspace__/with-options-styles/src/tsconfig.app.json +0 -9
  223. package/dist/server/__mocks-ng-workspace__/with-options-styles/tsconfig.json +0 -13
  224. package/dist/server/__mocks-ng-workspace__/without-architect-build/angular.json +0 -5
  225. package/dist/server/__mocks-ng-workspace__/without-architect-build-options/angular.json +0 -11
  226. package/dist/server/__mocks-ng-workspace__/without-compatible-projects/angular.json +0 -7
  227. package/dist/server/__mocks-ng-workspace__/without-projects-entry/angular.json +0 -3
  228. package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.d.ts +0 -1
  229. package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.js +0 -5
  230. package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.mjs +0 -2
  231. package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/tsconfig.lib.json +0 -20
  232. package/dist/server/__mocks-ng-workspace__/without-projects-entry/tsconfig.json +0 -13
  233. package/dist/server/__mocks-ng-workspace__/without-tsConfig/angular.json +0 -16
  234. package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.d.ts +0 -1
  235. package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.js +0 -5
  236. package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.mjs +0 -2
  237. package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/tsconfig.app.json +0 -9
  238. package/dist/server/__mocks-ng-workspace__/without-tsConfig/tsconfig.json +0 -13
  239. package/dist/server/__tests__/angular.json +0 -96
  240. package/dist/server/angular-cli-webpack.d.ts +0 -1
  241. package/dist/server/angular-cli-webpack.js +0 -80
  242. package/dist/server/angular-cli-webpack.mjs +0 -80
  243. package/dist/server/framework-preset-angular-cli.d.ts +0 -3
  244. package/dist/server/framework-preset-angular-cli.mjs +0 -81
  245. package/dist/server/framework-preset-angular-ivy.d.ts +0 -10
  246. package/dist/server/framework-preset-angular-ivy.mjs +0 -56
  247. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.d.ts +0 -12
  248. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.js +0 -55
  249. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.mjs +0 -52
  250. package/dist/server/preset-options.d.ts +0 -9
  251. package/dist/server/preset-options.js +0 -2
  252. package/dist/server/preset-options.mjs +0 -1
  253. package/dist/server/utils/filter-out-styling-rules.d.ts +0 -2
  254. package/dist/server/utils/filter-out-styling-rules.js +0 -17
  255. package/dist/server/utils/filter-out-styling-rules.mjs +0 -13
  256. package/dist/server/utils/module-is-available.d.ts +0 -1
  257. package/dist/server/utils/module-is-available.js +0 -13
  258. package/dist/server/utils/module-is-available.mjs +0 -9
  259. package/dist/test-setup.d.ts +0 -1
  260. package/dist/test-setup.js +0 -6
  261. package/dist/test-setup.mjs +0 -4
  262. package/dist/types.d.ts +0 -27
  263. package/dist/types.js +0 -2
  264. package/dist/types.mjs +0 -1
  265. package/scripts/postbuild.js +0 -17
  266. package/template/cli/.eslintrc.json +0 -5
@@ -1,175 +0,0 @@
1
- import { CommonModule } from '@angular/common';
2
- import { Component, Directive, Injectable, InjectionToken, NgModule } from '@angular/core';
3
- import { BrowserModule } from '@angular/platform-browser';
4
- import { BrowserAnimationsModule, NoopAnimationsModule, provideAnimations, provideNoopAnimations, } from '@angular/platform-browser/animations';
5
- import { describe, expect, it, vi } from 'vitest';
6
- import { WithOfficialModule } from '../__testfixtures__/test.module';
7
- import { PropertyExtractor } from './PropertyExtractor';
8
- const TEST_TOKEN = new InjectionToken('testToken');
9
- const TestTokenProvider = { provide: TEST_TOKEN, useValue: 123 };
10
- const TestService = Injectable()(class {
11
- });
12
- const TestComponent1 = Component({ standalone: false })(class {
13
- });
14
- const TestComponent2 = Component({ standalone: false })(class {
15
- });
16
- const StandaloneTestComponent = Component({})(class {
17
- });
18
- const StandaloneTestDirective = Directive({})(class {
19
- });
20
- const MixedTestComponent1 = Component({})(class extends StandaloneTestComponent {
21
- });
22
- const MixedTestComponent2 = Component({ standalone: false })(class extends MixedTestComponent1 {
23
- });
24
- const MixedTestComponent3 = Component({})(class extends MixedTestComponent2 {
25
- });
26
- const TestModuleWithDeclarations = NgModule({ declarations: [TestComponent1] })(class {
27
- });
28
- const TestModuleWithImportsAndProviders = NgModule({
29
- imports: [TestModuleWithDeclarations],
30
- providers: [TestTokenProvider],
31
- })(class {
32
- });
33
- const analyzeMetadata = async (metadata, component) => {
34
- const propertyExtractor = new PropertyExtractor(metadata, component);
35
- await propertyExtractor.init();
36
- return propertyExtractor;
37
- };
38
- const extractImports = async (metadata, component) => {
39
- const propertyExtractor = new PropertyExtractor(metadata, component);
40
- await propertyExtractor.init();
41
- return propertyExtractor.imports;
42
- };
43
- const extractDeclarations = async (metadata, component) => {
44
- const propertyExtractor = new PropertyExtractor(metadata, component);
45
- await propertyExtractor.init();
46
- return propertyExtractor.declarations;
47
- };
48
- const extractProviders = async (metadata, component) => {
49
- const propertyExtractor = new PropertyExtractor(metadata, component);
50
- await propertyExtractor.init();
51
- return propertyExtractor.providers;
52
- };
53
- const extractApplicationProviders = async (metadata, component) => {
54
- const propertyExtractor = new PropertyExtractor(metadata, component);
55
- await propertyExtractor.init();
56
- return propertyExtractor.applicationProviders;
57
- };
58
- describe('PropertyExtractor', () => {
59
- vi.spyOn(console, 'warn').mockImplementation(() => { });
60
- describe('analyzeMetadata', () => {
61
- it('should remove BrowserModule', async () => {
62
- const metadata = {
63
- imports: [BrowserModule],
64
- };
65
- const { imports, providers, applicationProviders } = await analyzeMetadata(metadata);
66
- expect(imports.flat(Number.MAX_VALUE)).toEqual([CommonModule]);
67
- expect(providers.flat(Number.MAX_VALUE)).toEqual([]);
68
- expect(applicationProviders.flat(Number.MAX_VALUE)).toEqual([]);
69
- });
70
- it('should remove BrowserAnimationsModule and use its providers instead', async () => {
71
- const metadata = {
72
- imports: [BrowserAnimationsModule],
73
- };
74
- const { imports, providers, applicationProviders } = await analyzeMetadata(metadata);
75
- expect(imports.flat(Number.MAX_VALUE)).toEqual([CommonModule]);
76
- expect(providers.flat(Number.MAX_VALUE)).toEqual([]);
77
- expect(applicationProviders.flat(Number.MAX_VALUE)).toEqual(provideAnimations());
78
- });
79
- it('should remove NoopAnimationsModule and use its providers instead', async () => {
80
- const metadata = {
81
- imports: [NoopAnimationsModule],
82
- };
83
- const { imports, providers, applicationProviders } = await analyzeMetadata(metadata);
84
- expect(imports.flat(Number.MAX_VALUE)).toEqual([CommonModule]);
85
- expect(providers.flat(Number.MAX_VALUE)).toEqual([]);
86
- expect(applicationProviders.flat(Number.MAX_VALUE)).toEqual(provideNoopAnimations());
87
- });
88
- it('should remove Browser/Animations modules recursively', async () => {
89
- const metadata = {
90
- imports: [BrowserAnimationsModule, BrowserModule],
91
- };
92
- const { imports, providers, applicationProviders } = await analyzeMetadata(metadata);
93
- expect(imports.flat(Number.MAX_VALUE)).toEqual([CommonModule]);
94
- expect(providers.flat(Number.MAX_VALUE)).toEqual([]);
95
- expect(applicationProviders.flat(Number.MAX_VALUE)).toEqual(provideAnimations());
96
- });
97
- it('should not destructure Angular official module', async () => {
98
- const metadata = {
99
- imports: [WithOfficialModule],
100
- };
101
- const { imports, providers, applicationProviders } = await analyzeMetadata(metadata);
102
- expect(imports.flat(Number.MAX_VALUE)).toEqual([CommonModule, WithOfficialModule]);
103
- expect(providers.flat(Number.MAX_VALUE)).toEqual([]);
104
- expect(applicationProviders.flat(Number.MAX_VALUE)).toEqual([]);
105
- });
106
- });
107
- describe('extractImports', () => {
108
- it('should return Angular official modules', async () => {
109
- const imports = await extractImports({ imports: [TestModuleWithImportsAndProviders] });
110
- expect(imports).toEqual([CommonModule, TestModuleWithImportsAndProviders]);
111
- });
112
- it('should return standalone components', async () => {
113
- const imports = await extractImports({
114
- imports: [TestModuleWithImportsAndProviders],
115
- }, StandaloneTestComponent);
116
- expect(imports).toEqual([
117
- CommonModule,
118
- TestModuleWithImportsAndProviders,
119
- StandaloneTestComponent,
120
- ]);
121
- });
122
- it('should return standalone directives', async () => {
123
- const imports = await extractImports({
124
- imports: [TestModuleWithImportsAndProviders],
125
- }, StandaloneTestDirective);
126
- expect(imports).toEqual([
127
- CommonModule,
128
- TestModuleWithImportsAndProviders,
129
- StandaloneTestDirective,
130
- ]);
131
- });
132
- });
133
- describe('extractDeclarations', () => {
134
- it('should return an array of declarations that contains `storyComponent`', async () => {
135
- const declarations = await extractDeclarations({ declarations: [TestComponent1] }, TestComponent2);
136
- expect(declarations).toEqual([TestComponent1, TestComponent2]);
137
- });
138
- });
139
- describe('analyzeDecorators', () => {
140
- it('isStandalone should be false', () => {
141
- const { isStandalone } = PropertyExtractor.analyzeDecorators(TestComponent1);
142
- expect(isStandalone).toBe(false);
143
- });
144
- it('isStandalone should be true', () => {
145
- const { isStandalone } = PropertyExtractor.analyzeDecorators(StandaloneTestComponent);
146
- expect(isStandalone).toBe(true);
147
- });
148
- it('isStandalone should be true', () => {
149
- const { isStandalone } = PropertyExtractor.analyzeDecorators(MixedTestComponent1);
150
- expect(isStandalone).toBe(true);
151
- });
152
- it('isStandalone should be false', () => {
153
- const { isStandalone } = PropertyExtractor.analyzeDecorators(MixedTestComponent2);
154
- expect(isStandalone).toBe(false);
155
- });
156
- it('isStandalone should be true', () => {
157
- const { isStandalone } = PropertyExtractor.analyzeDecorators(MixedTestComponent3);
158
- expect(isStandalone).toBe(true);
159
- });
160
- });
161
- describe('extractProviders', () => {
162
- it('should return an array of providers', async () => {
163
- const providers = await extractProviders({
164
- providers: [TestService],
165
- });
166
- expect(providers).toEqual([TestService]);
167
- });
168
- it('should return an array of singletons extracted', async () => {
169
- const singeltons = await extractApplicationProviders({
170
- imports: [BrowserAnimationsModule],
171
- });
172
- expect(singeltons).toEqual(provideAnimations());
173
- });
174
- });
175
- });
@@ -1,22 +0,0 @@
1
- /**
2
- * Increments the count for a storyId and returns the next UID.
3
- *
4
- * When a story is bootstrapped, the storyId is used as the element tag. That becomes an issue when
5
- * a story is rendered multiple times in the same docs page. This function returns a UID that is
6
- * appended to the storyId to make it unique.
7
- *
8
- * @param storyId Id of a story
9
- * @returns Uid of a story
10
- */
11
- export declare const getNextStoryUID: (storyId: string) => string;
12
- /**
13
- * Clears the storyId counts.
14
- *
15
- * Can be useful for testing, where you need predictable increments, without reloading the global
16
- * state.
17
- *
18
- * If onlyStoryId is provided, only that storyId is cleared.
19
- *
20
- * @param onlyStoryId Id of a story
21
- */
22
- export declare const clearStoryUIDs: (onlyStoryId?: string) => void;
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.clearStoryUIDs = exports.getNextStoryUID = void 0;
4
- /** Count of stories for each storyId. */
5
- const storyCounts = new Map();
6
- /**
7
- * Increments the count for a storyId and returns the next UID.
8
- *
9
- * When a story is bootstrapped, the storyId is used as the element tag. That becomes an issue when
10
- * a story is rendered multiple times in the same docs page. This function returns a UID that is
11
- * appended to the storyId to make it unique.
12
- *
13
- * @param storyId Id of a story
14
- * @returns Uid of a story
15
- */
16
- const getNextStoryUID = (storyId) => {
17
- if (!storyCounts.has(storyId)) {
18
- storyCounts.set(storyId, -1);
19
- }
20
- const count = storyCounts.get(storyId) + 1;
21
- storyCounts.set(storyId, count);
22
- return `${storyId}-${count}`;
23
- };
24
- exports.getNextStoryUID = getNextStoryUID;
25
- /**
26
- * Clears the storyId counts.
27
- *
28
- * Can be useful for testing, where you need predictable increments, without reloading the global
29
- * state.
30
- *
31
- * If onlyStoryId is provided, only that storyId is cleared.
32
- *
33
- * @param onlyStoryId Id of a story
34
- */
35
- const clearStoryUIDs = (onlyStoryId) => {
36
- if (onlyStoryId !== undefined && onlyStoryId !== null) {
37
- storyCounts.delete(onlyStoryId);
38
- }
39
- else {
40
- storyCounts.clear();
41
- }
42
- };
43
- exports.clearStoryUIDs = clearStoryUIDs;
@@ -1,38 +0,0 @@
1
- /** Count of stories for each storyId. */
2
- const storyCounts = new Map();
3
- /**
4
- * Increments the count for a storyId and returns the next UID.
5
- *
6
- * When a story is bootstrapped, the storyId is used as the element tag. That becomes an issue when
7
- * a story is rendered multiple times in the same docs page. This function returns a UID that is
8
- * appended to the storyId to make it unique.
9
- *
10
- * @param storyId Id of a story
11
- * @returns Uid of a story
12
- */
13
- export const getNextStoryUID = (storyId) => {
14
- if (!storyCounts.has(storyId)) {
15
- storyCounts.set(storyId, -1);
16
- }
17
- const count = storyCounts.get(storyId) + 1;
18
- storyCounts.set(storyId, count);
19
- return `${storyId}-${count}`;
20
- };
21
- /**
22
- * Clears the storyId counts.
23
- *
24
- * Can be useful for testing, where you need predictable increments, without reloading the global
25
- * state.
26
- *
27
- * If onlyStoryId is provided, only that storyId is cleared.
28
- *
29
- * @param onlyStoryId Id of a story
30
- */
31
- export const clearStoryUIDs = (onlyStoryId) => {
32
- if (onlyStoryId !== undefined && onlyStoryId !== null) {
33
- storyCounts.delete(onlyStoryId);
34
- }
35
- else {
36
- storyCounts.clear();
37
- }
38
- };
@@ -1,56 +0,0 @@
1
- /**
2
- * Options for controlling the behavior of the argsToTemplate function.
3
- *
4
- * @template T The type of the keys in the target object.
5
- */
6
- export interface ArgsToTemplateOptions<T> {
7
- /**
8
- * An array of keys to specifically include in the output. If provided, only the keys from this
9
- * array will be included in the output, irrespective of the `exclude` option. Undefined values
10
- * will still be excluded from the output.
11
- */
12
- include?: Array<T>;
13
- /**
14
- * An array of keys to specifically exclude from the output. If provided, these keys will be
15
- * omitted from the output. This option is ignored if the `include` option is also provided
16
- */
17
- exclude?: Array<T>;
18
- }
19
- /**
20
- * Converts an object of arguments to a string of property and event bindings and excludes undefined
21
- * values. Why? Because Angular treats undefined values in property bindings as an actual value and
22
- * does not apply the default value of the property as soon as the binding is set. This feels
23
- * counter-intuitive and is a common source of bugs in stories.
24
- *
25
- * @example
26
- *
27
- * ```ts
28
- * // component.ts
29
- * ㅤ@Component({ selector: 'example' })
30
- * export class ExampleComponent {
31
- * ㅤ@Input() input1: string = 'Default Input1';
32
- * ㅤ@Input() input2: string = 'Default Input2';
33
- * ㅤ@Output() click = new EventEmitter();
34
- * }
35
- *
36
- * // component.stories.ts
37
- * import { argsToTemplate } from '@storybook/angular';
38
- * export const Input1: Story = {
39
- * render: (args) => ({
40
- * props: args,
41
- * // Problem1: <example [input1]="input1" [input2]="input2" (click)="click($event)"></example>
42
- * // This will set input2 to undefined and the internal default value will not be used.
43
- * // Problem2: <example [input1]="input1" (click)="click($event)"></example>
44
- * // The default value of input2 will be used, but it is not overridable by the user via controls.
45
- * // Solution: Now the controls will be applicable to both input1 and input2, and the default values will be used if the user does not override them.
46
- * template: `<example ${argsToTemplate(args)}"></example>`,
47
- * }),
48
- * args: {
49
- * // In this Story, we want to set the input1 property, and the internal default property of input2 should be used.
50
- * input1: 'Input 1',
51
- * click: { action: 'clicked' },
52
- * },
53
- * };
54
- * ```
55
- */
56
- export declare function argsToTemplate<A extends Record<string, any>>(args: A, options?: ArgsToTemplateOptions<keyof A>): string;
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.argsToTemplate = argsToTemplate;
4
- const ComputesTemplateFromComponent_1 = require("./angular-beta/ComputesTemplateFromComponent");
5
- /**
6
- * Converts an object of arguments to a string of property and event bindings and excludes undefined
7
- * values. Why? Because Angular treats undefined values in property bindings as an actual value and
8
- * does not apply the default value of the property as soon as the binding is set. This feels
9
- * counter-intuitive and is a common source of bugs in stories.
10
- *
11
- * @example
12
- *
13
- * ```ts
14
- * // component.ts
15
- * ㅤ@Component({ selector: 'example' })
16
- * export class ExampleComponent {
17
- * ㅤ@Input() input1: string = 'Default Input1';
18
- * ㅤ@Input() input2: string = 'Default Input2';
19
- * ㅤ@Output() click = new EventEmitter();
20
- * }
21
- *
22
- * // component.stories.ts
23
- * import { argsToTemplate } from '@storybook/angular';
24
- * export const Input1: Story = {
25
- * render: (args) => ({
26
- * props: args,
27
- * // Problem1: <example [input1]="input1" [input2]="input2" (click)="click($event)"></example>
28
- * // This will set input2 to undefined and the internal default value will not be used.
29
- * // Problem2: <example [input1]="input1" (click)="click($event)"></example>
30
- * // The default value of input2 will be used, but it is not overridable by the user via controls.
31
- * // Solution: Now the controls will be applicable to both input1 and input2, and the default values will be used if the user does not override them.
32
- * template: `<example ${argsToTemplate(args)}"></example>`,
33
- * }),
34
- * args: {
35
- * // In this Story, we want to set the input1 property, and the internal default property of input2 should be used.
36
- * input1: 'Input 1',
37
- * click: { action: 'clicked' },
38
- * },
39
- * };
40
- * ```
41
- */
42
- function argsToTemplate(args, options = {}) {
43
- const includeSet = options.include ? new Set(options.include) : null;
44
- const excludeSet = options.exclude ? new Set(options.exclude) : null;
45
- return Object.entries(args)
46
- .filter(([key]) => args[key] !== undefined)
47
- .filter(([key]) => {
48
- if (includeSet)
49
- return includeSet.has(key);
50
- if (excludeSet)
51
- return !excludeSet.has(key);
52
- return true;
53
- })
54
- .map(([key, value]) => typeof value === 'function'
55
- ? `(${key})="${(0, ComputesTemplateFromComponent_1.formatPropInTemplate)(key)}($event)"`
56
- : `[${key}]="${(0, ComputesTemplateFromComponent_1.formatPropInTemplate)(key)}"`)
57
- .join(' ');
58
- }
@@ -1,55 +0,0 @@
1
- import { formatPropInTemplate } from './angular-beta/ComputesTemplateFromComponent';
2
- /**
3
- * Converts an object of arguments to a string of property and event bindings and excludes undefined
4
- * values. Why? Because Angular treats undefined values in property bindings as an actual value and
5
- * does not apply the default value of the property as soon as the binding is set. This feels
6
- * counter-intuitive and is a common source of bugs in stories.
7
- *
8
- * @example
9
- *
10
- * ```ts
11
- * // component.ts
12
- * ㅤ@Component({ selector: 'example' })
13
- * export class ExampleComponent {
14
- * ㅤ@Input() input1: string = 'Default Input1';
15
- * ㅤ@Input() input2: string = 'Default Input2';
16
- * ㅤ@Output() click = new EventEmitter();
17
- * }
18
- *
19
- * // component.stories.ts
20
- * import { argsToTemplate } from '@storybook/angular';
21
- * export const Input1: Story = {
22
- * render: (args) => ({
23
- * props: args,
24
- * // Problem1: <example [input1]="input1" [input2]="input2" (click)="click($event)"></example>
25
- * // This will set input2 to undefined and the internal default value will not be used.
26
- * // Problem2: <example [input1]="input1" (click)="click($event)"></example>
27
- * // The default value of input2 will be used, but it is not overridable by the user via controls.
28
- * // Solution: Now the controls will be applicable to both input1 and input2, and the default values will be used if the user does not override them.
29
- * template: `<example ${argsToTemplate(args)}"></example>`,
30
- * }),
31
- * args: {
32
- * // In this Story, we want to set the input1 property, and the internal default property of input2 should be used.
33
- * input1: 'Input 1',
34
- * click: { action: 'clicked' },
35
- * },
36
- * };
37
- * ```
38
- */
39
- export function argsToTemplate(args, options = {}) {
40
- const includeSet = options.include ? new Set(options.include) : null;
41
- const excludeSet = options.exclude ? new Set(options.exclude) : null;
42
- return Object.entries(args)
43
- .filter(([key]) => args[key] !== undefined)
44
- .filter(([key]) => {
45
- if (includeSet)
46
- return includeSet.has(key);
47
- if (excludeSet)
48
- return !excludeSet.has(key);
49
- return true;
50
- })
51
- .map(([key, value]) => typeof value === 'function'
52
- ? `(${key})="${formatPropInTemplate(key)}($event)"`
53
- : `[${key}]="${formatPropInTemplate(key)}"`)
54
- .join(' ');
55
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,102 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const vitest_1 = require("vitest");
4
- const argsToTemplate_1 = require("./argsToTemplate");
5
- // adjust path
6
- (0, vitest_1.describe)('argsToTemplate', () => {
7
- (0, vitest_1.it)('should correctly convert args to template string and exclude undefined values', () => {
8
- const args = {
9
- prop1: 'value1',
10
- prop2: undefined,
11
- prop3: 'value3',
12
- };
13
- const options = {};
14
- const result = (0, argsToTemplate_1.argsToTemplate)(args, options);
15
- (0, vitest_1.expect)(result).toBe('[prop1]="prop1" [prop3]="prop3"');
16
- });
17
- (0, vitest_1.it)('should include properties from include option', () => {
18
- const args = {
19
- prop1: 'value1',
20
- prop2: 'value2',
21
- prop3: 'value3',
22
- };
23
- const options = {
24
- include: ['prop1', 'prop3'],
25
- };
26
- const result = (0, argsToTemplate_1.argsToTemplate)(args, options);
27
- (0, vitest_1.expect)(result).toBe('[prop1]="prop1" [prop3]="prop3"');
28
- });
29
- (0, vitest_1.it)('should include non-undefined properties from include option', () => {
30
- const args = {
31
- prop1: 'value1',
32
- prop2: 'value2',
33
- prop3: undefined,
34
- };
35
- const options = {
36
- include: ['prop1', 'prop3'],
37
- };
38
- const result = (0, argsToTemplate_1.argsToTemplate)(args, options);
39
- (0, vitest_1.expect)(result).toBe('[prop1]="prop1"');
40
- });
41
- (0, vitest_1.it)('should exclude properties from exclude option', () => {
42
- const args = {
43
- prop1: 'value1',
44
- prop2: 'value2',
45
- prop3: 'value3',
46
- };
47
- const options = {
48
- exclude: ['prop2'],
49
- };
50
- const result = (0, argsToTemplate_1.argsToTemplate)(args, options);
51
- (0, vitest_1.expect)(result).toBe('[prop1]="prop1" [prop3]="prop3"');
52
- });
53
- (0, vitest_1.it)('should exclude properties from exclude option and undefined properties', () => {
54
- const args = {
55
- prop1: 'value1',
56
- prop2: 'value2',
57
- prop3: undefined,
58
- };
59
- const options = {
60
- exclude: ['prop2'],
61
- };
62
- const result = (0, argsToTemplate_1.argsToTemplate)(args, options);
63
- (0, vitest_1.expect)(result).toBe('[prop1]="prop1"');
64
- });
65
- (0, vitest_1.it)('should prioritize include over exclude when both options are given', () => {
66
- const args = {
67
- prop1: 'value1',
68
- prop2: 'value2',
69
- prop3: 'value3',
70
- };
71
- const options = {
72
- include: ['prop1', 'prop2'],
73
- exclude: ['prop2', 'prop3'],
74
- };
75
- const result = (0, argsToTemplate_1.argsToTemplate)(args, options);
76
- (0, vitest_1.expect)(result).toBe('[prop1]="prop1" [prop2]="prop2"');
77
- });
78
- (0, vitest_1.it)('should work when neither include nor exclude options are given', () => {
79
- const args = {
80
- prop1: 'value1',
81
- prop2: 'value2',
82
- };
83
- const options = {};
84
- const result = (0, argsToTemplate_1.argsToTemplate)(args, options);
85
- (0, vitest_1.expect)(result).toBe('[prop1]="prop1" [prop2]="prop2"');
86
- });
87
- (0, vitest_1.it)('should bind events correctly when value is a function', () => {
88
- const args = { event1: () => { }, event2: () => { } };
89
- const result = (0, argsToTemplate_1.argsToTemplate)(args, {});
90
- (0, vitest_1.expect)(result).toEqual('(event1)="event1($event)" (event2)="event2($event)"');
91
- });
92
- (0, vitest_1.it)('should mix properties and events correctly', () => {
93
- const args = { input: 'Value1', event1: () => { } };
94
- const result = (0, argsToTemplate_1.argsToTemplate)(args, {});
95
- (0, vitest_1.expect)(result).toEqual('[input]="input" (event1)="event1($event)"');
96
- });
97
- (0, vitest_1.it)('should format for non dot notation', () => {
98
- const args = { 'non-dot': 'Value1', 'dash-out': () => { } };
99
- const result = (0, argsToTemplate_1.argsToTemplate)(args, {});
100
- (0, vitest_1.expect)(result).toEqual('[non-dot]="this[\'non-dot\']" (dash-out)="this[\'dash-out\']($event)"');
101
- });
102
- });
@@ -1,100 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { argsToTemplate } from './argsToTemplate';
3
- // adjust path
4
- describe('argsToTemplate', () => {
5
- it('should correctly convert args to template string and exclude undefined values', () => {
6
- const args = {
7
- prop1: 'value1',
8
- prop2: undefined,
9
- prop3: 'value3',
10
- };
11
- const options = {};
12
- const result = argsToTemplate(args, options);
13
- expect(result).toBe('[prop1]="prop1" [prop3]="prop3"');
14
- });
15
- it('should include properties from include option', () => {
16
- const args = {
17
- prop1: 'value1',
18
- prop2: 'value2',
19
- prop3: 'value3',
20
- };
21
- const options = {
22
- include: ['prop1', 'prop3'],
23
- };
24
- const result = argsToTemplate(args, options);
25
- expect(result).toBe('[prop1]="prop1" [prop3]="prop3"');
26
- });
27
- it('should include non-undefined properties from include option', () => {
28
- const args = {
29
- prop1: 'value1',
30
- prop2: 'value2',
31
- prop3: undefined,
32
- };
33
- const options = {
34
- include: ['prop1', 'prop3'],
35
- };
36
- const result = argsToTemplate(args, options);
37
- expect(result).toBe('[prop1]="prop1"');
38
- });
39
- it('should exclude properties from exclude option', () => {
40
- const args = {
41
- prop1: 'value1',
42
- prop2: 'value2',
43
- prop3: 'value3',
44
- };
45
- const options = {
46
- exclude: ['prop2'],
47
- };
48
- const result = argsToTemplate(args, options);
49
- expect(result).toBe('[prop1]="prop1" [prop3]="prop3"');
50
- });
51
- it('should exclude properties from exclude option and undefined properties', () => {
52
- const args = {
53
- prop1: 'value1',
54
- prop2: 'value2',
55
- prop3: undefined,
56
- };
57
- const options = {
58
- exclude: ['prop2'],
59
- };
60
- const result = argsToTemplate(args, options);
61
- expect(result).toBe('[prop1]="prop1"');
62
- });
63
- it('should prioritize include over exclude when both options are given', () => {
64
- const args = {
65
- prop1: 'value1',
66
- prop2: 'value2',
67
- prop3: 'value3',
68
- };
69
- const options = {
70
- include: ['prop1', 'prop2'],
71
- exclude: ['prop2', 'prop3'],
72
- };
73
- const result = argsToTemplate(args, options);
74
- expect(result).toBe('[prop1]="prop1" [prop2]="prop2"');
75
- });
76
- it('should work when neither include nor exclude options are given', () => {
77
- const args = {
78
- prop1: 'value1',
79
- prop2: 'value2',
80
- };
81
- const options = {};
82
- const result = argsToTemplate(args, options);
83
- expect(result).toBe('[prop1]="prop1" [prop2]="prop2"');
84
- });
85
- it('should bind events correctly when value is a function', () => {
86
- const args = { event1: () => { }, event2: () => { } };
87
- const result = argsToTemplate(args, {});
88
- expect(result).toEqual('(event1)="event1($event)" (event2)="event2($event)"');
89
- });
90
- it('should mix properties and events correctly', () => {
91
- const args = { input: 'Value1', event1: () => { } };
92
- const result = argsToTemplate(args, {});
93
- expect(result).toEqual('[input]="input" (event1)="event1($event)"');
94
- });
95
- it('should format for non dot notation', () => {
96
- const args = { 'non-dot': 'Value1', 'dash-out': () => { } };
97
- const result = argsToTemplate(args, {});
98
- expect(result).toEqual('[non-dot]="this[\'non-dot\']" (dash-out)="this[\'dash-out\']($event)"');
99
- });
100
- });