@storybook/angular 0.0.0-pr-23609-sha-f47ef339

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 (280) hide show
  1. package/.eslintrc.js +8 -0
  2. package/README.md +322 -0
  3. package/dist/builders/build-storybook/index.js +72 -0
  4. package/dist/builders/build-storybook/index.spec.d.ts +1 -0
  5. package/dist/builders/build-storybook/index.spec.js +216 -0
  6. package/dist/builders/build-storybook/schema.json +167 -0
  7. package/dist/builders/builders.json +14 -0
  8. package/dist/builders/start-storybook/index.js +93 -0
  9. package/dist/builders/start-storybook/index.spec.d.ts +1 -0
  10. package/dist/builders/start-storybook/index.spec.js +215 -0
  11. package/dist/builders/start-storybook/schema.json +198 -0
  12. package/dist/builders/utils/error-handler.d.ts +2 -0
  13. package/dist/builders/utils/error-handler.js +38 -0
  14. package/dist/builders/utils/run-compodoc.d.ts +6 -0
  15. package/dist/builders/utils/run-compodoc.js +58 -0
  16. package/dist/builders/utils/run-compodoc.spec.d.ts +1 -0
  17. package/dist/builders/utils/run-compodoc.spec.js +86 -0
  18. package/dist/builders/utils/standalone-options.d.ts +15 -0
  19. package/dist/builders/utils/standalone-options.js +2 -0
  20. package/dist/client/angular-beta/AbstractRenderer.d.ts +53 -0
  21. package/dist/client/angular-beta/AbstractRenderer.js +180 -0
  22. package/dist/client/angular-beta/CanvasRenderer.d.ts +13 -0
  23. package/dist/client/angular-beta/CanvasRenderer.js +16 -0
  24. package/dist/client/angular-beta/ComputesTemplateFromComponent.d.ts +17 -0
  25. package/dist/client/angular-beta/ComputesTemplateFromComponent.js +132 -0
  26. package/dist/client/angular-beta/ComputesTemplateFromComponent.test.d.ts +1 -0
  27. package/dist/client/angular-beta/ComputesTemplateFromComponent.test.js +403 -0
  28. package/dist/client/angular-beta/DocsRenderer.d.ts +13 -0
  29. package/dist/client/angular-beta/DocsRenderer.js +40 -0
  30. package/dist/client/angular-beta/RendererFactory.d.ts +11 -0
  31. package/dist/client/angular-beta/RendererFactory.js +56 -0
  32. package/dist/client/angular-beta/RendererFactory.test.d.ts +1 -0
  33. package/dist/client/angular-beta/RendererFactory.test.js +164 -0
  34. package/dist/client/angular-beta/StorybookModule.d.ts +8 -0
  35. package/dist/client/angular-beta/StorybookModule.js +29 -0
  36. package/dist/client/angular-beta/StorybookModule.test.d.ts +1 -0
  37. package/dist/client/angular-beta/StorybookModule.test.js +311 -0
  38. package/dist/client/angular-beta/StorybookProvider.d.ts +5 -0
  39. package/dist/client/angular-beta/StorybookProvider.js +26 -0
  40. package/dist/client/angular-beta/StorybookWrapperComponent.d.ts +16 -0
  41. package/dist/client/angular-beta/StorybookWrapperComponent.js +140 -0
  42. package/dist/client/angular-beta/__testfixtures__/input.component.d.ts +26 -0
  43. package/dist/client/angular-beta/__testfixtures__/input.component.js +67 -0
  44. package/dist/client/angular-beta/__testfixtures__/test.module.d.ts +2 -0
  45. package/dist/client/angular-beta/__testfixtures__/test.module.js +20 -0
  46. package/dist/client/angular-beta/utils/NgComponentAnalyzer.d.ts +29 -0
  47. package/dist/client/angular-beta/utils/NgComponentAnalyzer.js +100 -0
  48. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.d.ts +1 -0
  49. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.js +374 -0
  50. package/dist/client/angular-beta/utils/NgModulesAnalyzer.d.ts +6 -0
  51. package/dist/client/angular-beta/utils/NgModulesAnalyzer.js +41 -0
  52. package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.d.ts +1 -0
  53. package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.js +23 -0
  54. package/dist/client/angular-beta/utils/PropertyExtractor.d.ts +32 -0
  55. package/dist/client/angular-beta/utils/PropertyExtractor.js +162 -0
  56. package/dist/client/angular-beta/utils/PropertyExtractor.test.d.ts +1 -0
  57. package/dist/client/angular-beta/utils/PropertyExtractor.test.js +142 -0
  58. package/dist/client/config.d.ts +6 -0
  59. package/dist/client/config.js +10 -0
  60. package/dist/client/decorateStory.d.ts +4 -0
  61. package/dist/client/decorateStory.js +49 -0
  62. package/dist/client/decorateStory.test.d.ts +1 -0
  63. package/dist/client/decorateStory.test.js +304 -0
  64. package/dist/client/decorators.d.ts +14 -0
  65. package/dist/client/decorators.js +70 -0
  66. package/dist/client/decorators.test.d.ts +1 -0
  67. package/dist/client/decorators.test.js +146 -0
  68. package/dist/client/docs/__testfixtures__/doc-button/input.d.ts +111 -0
  69. package/dist/client/docs/__testfixtures__/doc-button/input.js +207 -0
  70. package/dist/client/docs/__testfixtures__/doc-button/tsconfig.json +7 -0
  71. package/dist/client/docs/angular-properties.test.d.ts +1 -0
  72. package/dist/client/docs/angular-properties.test.js +62 -0
  73. package/dist/client/docs/compodoc.d.ts +12 -0
  74. package/dist/client/docs/compodoc.js +258 -0
  75. package/dist/client/docs/compodoc.test.d.ts +1 -0
  76. package/dist/client/docs/compodoc.test.js +131 -0
  77. package/dist/client/docs/config.d.ts +4 -0
  78. package/dist/client/docs/config.js +19 -0
  79. package/dist/client/docs/index.d.ts +1 -0
  80. package/dist/client/docs/index.js +17 -0
  81. package/dist/client/docs/sourceDecorator.d.ts +9 -0
  82. package/dist/client/docs/sourceDecorator.js +51 -0
  83. package/dist/client/docs/types.d.ts +102 -0
  84. package/dist/client/docs/types.js +2 -0
  85. package/dist/client/globals.d.ts +23 -0
  86. package/dist/client/globals.js +40 -0
  87. package/dist/client/index.d.ts +5 -0
  88. package/dist/client/index.js +30 -0
  89. package/dist/client/preview-prod.d.ts +1 -0
  90. package/dist/client/preview-prod.js +4 -0
  91. package/dist/client/public-api.d.ts +15 -0
  92. package/dist/client/public-api.js +36 -0
  93. package/dist/client/public-types.d.ts +37 -0
  94. package/dist/client/public-types.js +2 -0
  95. package/dist/client/render.d.ts +7 -0
  96. package/dist/client/render.js +19 -0
  97. package/dist/client/types.d.ts +46 -0
  98. package/dist/client/types.js +2 -0
  99. package/dist/index.d.ts +2 -0
  100. package/dist/index.js +29 -0
  101. package/dist/index.mjs +13 -0
  102. package/dist/preset.d.ts +6 -0
  103. package/dist/preset.js +36 -0
  104. package/dist/preset.mjs +30 -0
  105. package/dist/renderer.d.ts +6 -0
  106. package/dist/renderer.js +15 -0
  107. package/dist/renderer.mjs +6 -0
  108. package/dist/server/__mocks-ng-workspace__/empty-projects-entry/angular.json +4 -0
  109. package/dist/server/__mocks-ng-workspace__/minimal-config/angular.json +18 -0
  110. package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.d.ts +1 -0
  111. package/dist/server/__mocks-ng-workspace__/minimal-config/src/main.js +5 -0
  112. package/dist/server/__mocks-ng-workspace__/minimal-config/src/tsconfig.app.json +9 -0
  113. package/dist/server/__mocks-ng-workspace__/minimal-config/tsconfig.json +13 -0
  114. package/dist/server/__mocks-ng-workspace__/some-config/angular.json +19 -0
  115. package/dist/server/__mocks-ng-workspace__/some-config/src/main.d.ts +1 -0
  116. package/dist/server/__mocks-ng-workspace__/some-config/src/main.js +5 -0
  117. package/dist/server/__mocks-ng-workspace__/some-config/src/tsconfig.app.json +9 -0
  118. package/dist/server/__mocks-ng-workspace__/some-config/tsconfig.json +13 -0
  119. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/angular.json +64 -0
  120. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.d.ts +1 -0
  121. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/main.js +5 -0
  122. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/src/tsconfig.app.json +9 -0
  123. package/dist/server/__mocks-ng-workspace__/with-angularBrowserTarget/tsconfig.json +13 -0
  124. package/dist/server/__mocks-ng-workspace__/with-lib/angular.json +28 -0
  125. package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.d.ts +1 -0
  126. package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/src/main.js +5 -0
  127. package/dist/server/__mocks-ng-workspace__/with-lib/projects/pattern-lib/tsconfig.lib.json +20 -0
  128. package/dist/server/__mocks-ng-workspace__/with-lib/tsconfig.json +13 -0
  129. package/dist/server/__mocks-ng-workspace__/with-nx/angular.json +18 -0
  130. package/dist/server/__mocks-ng-workspace__/with-nx/nx.json +3 -0
  131. package/dist/server/__mocks-ng-workspace__/with-nx/src/main.d.ts +1 -0
  132. package/dist/server/__mocks-ng-workspace__/with-nx/src/main.js +5 -0
  133. package/dist/server/__mocks-ng-workspace__/with-nx/src/tsconfig.app.json +8 -0
  134. package/dist/server/__mocks-ng-workspace__/with-nx/tsconfig.json +14 -0
  135. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/nx.json +3 -0
  136. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.d.ts +1 -0
  137. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/main.js +5 -0
  138. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/src/tsconfig.app.json +8 -0
  139. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/tsconfig.json +14 -0
  140. package/dist/server/__mocks-ng-workspace__/with-nx-workspace/workspace.json +18 -0
  141. package/dist/server/__mocks-ng-workspace__/with-options-styles/angular.json +18 -0
  142. package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.d.ts +1 -0
  143. package/dist/server/__mocks-ng-workspace__/with-options-styles/src/main.js +5 -0
  144. package/dist/server/__mocks-ng-workspace__/with-options-styles/src/tsconfig.app.json +9 -0
  145. package/dist/server/__mocks-ng-workspace__/with-options-styles/tsconfig.json +13 -0
  146. package/dist/server/__mocks-ng-workspace__/without-architect-build/angular.json +5 -0
  147. package/dist/server/__mocks-ng-workspace__/without-architect-build-options/angular.json +11 -0
  148. package/dist/server/__mocks-ng-workspace__/without-compatible-projects/angular.json +7 -0
  149. package/dist/server/__mocks-ng-workspace__/without-projects-entry/angular.json +3 -0
  150. package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.d.ts +1 -0
  151. package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/src/main.js +5 -0
  152. package/dist/server/__mocks-ng-workspace__/without-projects-entry/projects/pattern-lib/tsconfig.lib.json +20 -0
  153. package/dist/server/__mocks-ng-workspace__/without-projects-entry/tsconfig.json +13 -0
  154. package/dist/server/__mocks-ng-workspace__/without-tsConfig/angular.json +16 -0
  155. package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.d.ts +1 -0
  156. package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/main.js +5 -0
  157. package/dist/server/__mocks-ng-workspace__/without-tsConfig/src/tsconfig.app.json +9 -0
  158. package/dist/server/__mocks-ng-workspace__/without-tsConfig/tsconfig.json +13 -0
  159. package/dist/server/__tests__/angular.json +96 -0
  160. package/dist/server/angular-cli-webpack.d.ts +1 -0
  161. package/dist/server/angular-cli-webpack.js +99 -0
  162. package/dist/server/framework-preset-angular-cli.d.ts +4 -0
  163. package/dist/server/framework-preset-angular-cli.js +85 -0
  164. package/dist/server/framework-preset-angular-docs.d.ts +2 -0
  165. package/dist/server/framework-preset-angular-docs.js +10 -0
  166. package/dist/server/framework-preset-angular-ivy.d.ts +10 -0
  167. package/dist/server/framework-preset-angular-ivy.js +103 -0
  168. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.d.ts +25 -0
  169. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.js +48 -0
  170. package/dist/server/preset-options.d.ts +13 -0
  171. package/dist/server/preset-options.js +2 -0
  172. package/dist/server/utils/filter-out-styling-rules.d.ts +2 -0
  173. package/dist/server/utils/filter-out-styling-rules.js +17 -0
  174. package/dist/server/utils/module-is-available.d.ts +1 -0
  175. package/dist/server/utils/module-is-available.js +13 -0
  176. package/dist/types.d.ts +29 -0
  177. package/dist/types.js +2 -0
  178. package/dist/types.mjs +1 -0
  179. package/jest.config.js +31 -0
  180. package/package.json +126 -0
  181. package/preset.js +1 -0
  182. package/renderer.d.ts +1 -0
  183. package/renderer.js +1 -0
  184. package/src/server/angular-cli-webpack.d.ts +7 -0
  185. package/src/server/angular-cli-webpack.js +127 -0
  186. package/src/server/plugins/storybook-normalize-angular-entry-plugin.js +54 -0
  187. package/src/typings.d.ts +21 -0
  188. package/template/cli/.eslintrc.json +5 -0
  189. package/template/cli/Button.stories.ts +51 -0
  190. package/template/cli/Header.stories.ts +37 -0
  191. package/template/cli/Page.stories.ts +46 -0
  192. package/template/cli/User.ts +2 -0
  193. package/template/cli/button.component.ts +55 -0
  194. package/template/cli/header.component.ts +75 -0
  195. package/template/cli/page.component.ts +77 -0
  196. package/template/components/button.component.ts +54 -0
  197. package/template/components/button.css +30 -0
  198. package/template/components/form.component.ts +37 -0
  199. package/template/components/html.component.ts +22 -0
  200. package/template/components/index.js +8 -0
  201. package/template/components/pre.component.ts +29 -0
  202. package/template/stories/angular-mdx.stories.mdx +25 -0
  203. package/template/stories/argTypes/doc-button/doc-button.component.html +7 -0
  204. package/template/stories/argTypes/doc-button/doc-button.component.scss +3 -0
  205. package/template/stories/argTypes/doc-button/doc-button.component.ts +232 -0
  206. package/template/stories/argTypes/doc-button/doc-button.stories.ts +24 -0
  207. package/template/stories/argTypes/doc-directive/doc-directive.directive.ts +24 -0
  208. package/template/stories/argTypes/doc-directive/doc-directive.stories.ts +14 -0
  209. package/template/stories/argTypes/doc-injectable/doc-injectable.service.ts +27 -0
  210. package/template/stories/argTypes/doc-injectable/doc-injectable.stories.ts +17 -0
  211. package/template/stories/argTypes/doc-pipe/doc-pipe.pipe.ts +18 -0
  212. package/template/stories/argTypes/doc-pipe/doc-pipe.stories.ts +17 -0
  213. package/template/stories/basics/README.stories.mdx +7 -0
  214. package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva-component.stories.ts +27 -0
  215. package/template/stories/basics/angular-forms/customControlValueAccessor/custom-cva.component.ts +57 -0
  216. package/template/stories/basics/component-with-complex-selectors/attribute-selector.component.ts +19 -0
  217. package/template/stories/basics/component-with-complex-selectors/attribute-selectors.component.stories.ts +8 -0
  218. package/template/stories/basics/component-with-complex-selectors/class-selector.component.stories.ts +8 -0
  219. package/template/stories/basics/component-with-complex-selectors/class-selector.component.ts +19 -0
  220. package/template/stories/basics/component-with-complex-selectors/multiple-class-selector.component.stories.ts +8 -0
  221. package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.stories.ts +8 -0
  222. package/template/stories/basics/component-with-complex-selectors/multiple-selector.component.ts +37 -0
  223. package/template/stories/basics/component-with-enums/enums.component.html +8 -0
  224. package/template/stories/basics/component-with-enums/enums.component.stories.ts +24 -0
  225. package/template/stories/basics/component-with-enums/enums.component.ts +53 -0
  226. package/template/stories/basics/component-with-inheritance/base-button.component.ts +10 -0
  227. package/template/stories/basics/component-with-inheritance/base-button.stories.ts +12 -0
  228. package/template/stories/basics/component-with-inheritance/icon-button.component.ts +11 -0
  229. package/template/stories/basics/component-with-inheritance/icon-button.stories.ts +13 -0
  230. package/template/stories/basics/component-with-ng-content/ng-content-about-parent.stories.ts +58 -0
  231. package/template/stories/basics/component-with-ng-content/ng-content-simple.stories.ts +29 -0
  232. package/template/stories/basics/component-with-ng-on-destroy/component-with-on-destroy.stories.ts +40 -0
  233. package/template/stories/basics/component-with-on-push/on-push-box.component.ts +21 -0
  234. package/template/stories/basics/component-with-on-push/on-push.stories.ts +21 -0
  235. package/template/stories/basics/component-with-pipe/custom-pipes.stories.ts +31 -0
  236. package/template/stories/basics/component-with-pipe/custom.pipe.ts +10 -0
  237. package/template/stories/basics/component-with-pipe/with-pipe.component.ts +10 -0
  238. package/template/stories/basics/component-with-provider/di.component.html +7 -0
  239. package/template/stories/basics/component-with-provider/di.component.stories.ts +26 -0
  240. package/template/stories/basics/component-with-provider/di.component.ts +28 -0
  241. package/template/stories/basics/component-with-style/styled.component.css +3 -0
  242. package/template/stories/basics/component-with-style/styled.component.html +5 -0
  243. package/template/stories/basics/component-with-style/styled.component.scss +5 -0
  244. package/template/stories/basics/component-with-style/styled.component.stories.ts +10 -0
  245. package/template/stories/basics/component-with-style/styled.component.ts +8 -0
  246. package/template/stories/basics/component-without-selector/without-selector-ng-component-outlet.stories.ts +73 -0
  247. package/template/stories/basics/component-without-selector/without-selector-ng-factory-resolver.stories.ts +71 -0
  248. package/template/stories/basics/component-without-selector/without-selector.component.ts +30 -0
  249. package/template/stories/basics/component-without-selector/without-selector.stories.ts +30 -0
  250. package/template/stories/basics/ng-module/angular-src/chip-color.token.ts +3 -0
  251. package/template/stories/basics/ng-module/angular-src/chip-text.pipe.ts +29 -0
  252. package/template/stories/basics/ng-module/angular-src/chip.component.ts +60 -0
  253. package/template/stories/basics/ng-module/angular-src/chips-group.component.ts +49 -0
  254. package/template/stories/basics/ng-module/angular-src/chips.module.ts +31 -0
  255. package/template/stories/basics/ng-module/import-module-chip.stories.ts +23 -0
  256. package/template/stories/basics/ng-module/import-module-for-root.stories.ts +50 -0
  257. package/template/stories/basics/ng-module/import-module.stories.ts +35 -0
  258. package/template/stories/button.component.ts +26 -0
  259. package/template/stories/core/README.stories.mdx +7 -0
  260. package/template/stories/core/applicationConfig/with-browser-animations.stories.ts +40 -0
  261. package/template/stories/core/applicationConfig/with-noop-browser-animations.stories.ts +35 -0
  262. package/template/stories/core/decorators/componentWrapperDecorator/child.component.ts +20 -0
  263. package/template/stories/core/decorators/componentWrapperDecorator/decorators.stories.ts +99 -0
  264. package/template/stories/core/decorators/componentWrapperDecorator/parent.component.ts +18 -0
  265. package/template/stories/core/decorators/theme-decorator/decorators.stories.ts +20 -0
  266. package/template/stories/core/moduleMetadata/angular-src/custom.pipe.ts +10 -0
  267. package/template/stories/core/moduleMetadata/angular-src/dummy.service.ts +14 -0
  268. package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.css +13 -0
  269. package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.html +7 -0
  270. package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.ts +39 -0
  271. package/template/stories/core/moduleMetadata/angular-src/service.component.ts +24 -0
  272. package/template/stories/core/moduleMetadata/angular-src/token.component.ts +31 -0
  273. package/template/stories/core/moduleMetadata/in-export-default.stories.ts +38 -0
  274. package/template/stories/core/moduleMetadata/in-stories.stories.ts +46 -0
  275. package/template/stories/core/moduleMetadata/merge-default-and-story.stories.ts +35 -0
  276. package/template/stories/core/parameters/bootstrap-options.stories.ts +18 -0
  277. package/template/stories/core/styles/story-styles.stories.ts +50 -0
  278. package/template/stories/others/app-initializer-use-factory/app-initializer-use-factory.stories.ts +34 -0
  279. package/template/stories/others/issues/12009-unknown-component.stories.ts +14 -0
  280. package/template/stories/others/ngx-translate/README.stories.mdx +65 -0
@@ -0,0 +1,374 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const core_1 = require("@angular/core");
13
+ const testing_1 = require("@angular/core/testing");
14
+ const testing_2 = require("@angular/platform-browser-dynamic/testing");
15
+ const NgComponentAnalyzer_1 = require("./NgComponentAnalyzer");
16
+ describe('getComponentInputsOutputs', () => {
17
+ it('should return empty if no I/O found', () => {
18
+ let FooComponent = class FooComponent {
19
+ };
20
+ FooComponent = __decorate([
21
+ (0, core_1.Component)({})
22
+ ], FooComponent);
23
+ expect((0, NgComponentAnalyzer_1.getComponentInputsOutputs)(FooComponent)).toEqual({
24
+ inputs: [],
25
+ outputs: [],
26
+ });
27
+ class BarComponent {
28
+ }
29
+ expect((0, NgComponentAnalyzer_1.getComponentInputsOutputs)(BarComponent)).toEqual({
30
+ inputs: [],
31
+ outputs: [],
32
+ });
33
+ });
34
+ it('should return I/O', () => {
35
+ let FooComponent = class FooComponent {
36
+ constructor() {
37
+ this.output = new core_1.EventEmitter();
38
+ this.outputWithBindingPropertyName = new core_1.EventEmitter();
39
+ }
40
+ };
41
+ __decorate([
42
+ (0, core_1.Input)(),
43
+ __metadata("design:type", String)
44
+ ], FooComponent.prototype, "input", void 0);
45
+ __decorate([
46
+ (0, core_1.Input)('inputPropertyName'),
47
+ __metadata("design:type", String)
48
+ ], FooComponent.prototype, "inputWithBindingPropertyName", void 0);
49
+ __decorate([
50
+ (0, core_1.Output)(),
51
+ __metadata("design:type", Object)
52
+ ], FooComponent.prototype, "output", void 0);
53
+ __decorate([
54
+ (0, core_1.Output)('outputPropertyName'),
55
+ __metadata("design:type", Object)
56
+ ], FooComponent.prototype, "outputWithBindingPropertyName", void 0);
57
+ FooComponent = __decorate([
58
+ (0, core_1.Component)({
59
+ template: '',
60
+ inputs: ['inputInComponentMetadata'],
61
+ outputs: ['outputInComponentMetadata'],
62
+ })
63
+ ], FooComponent);
64
+ const fooComponentFactory = resolveComponentFactory(FooComponent);
65
+ const { inputs, outputs } = (0, NgComponentAnalyzer_1.getComponentInputsOutputs)(FooComponent);
66
+ expect({ inputs, outputs }).toEqual({
67
+ inputs: [
68
+ { propName: 'inputInComponentMetadata', templateName: 'inputInComponentMetadata' },
69
+ { propName: 'input', templateName: 'input' },
70
+ { propName: 'inputWithBindingPropertyName', templateName: 'inputPropertyName' },
71
+ ],
72
+ outputs: [
73
+ { propName: 'outputInComponentMetadata', templateName: 'outputInComponentMetadata' },
74
+ { propName: 'output', templateName: 'output' },
75
+ { propName: 'outputWithBindingPropertyName', templateName: 'outputPropertyName' },
76
+ ],
77
+ });
78
+ expect(sortByPropName(inputs)).toEqual(sortByPropName(fooComponentFactory.inputs));
79
+ expect(sortByPropName(outputs)).toEqual(sortByPropName(fooComponentFactory.outputs));
80
+ });
81
+ it("should return I/O when some of component metadata has the same name as one of component's properties", () => {
82
+ let FooComponent = class FooComponent {
83
+ constructor() {
84
+ this.output = new core_1.EventEmitter();
85
+ this.outputWithBindingPropertyName = new core_1.EventEmitter();
86
+ }
87
+ };
88
+ __decorate([
89
+ (0, core_1.Input)(),
90
+ __metadata("design:type", String)
91
+ ], FooComponent.prototype, "input", void 0);
92
+ __decorate([
93
+ (0, core_1.Input)('inputPropertyName'),
94
+ __metadata("design:type", String)
95
+ ], FooComponent.prototype, "inputWithBindingPropertyName", void 0);
96
+ __decorate([
97
+ (0, core_1.Output)(),
98
+ __metadata("design:type", Object)
99
+ ], FooComponent.prototype, "output", void 0);
100
+ __decorate([
101
+ (0, core_1.Output)('outputPropertyName'),
102
+ __metadata("design:type", Object)
103
+ ], FooComponent.prototype, "outputWithBindingPropertyName", void 0);
104
+ FooComponent = __decorate([
105
+ (0, core_1.Component)({
106
+ template: '',
107
+ inputs: ['input', 'inputWithBindingPropertyName'],
108
+ outputs: ['outputWithBindingPropertyName'],
109
+ })
110
+ ], FooComponent);
111
+ const fooComponentFactory = resolveComponentFactory(FooComponent);
112
+ const { inputs, outputs } = (0, NgComponentAnalyzer_1.getComponentInputsOutputs)(FooComponent);
113
+ expect(sortByPropName(inputs)).toEqual(sortByPropName(fooComponentFactory.inputs));
114
+ expect(sortByPropName(outputs)).toEqual(sortByPropName(fooComponentFactory.outputs));
115
+ });
116
+ it('should return I/O in the presence of multiple decorators', () => {
117
+ let FooComponent = class FooComponent {
118
+ };
119
+ __decorate([
120
+ (0, core_1.Input)(),
121
+ (0, core_1.HostBinding)('class.preceeding-first'),
122
+ __metadata("design:type", String)
123
+ ], FooComponent.prototype, "inputPreceedingHostBinding", void 0);
124
+ __decorate([
125
+ (0, core_1.HostBinding)('class.following-binding'),
126
+ (0, core_1.Input)(),
127
+ __metadata("design:type", String)
128
+ ], FooComponent.prototype, "inputFollowingHostBinding", void 0);
129
+ FooComponent = __decorate([
130
+ (0, core_1.Component)({
131
+ template: '',
132
+ })
133
+ ], FooComponent);
134
+ const fooComponentFactory = resolveComponentFactory(FooComponent);
135
+ const { inputs, outputs } = (0, NgComponentAnalyzer_1.getComponentInputsOutputs)(FooComponent);
136
+ expect({ inputs, outputs }).toEqual({
137
+ inputs: [
138
+ { propName: 'inputPreceedingHostBinding', templateName: 'inputPreceedingHostBinding' },
139
+ { propName: 'inputFollowingHostBinding', templateName: 'inputFollowingHostBinding' },
140
+ ],
141
+ outputs: [],
142
+ });
143
+ expect(sortByPropName(inputs)).toEqual(sortByPropName(fooComponentFactory.inputs));
144
+ expect(sortByPropName(outputs)).toEqual(sortByPropName(fooComponentFactory.outputs));
145
+ });
146
+ it('should return I/O with extending classes', () => {
147
+ let BarComponent = class BarComponent {
148
+ };
149
+ __decorate([
150
+ (0, core_1.Input)(),
151
+ __metadata("design:type", String)
152
+ ], BarComponent.prototype, "a", void 0);
153
+ __decorate([
154
+ (0, core_1.Input)(),
155
+ __metadata("design:type", String)
156
+ ], BarComponent.prototype, "b", void 0);
157
+ BarComponent = __decorate([
158
+ (0, core_1.Component)({
159
+ template: '',
160
+ })
161
+ ], BarComponent);
162
+ let FooComponent = class FooComponent extends BarComponent {
163
+ };
164
+ __decorate([
165
+ (0, core_1.Input)(),
166
+ __metadata("design:type", String)
167
+ ], FooComponent.prototype, "b", void 0);
168
+ __decorate([
169
+ (0, core_1.Input)(),
170
+ __metadata("design:type", String)
171
+ ], FooComponent.prototype, "c", void 0);
172
+ FooComponent = __decorate([
173
+ (0, core_1.Component)({
174
+ template: '',
175
+ })
176
+ ], FooComponent);
177
+ const fooComponentFactory = resolveComponentFactory(FooComponent);
178
+ const { inputs, outputs } = (0, NgComponentAnalyzer_1.getComponentInputsOutputs)(FooComponent);
179
+ expect({ inputs, outputs }).toEqual({
180
+ inputs: [
181
+ { propName: 'a', templateName: 'a' },
182
+ { propName: 'b', templateName: 'b' },
183
+ { propName: 'c', templateName: 'c' },
184
+ ],
185
+ outputs: [],
186
+ });
187
+ expect(sortByPropName(inputs)).toEqual(sortByPropName(fooComponentFactory.inputs));
188
+ expect(sortByPropName(outputs)).toEqual(sortByPropName(fooComponentFactory.outputs));
189
+ });
190
+ });
191
+ describe('isDeclarable', () => {
192
+ it('should return true with a Component', () => {
193
+ let FooComponent = class FooComponent {
194
+ };
195
+ FooComponent = __decorate([
196
+ (0, core_1.Component)({})
197
+ ], FooComponent);
198
+ expect((0, NgComponentAnalyzer_1.isDeclarable)(FooComponent)).toEqual(true);
199
+ });
200
+ it('should return true with a Directive', () => {
201
+ let FooDirective = class FooDirective {
202
+ };
203
+ FooDirective = __decorate([
204
+ (0, core_1.Directive)({})
205
+ ], FooDirective);
206
+ expect((0, NgComponentAnalyzer_1.isDeclarable)(FooDirective)).toEqual(true);
207
+ });
208
+ it('should return true with a Pipe', () => {
209
+ let FooPipe = class FooPipe {
210
+ };
211
+ FooPipe = __decorate([
212
+ (0, core_1.Pipe)({ name: 'pipe' })
213
+ ], FooPipe);
214
+ expect((0, NgComponentAnalyzer_1.isDeclarable)(FooPipe)).toEqual(true);
215
+ });
216
+ it('should return false with simple class', () => {
217
+ class FooPipe {
218
+ }
219
+ expect((0, NgComponentAnalyzer_1.isDeclarable)(FooPipe)).toEqual(false);
220
+ });
221
+ it('should return false with Injectable', () => {
222
+ let FooInjectable = class FooInjectable {
223
+ };
224
+ FooInjectable = __decorate([
225
+ (0, core_1.Injectable)()
226
+ ], FooInjectable);
227
+ expect((0, NgComponentAnalyzer_1.isDeclarable)(FooInjectable)).toEqual(false);
228
+ });
229
+ });
230
+ describe('isComponent', () => {
231
+ it('should return true with a Component', () => {
232
+ let FooComponent = class FooComponent {
233
+ };
234
+ FooComponent = __decorate([
235
+ (0, core_1.Component)({})
236
+ ], FooComponent);
237
+ expect((0, NgComponentAnalyzer_1.isComponent)(FooComponent)).toEqual(true);
238
+ });
239
+ it('should return false with simple class', () => {
240
+ class FooPipe {
241
+ }
242
+ expect((0, NgComponentAnalyzer_1.isComponent)(FooPipe)).toEqual(false);
243
+ });
244
+ it('should return false with Directive', () => {
245
+ let FooDirective = class FooDirective {
246
+ };
247
+ FooDirective = __decorate([
248
+ (0, core_1.Directive)()
249
+ ], FooDirective);
250
+ expect((0, NgComponentAnalyzer_1.isComponent)(FooDirective)).toEqual(false);
251
+ });
252
+ });
253
+ describe('isStandaloneComponent', () => {
254
+ it('should return true with a Component with "standalone: true"', () => {
255
+ let FooComponent = class FooComponent {
256
+ };
257
+ FooComponent = __decorate([
258
+ (0, core_1.Component)({ standalone: true })
259
+ ], FooComponent);
260
+ expect((0, NgComponentAnalyzer_1.isStandaloneComponent)(FooComponent)).toEqual(true);
261
+ });
262
+ it('should return false with a Component with "standalone: false"', () => {
263
+ let FooComponent = class FooComponent {
264
+ };
265
+ FooComponent = __decorate([
266
+ (0, core_1.Component)({ standalone: false })
267
+ ], FooComponent);
268
+ expect((0, NgComponentAnalyzer_1.isStandaloneComponent)(FooComponent)).toEqual(false);
269
+ });
270
+ it('should return false with a Component without the "standalone" property', () => {
271
+ let FooComponent = class FooComponent {
272
+ };
273
+ FooComponent = __decorate([
274
+ (0, core_1.Component)({})
275
+ ], FooComponent);
276
+ expect((0, NgComponentAnalyzer_1.isStandaloneComponent)(FooComponent)).toEqual(false);
277
+ });
278
+ it('should return false with simple class', () => {
279
+ class FooPipe {
280
+ }
281
+ expect((0, NgComponentAnalyzer_1.isStandaloneComponent)(FooPipe)).toEqual(false);
282
+ });
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', () => {
300
+ let FooDirective = class FooDirective {
301
+ };
302
+ FooDirective = __decorate([
303
+ (0, core_1.Directive)()
304
+ ], FooDirective);
305
+ expect((0, NgComponentAnalyzer_1.isStandaloneComponent)(FooDirective)).toEqual(false);
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
+ });
333
+ });
334
+ describe('getComponentDecoratorMetadata', () => {
335
+ it('should return Component with a Component', () => {
336
+ let FooComponent = class FooComponent {
337
+ };
338
+ FooComponent = __decorate([
339
+ (0, core_1.Component)({ selector: 'foo' })
340
+ ], FooComponent);
341
+ expect((0, NgComponentAnalyzer_1.getComponentDecoratorMetadata)(FooComponent)).toBeInstanceOf(core_1.Component);
342
+ expect((0, NgComponentAnalyzer_1.getComponentDecoratorMetadata)(FooComponent)).toEqual({
343
+ changeDetection: 1,
344
+ selector: 'foo',
345
+ });
346
+ });
347
+ it('should return Component with extending classes', () => {
348
+ let BarComponent = class BarComponent {
349
+ };
350
+ BarComponent = __decorate([
351
+ (0, core_1.Component)({ selector: 'bar' })
352
+ ], BarComponent);
353
+ let FooComponent = class FooComponent extends BarComponent {
354
+ };
355
+ FooComponent = __decorate([
356
+ (0, core_1.Component)({ selector: 'foo' })
357
+ ], FooComponent);
358
+ expect((0, NgComponentAnalyzer_1.getComponentDecoratorMetadata)(FooComponent)).toBeInstanceOf(core_1.Component);
359
+ expect((0, NgComponentAnalyzer_1.getComponentDecoratorMetadata)(FooComponent)).toEqual({
360
+ changeDetection: 1,
361
+ selector: 'foo',
362
+ });
363
+ });
364
+ });
365
+ function sortByPropName(array) {
366
+ return array.sort((a, b) => a.propName.localeCompare(b.propName));
367
+ }
368
+ function resolveComponentFactory(component) {
369
+ testing_1.TestBed.configureTestingModule({
370
+ declarations: [component],
371
+ }).overrideModule(testing_2.BrowserDynamicTestingModule, {});
372
+ const componentFactoryResolver = testing_1.TestBed.inject(core_1.ComponentFactoryResolver);
373
+ return componentFactoryResolver.resolveComponentFactory(component);
374
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Avoid component redeclaration
3
+ *
4
+ * Checks recursively if the component has already been declared in all import Module
5
+ */
6
+ export declare const isComponentAlreadyDeclared: (componentToFind: any, moduleDeclarations: any[], moduleImports: any[]) => boolean;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isComponentAlreadyDeclared = void 0;
4
+ const core_1 = require("@angular/core");
5
+ const reflectionCapabilities = new core_1.ɵReflectionCapabilities();
6
+ /**
7
+ * Avoid component redeclaration
8
+ *
9
+ * Checks recursively if the component has already been declared in all import Module
10
+ */
11
+ const isComponentAlreadyDeclared = (componentToFind, moduleDeclarations, moduleImports) => {
12
+ if (moduleDeclarations &&
13
+ moduleDeclarations.some((declaration) => declaration === componentToFind)) {
14
+ // Found component in declarations array
15
+ return true;
16
+ }
17
+ if (!moduleImports) {
18
+ return false;
19
+ }
20
+ return moduleImports.some((importItem) => {
21
+ const extractedNgModuleMetadata = extractNgModuleMetadata(importItem);
22
+ if (!extractedNgModuleMetadata) {
23
+ // Not an NgModule
24
+ return false;
25
+ }
26
+ return (0, exports.isComponentAlreadyDeclared)(componentToFind, extractedNgModuleMetadata.declarations, extractedNgModuleMetadata.imports);
27
+ });
28
+ };
29
+ exports.isComponentAlreadyDeclared = isComponentAlreadyDeclared;
30
+ const extractNgModuleMetadata = (importItem) => {
31
+ const target = importItem && importItem.ngModule ? importItem.ngModule : importItem;
32
+ const decorators = reflectionCapabilities.annotations(target);
33
+ if (!decorators || decorators.length === 0) {
34
+ return null;
35
+ }
36
+ const ngModuleDecorator = decorators.find((decorator) => decorator instanceof core_1.NgModule);
37
+ if (!ngModuleDecorator) {
38
+ return null;
39
+ }
40
+ return ngModuleDecorator;
41
+ };
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@angular/core");
4
+ const NgModulesAnalyzer_1 = require("./NgModulesAnalyzer");
5
+ const FooComponent = (0, core_1.Component)({})(class {
6
+ });
7
+ const BarComponent = (0, core_1.Component)({})(class {
8
+ });
9
+ const BetaModule = (0, core_1.NgModule)({ declarations: [FooComponent] })(class {
10
+ });
11
+ const AlphaModule = (0, core_1.NgModule)({ imports: [BetaModule] })(class {
12
+ });
13
+ describe('isComponentAlreadyDeclaredInModules', () => {
14
+ it('should return true when the component is already declared in one of modules', () => {
15
+ expect((0, NgModulesAnalyzer_1.isComponentAlreadyDeclared)(FooComponent, [], [AlphaModule])).toEqual(true);
16
+ });
17
+ it('should return true if the component is in moduleDeclarations', () => {
18
+ expect((0, NgModulesAnalyzer_1.isComponentAlreadyDeclared)(BarComponent, [BarComponent], [AlphaModule])).toEqual(true);
19
+ });
20
+ it('should return false if the component is not declared', () => {
21
+ expect((0, NgModulesAnalyzer_1.isComponentAlreadyDeclared)(BarComponent, [], [AlphaModule])).toEqual(false);
22
+ });
23
+ });
@@ -0,0 +1,32 @@
1
+ import { importProvidersFrom, InjectionToken, NgModule, Provider, ɵReflectionCapabilities as ReflectionCapabilities } from '@angular/core';
2
+ import { NgModuleMetadata } from '../../types';
3
+ export declare const reflectionCapabilities: ReflectionCapabilities;
4
+ export declare const REMOVED_MODULES: InjectionToken<unknown>;
5
+ export declare const uniqueArray: (arr: any[]) => any[];
6
+ export declare class PropertyExtractor implements NgModuleMetadata {
7
+ private metadata;
8
+ private component?;
9
+ declarations?: any[];
10
+ imports?: any[];
11
+ providers?: Provider[];
12
+ applicationProviders?: Array<Provider | ReturnType<typeof importProvidersFrom>>;
13
+ constructor(metadata: NgModuleMetadata, component?: any);
14
+ static warnImportsModuleWithProviders(propertyExtractor: PropertyExtractor): void;
15
+ private init;
16
+ /**
17
+ * Analyze NgModule Metadata
18
+ *
19
+ * - Removes Restricted Imports
20
+ * - Extracts providers from ModuleWithProviders
21
+ * - Returns a new NgModuleMetadata object
22
+ *
23
+ *
24
+ */
25
+ private analyzeMetadata;
26
+ static analyzeRestricted: (ngModule: NgModule) => [boolean] | [boolean, Provider];
27
+ static analyzeDecorators: (component: any) => {
28
+ isDeclarable: boolean;
29
+ isStandalone: boolean;
30
+ };
31
+ static isDecoratorInstanceOf: (decorator: any, name: string) => boolean;
32
+ }
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ var _a;
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.PropertyExtractor = exports.uniqueArray = exports.REMOVED_MODULES = exports.reflectionCapabilities = void 0;
8
+ /* eslint-disable no-console */
9
+ const common_1 = require("@angular/common");
10
+ const core_1 = require("@angular/core");
11
+ const platform_browser_1 = require("@angular/platform-browser");
12
+ const animations_1 = require("@angular/platform-browser/animations");
13
+ const ts_dedent_1 = __importDefault(require("ts-dedent"));
14
+ const NgModulesAnalyzer_1 = require("./NgModulesAnalyzer");
15
+ exports.reflectionCapabilities = new core_1.ɵReflectionCapabilities();
16
+ exports.REMOVED_MODULES = new core_1.InjectionToken('REMOVED_MODULES');
17
+ const uniqueArray = (arr) => {
18
+ return arr
19
+ .flat(Number.MAX_VALUE)
20
+ .filter(Boolean)
21
+ .filter((value, index, self) => self.indexOf(value) === index);
22
+ };
23
+ exports.uniqueArray = uniqueArray;
24
+ class PropertyExtractor {
25
+ /* eslint-enable @typescript-eslint/lines-between-class-members */
26
+ constructor(metadata, component) {
27
+ this.metadata = metadata;
28
+ this.component = component;
29
+ /* eslint-disable @typescript-eslint/lines-between-class-members */
30
+ this.declarations = [];
31
+ /**
32
+ * Analyze NgModule Metadata
33
+ *
34
+ * - Removes Restricted Imports
35
+ * - Extracts providers from ModuleWithProviders
36
+ * - Returns a new NgModuleMetadata object
37
+ *
38
+ *
39
+ */
40
+ this.analyzeMetadata = (metadata) => {
41
+ const declarations = [...(metadata?.declarations || [])];
42
+ const providers = [...(metadata?.providers || [])];
43
+ const applicationProviders = [];
44
+ const imports = [...(metadata?.imports || [])].reduce((acc, imported) => {
45
+ // remove ngModule and use only its providers if it is restricted
46
+ // (e.g. BrowserModule, BrowserAnimationsModule, NoopAnimationsModule, ...etc)
47
+ const [isRestricted, restrictedProviders] = PropertyExtractor.analyzeRestricted(imported);
48
+ if (isRestricted) {
49
+ applicationProviders.unshift(restrictedProviders || []);
50
+ return acc;
51
+ }
52
+ acc.push(imported);
53
+ return acc;
54
+ }, []);
55
+ return { ...metadata, imports, providers, applicationProviders, declarations };
56
+ };
57
+ this.init();
58
+ }
59
+ // With the new way of mounting standalone components to the DOM via bootstrapApplication API,
60
+ // we should now pass ModuleWithProviders to the providers array of the bootstrapApplication function.
61
+ static warnImportsModuleWithProviders(propertyExtractor) {
62
+ const hasModuleWithProvidersImport = propertyExtractor.imports.some((importedModule) => 'ngModule' in importedModule);
63
+ if (hasModuleWithProvidersImport) {
64
+ console.warn((0, ts_dedent_1.default)(`
65
+ Storybook Warning:
66
+ moduleMetadata property 'imports' contains one or more ModuleWithProviders, likely the result of a 'Module.forRoot()'-style call.
67
+ In Storybook 7.0 we use Angular's new 'bootstrapApplication' API to mount the component to the DOM, which accepts a list of providers to set up application-wide providers.
68
+ Use the 'applicationConfig' decorator from '@storybook/angular' to pass your ModuleWithProviders to the 'providers' property in combination with the importProvidersFrom helper function from '@angular/core' to extract all the necessary providers.
69
+ Visit https://angular.io/guide/standalone-components#configuring-dependency-injection for more information
70
+ `));
71
+ }
72
+ }
73
+ init() {
74
+ const analyzed = this.analyzeMetadata(this.metadata);
75
+ this.imports = (0, exports.uniqueArray)([common_1.CommonModule, analyzed.imports]);
76
+ this.providers = (0, exports.uniqueArray)(analyzed.providers);
77
+ this.applicationProviders = (0, exports.uniqueArray)(analyzed.applicationProviders);
78
+ this.declarations = (0, exports.uniqueArray)(analyzed.declarations);
79
+ if (this.component) {
80
+ const { isDeclarable, isStandalone } = PropertyExtractor.analyzeDecorators(this.component);
81
+ const isDeclared = (0, NgModulesAnalyzer_1.isComponentAlreadyDeclared)(this.component, analyzed.declarations, this.imports);
82
+ if (isStandalone) {
83
+ this.imports.push(this.component);
84
+ }
85
+ else if (isDeclarable && !isDeclared) {
86
+ this.declarations.push(this.component);
87
+ }
88
+ }
89
+ }
90
+ }
91
+ _a = PropertyExtractor;
92
+ PropertyExtractor.analyzeRestricted = (ngModule) => {
93
+ if (ngModule === platform_browser_1.BrowserModule) {
94
+ console.warn((0, ts_dedent_1.default) `
95
+ Storybook Warning:
96
+ You have imported the "BrowserModule", which is not necessary anymore.
97
+ In Storybook v7.0 we are using Angular's new bootstrapApplication API to mount an Angular application to the DOM.
98
+ Note that the BrowserModule providers are automatically included when starting an application with bootstrapApplication()
99
+ Please remove the "BrowserModule" from the list of imports in your moduleMetadata definition to remove this warning.
100
+ `);
101
+ return [true];
102
+ }
103
+ if (ngModule === animations_1.BrowserAnimationsModule) {
104
+ console.warn((0, ts_dedent_1.default) `
105
+ Storybook Warning:
106
+ You have added the "BrowserAnimationsModule" to the list of "imports" in your moduleMetadata definition of your Story.
107
+ In Storybook 7.0 we use Angular's new 'bootstrapApplication' API to mount the component to the DOM, which accepts a list of providers to set up application-wide providers.
108
+ Use the 'applicationConfig' decorator from '@storybook/angular' and add the "provideAnimations" function to the list of "providers".
109
+ If your Angular version does not support "provide-like" functions, use the helper function importProvidersFrom instead to set up animations. For this case, please add "importProvidersFrom(BrowserAnimationsModule)" to the list of providers of your applicationConfig definition.
110
+ Please visit https://angular.io/guide/standalone-components#configuring-dependency-injection for more information.
111
+ `);
112
+ return [true, (0, animations_1.provideAnimations)()];
113
+ }
114
+ if (ngModule === animations_1.NoopAnimationsModule) {
115
+ console.warn((0, ts_dedent_1.default) `
116
+ Storybook Warning:
117
+ You have added the "NoopAnimationsModule" to the list of "imports" in your moduleMetadata definition of your Story.
118
+ In Storybook v7.0 we are using Angular's new bootstrapApplication API to mount an Angular application to the DOM, which accepts a list of providers to set up application-wide providers.
119
+ Use the 'applicationConfig' decorator from '@storybook/angular' and add the "provideNoopAnimations" function to the list of "providers".
120
+ If your Angular version does not support "provide-like" functions, use the helper function importProvidersFrom instead to set up noop animations and to extract all necessary providers from NoopAnimationsModule. For this case, please add "importProvidersFrom(NoopAnimationsModule)" to the list of providers of your applicationConfig definition.
121
+ Please visit https://angular.io/guide/standalone-components#configuring-dependency-injection for more information.
122
+ `);
123
+ return [true, (0, animations_1.provideNoopAnimations)()];
124
+ }
125
+ return [false];
126
+ };
127
+ PropertyExtractor.analyzeDecorators = (component) => {
128
+ const decorators = exports.reflectionCapabilities.annotations(component);
129
+ const isComponent = decorators.some((d) => _a.isDecoratorInstanceOf(d, 'Component'));
130
+ const isDirective = decorators.some((d) => _a.isDecoratorInstanceOf(d, 'Directive'));
131
+ const isPipe = decorators.some((d) => _a.isDecoratorInstanceOf(d, 'Pipe'));
132
+ const isDeclarable = isComponent || isDirective || isPipe;
133
+ const isStandalone = isComponent && decorators.some((d) => d.standalone);
134
+ return { isDeclarable, isStandalone };
135
+ };
136
+ PropertyExtractor.isDecoratorInstanceOf = (decorator, name) => {
137
+ let factory;
138
+ switch (name) {
139
+ case 'Component':
140
+ factory = core_1.Component;
141
+ break;
142
+ case 'Directive':
143
+ factory = core_1.Directive;
144
+ break;
145
+ case 'Pipe':
146
+ factory = core_1.Pipe;
147
+ break;
148
+ case 'Injectable':
149
+ factory = core_1.Injectable;
150
+ break;
151
+ case 'Input':
152
+ factory = core_1.Input;
153
+ break;
154
+ case 'Output':
155
+ factory = core_1.Output;
156
+ break;
157
+ default:
158
+ throw new Error(`Unknown decorator type: ${name}`);
159
+ }
160
+ return decorator instanceof factory || decorator.ngMetadataName === name;
161
+ };
162
+ exports.PropertyExtractor = PropertyExtractor;