@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,140 @@
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
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.createStorybookWrapperComponent = exports.componentNgModules = void 0;
16
+ const core_1 = require("@angular/core");
17
+ const rxjs_1 = require("rxjs");
18
+ const operators_1 = require("rxjs/operators");
19
+ const StorybookProvider_1 = require("./StorybookProvider");
20
+ const NgComponentAnalyzer_1 = require("./utils/NgComponentAnalyzer");
21
+ const PropertyExtractor_1 = require("./utils/PropertyExtractor");
22
+ const getNonInputsOutputsProps = (ngComponentInputsOutputs, props = {}) => {
23
+ const inputs = ngComponentInputsOutputs.inputs
24
+ .filter((i) => i.templateName in props)
25
+ .map((i) => i.templateName);
26
+ const outputs = ngComponentInputsOutputs.outputs
27
+ .filter((o) => o.templateName in props)
28
+ .map((o) => o.templateName);
29
+ return Object.keys(props).filter((k) => ![...inputs, ...outputs].includes(k));
30
+ };
31
+ // component modules cache
32
+ exports.componentNgModules = new Map();
33
+ /**
34
+ * Wraps the story template into a component
35
+ */
36
+ const createStorybookWrapperComponent = ({ selector, template, storyComponent, styles, moduleMetadata, initialProps, analyzedMetadata, }) => {
37
+ // In ivy, a '' selector is not allowed, therefore we need to just set it to anything if
38
+ // storyComponent was not provided.
39
+ const viewChildSelector = storyComponent ?? '__storybook-noop';
40
+ const { imports, declarations, providers } = analyzedMetadata;
41
+ // Only create a new module if it doesn't already exist
42
+ // This is to prevent the module from being recreated on every story change
43
+ // Declarations & Imports are only added once
44
+ // Providers are added on every story change to allow for story-specific providers
45
+ let ngModule = exports.componentNgModules.get(storyComponent);
46
+ if (!ngModule) {
47
+ let StorybookComponentModule = class StorybookComponentModule {
48
+ };
49
+ StorybookComponentModule = __decorate([
50
+ (0, core_1.NgModule)({
51
+ declarations,
52
+ imports,
53
+ exports: [...declarations, ...imports],
54
+ })
55
+ ], StorybookComponentModule);
56
+ exports.componentNgModules.set(storyComponent, StorybookComponentModule);
57
+ ngModule = exports.componentNgModules.get(storyComponent);
58
+ }
59
+ PropertyExtractor_1.PropertyExtractor.warnImportsModuleWithProviders(analyzedMetadata);
60
+ let StorybookWrapperComponent = class StorybookWrapperComponent {
61
+ constructor(storyProps$, changeDetectorRef) {
62
+ this.storyProps$ = storyProps$;
63
+ this.changeDetectorRef = changeDetectorRef;
64
+ // Used in case of a component without selector
65
+ this.storyComponent = storyComponent ?? '';
66
+ }
67
+ ngOnInit() {
68
+ // Subscribes to the observable storyProps$ to keep these properties up to date
69
+ this.storyWrapperPropsSubscription = this.storyProps$.subscribe((storyProps = {}) => {
70
+ // All props are added as component properties
71
+ Object.assign(this, storyProps);
72
+ this.changeDetectorRef.detectChanges();
73
+ this.changeDetectorRef.markForCheck();
74
+ });
75
+ }
76
+ ngAfterViewInit() {
77
+ // Bind properties to component, if the story have component
78
+ if (this.storyComponentElementRef) {
79
+ const ngComponentInputsOutputs = (0, NgComponentAnalyzer_1.getComponentInputsOutputs)(storyComponent);
80
+ const initialOtherProps = getNonInputsOutputsProps(ngComponentInputsOutputs, initialProps);
81
+ // Initializes properties that are not Inputs | Outputs
82
+ // Allows story props to override local component properties
83
+ initialOtherProps.forEach((p) => {
84
+ this.storyComponentElementRef[p] = initialProps[p];
85
+ });
86
+ // `markForCheck` the component in case this uses changeDetection: OnPush
87
+ // And then forces the `detectChanges`
88
+ this.storyComponentViewContainerRef.injector.get(core_1.ChangeDetectorRef).markForCheck();
89
+ this.changeDetectorRef.detectChanges();
90
+ // Once target component has been initialized, the storyProps$ observable keeps target component properties than are not Input|Output up to date
91
+ this.storyComponentPropsSubscription = this.storyProps$
92
+ .pipe((0, operators_1.skip)(1), (0, operators_1.map)((props) => {
93
+ const propsKeyToKeep = getNonInputsOutputsProps(ngComponentInputsOutputs, props);
94
+ return propsKeyToKeep.reduce((acc, p) => ({ ...acc, [p]: props[p] }), {});
95
+ }))
96
+ .subscribe((props) => {
97
+ // Replace inputs with new ones from props
98
+ Object.assign(this.storyComponentElementRef, props);
99
+ // `markForCheck` the component in case this uses changeDetection: OnPush
100
+ // And then forces the `detectChanges`
101
+ this.storyComponentViewContainerRef.injector.get(core_1.ChangeDetectorRef).markForCheck();
102
+ this.changeDetectorRef.detectChanges();
103
+ });
104
+ }
105
+ }
106
+ ngOnDestroy() {
107
+ if (this.storyComponentPropsSubscription != null) {
108
+ this.storyComponentPropsSubscription.unsubscribe();
109
+ }
110
+ if (this.storyWrapperPropsSubscription != null) {
111
+ this.storyWrapperPropsSubscription.unsubscribe();
112
+ }
113
+ }
114
+ };
115
+ __decorate([
116
+ (0, core_1.ViewChild)(viewChildSelector, { static: true }),
117
+ __metadata("design:type", core_1.ElementRef)
118
+ ], StorybookWrapperComponent.prototype, "storyComponentElementRef", void 0);
119
+ __decorate([
120
+ (0, core_1.ViewChild)(viewChildSelector, { read: core_1.ViewContainerRef, static: true }),
121
+ __metadata("design:type", core_1.ViewContainerRef)
122
+ ], StorybookWrapperComponent.prototype, "storyComponentViewContainerRef", void 0);
123
+ StorybookWrapperComponent = __decorate([
124
+ (0, core_1.Component)({
125
+ selector,
126
+ template,
127
+ standalone: true,
128
+ imports: [ngModule],
129
+ providers,
130
+ styles,
131
+ schemas: moduleMetadata.schemas,
132
+ }),
133
+ __param(0, (0, core_1.Inject)(StorybookProvider_1.STORY_PROPS)),
134
+ __param(1, (0, core_1.Inject)(core_1.ChangeDetectorRef)),
135
+ __metadata("design:paramtypes", [rxjs_1.Subject,
136
+ core_1.ChangeDetectorRef])
137
+ ], StorybookWrapperComponent);
138
+ return StorybookWrapperComponent;
139
+ };
140
+ exports.createStorybookWrapperComponent = createStorybookWrapperComponent;
@@ -0,0 +1,26 @@
1
+ import { EventEmitter } from '@angular/core';
2
+ export declare const exportedConstant = "An exported constant";
3
+ export declare enum ButtonAccent {
4
+ 'Normal' = "Normal",
5
+ 'High' = "High"
6
+ }
7
+ export interface ISomeInterface {
8
+ one: string;
9
+ two: boolean;
10
+ three: any[];
11
+ }
12
+ export declare class InputComponent<T> {
13
+ /** Appearance style of the button. */
14
+ appearance: 'primary' | 'secondary';
15
+ counter: number;
16
+ /** Specify the accent-type of the button */
17
+ accent: ButtonAccent;
18
+ /** To test source-generation with overridden propertyname */
19
+ foregroundColor: string;
20
+ /** Sets the button to a disabled state. */
21
+ isDisabled: boolean;
22
+ label: string;
23
+ /** Specifies some arbitrary object */
24
+ someDataObject: ISomeInterface;
25
+ onClick: EventEmitter<Event>;
26
+ }
@@ -0,0 +1,67 @@
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
+ exports.InputComponent = exports.ButtonAccent = exports.exportedConstant = void 0;
13
+ const core_1 = require("@angular/core");
14
+ exports.exportedConstant = 'An exported constant';
15
+ var ButtonAccent;
16
+ (function (ButtonAccent) {
17
+ ButtonAccent["Normal"] = "Normal";
18
+ ButtonAccent["High"] = "High";
19
+ })(ButtonAccent = exports.ButtonAccent || (exports.ButtonAccent = {}));
20
+ let InputComponent = class InputComponent {
21
+ constructor() {
22
+ /** Appearance style of the button. */
23
+ this.appearance = 'secondary';
24
+ /** Sets the button to a disabled state. */
25
+ this.isDisabled = false;
26
+ this.onClick = new core_1.EventEmitter();
27
+ }
28
+ };
29
+ __decorate([
30
+ (0, core_1.Input)(),
31
+ __metadata("design:type", String)
32
+ ], InputComponent.prototype, "appearance", void 0);
33
+ __decorate([
34
+ (0, core_1.Input)(),
35
+ __metadata("design:type", Number)
36
+ ], InputComponent.prototype, "counter", void 0);
37
+ __decorate([
38
+ (0, core_1.Input)(),
39
+ __metadata("design:type", String)
40
+ ], InputComponent.prototype, "accent", void 0);
41
+ __decorate([
42
+ (0, core_1.Input)('color'),
43
+ __metadata("design:type", String)
44
+ ], InputComponent.prototype, "foregroundColor", void 0);
45
+ __decorate([
46
+ (0, core_1.Input)(),
47
+ __metadata("design:type", Object)
48
+ ], InputComponent.prototype, "isDisabled", void 0);
49
+ __decorate([
50
+ (0, core_1.Input)(),
51
+ __metadata("design:type", String)
52
+ ], InputComponent.prototype, "label", void 0);
53
+ __decorate([
54
+ (0, core_1.Input)(),
55
+ __metadata("design:type", Object)
56
+ ], InputComponent.prototype, "someDataObject", void 0);
57
+ __decorate([
58
+ (0, core_1.Output)(),
59
+ __metadata("design:type", Object)
60
+ ], InputComponent.prototype, "onClick", void 0);
61
+ InputComponent = __decorate([
62
+ (0, core_1.Component)({
63
+ selector: 'doc-button',
64
+ template: '<button>{{ label }}</button>',
65
+ })
66
+ ], InputComponent);
67
+ exports.InputComponent = InputComponent;
@@ -0,0 +1,2 @@
1
+ export declare class WithOfficialModule {
2
+ }
@@ -0,0 +1,20 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.WithOfficialModule = void 0;
10
+ const common_1 = require("@angular/common");
11
+ const http_1 = require("@angular/common/http");
12
+ const core_1 = require("@angular/core");
13
+ let WithOfficialModule = class WithOfficialModule {
14
+ };
15
+ WithOfficialModule = __decorate([
16
+ (0, core_1.NgModule)({
17
+ imports: [common_1.CommonModule, http_1.HttpClientModule],
18
+ })
19
+ ], WithOfficialModule);
20
+ exports.WithOfficialModule = WithOfficialModule;
@@ -0,0 +1,29 @@
1
+ import { Type, Component } from '@angular/core';
2
+ export type ComponentInputsOutputs = {
3
+ inputs: {
4
+ propName: string;
5
+ templateName: string;
6
+ }[];
7
+ outputs: {
8
+ propName: string;
9
+ templateName: string;
10
+ }[];
11
+ };
12
+ /**
13
+ * Returns component Inputs / Outputs by browsing these properties and decorator
14
+ */
15
+ export declare const getComponentInputsOutputs: (component: any) => ComponentInputsOutputs;
16
+ export declare const isDeclarable: (component: any) => boolean;
17
+ export declare const isComponent: (component: any) => component is Type<unknown>;
18
+ export declare const isStandaloneComponent: (component: any) => component is Type<unknown>;
19
+ /**
20
+ * Returns all component decorator properties
21
+ * is used to get all `@Input` and `@Output` Decorator
22
+ */
23
+ export declare const getComponentPropsDecoratorMetadata: (component: any) => {
24
+ [key: string]: any[];
25
+ };
26
+ /**
27
+ * Returns component decorator `@Component`
28
+ */
29
+ export declare const getComponentDecoratorMetadata: (component: any) => Component | undefined;
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getComponentDecoratorMetadata = exports.getComponentPropsDecoratorMetadata = exports.isStandaloneComponent = exports.isComponent = exports.isDeclarable = exports.getComponentInputsOutputs = void 0;
4
+ const core_1 = require("@angular/core");
5
+ const reflectionCapabilities = new core_1.ɵReflectionCapabilities();
6
+ /**
7
+ * Returns component Inputs / Outputs by browsing these properties and decorator
8
+ */
9
+ const getComponentInputsOutputs = (component) => {
10
+ const componentMetadata = (0, exports.getComponentDecoratorMetadata)(component);
11
+ const componentPropsMetadata = (0, exports.getComponentPropsDecoratorMetadata)(component);
12
+ const initialValue = {
13
+ inputs: [],
14
+ outputs: [],
15
+ };
16
+ // Adds the I/O present in @Component metadata
17
+ if (componentMetadata && componentMetadata.inputs) {
18
+ initialValue.inputs.push(...componentMetadata.inputs.map((i) => ({
19
+ propName: typeof i === 'string' ? i : i.name,
20
+ templateName: typeof i === 'string' ? i : i.alias,
21
+ })));
22
+ }
23
+ if (componentMetadata && componentMetadata.outputs) {
24
+ initialValue.outputs.push(...componentMetadata.outputs.map((i) => ({ propName: i, templateName: i })));
25
+ }
26
+ if (!componentPropsMetadata) {
27
+ return initialValue;
28
+ }
29
+ // Browses component properties to extract I/O
30
+ // Filters properties that have the same name as the one present in the @Component property
31
+ return Object.entries(componentPropsMetadata).reduce((previousValue, [propertyName, values]) => {
32
+ const value = values.find((v) => v instanceof core_1.Input || v instanceof core_1.Output);
33
+ if (value instanceof core_1.Input) {
34
+ const inputToAdd = {
35
+ propName: propertyName,
36
+ templateName: value.bindingPropertyName ?? value.alias ?? propertyName,
37
+ };
38
+ const previousInputsFiltered = previousValue.inputs.filter((i) => i.templateName !== propertyName);
39
+ return {
40
+ ...previousValue,
41
+ inputs: [...previousInputsFiltered, inputToAdd],
42
+ };
43
+ }
44
+ if (value instanceof core_1.Output) {
45
+ const outputToAdd = {
46
+ propName: propertyName,
47
+ templateName: value.bindingPropertyName ?? value.alias ?? propertyName,
48
+ };
49
+ const previousOutputsFiltered = previousValue.outputs.filter((i) => i.templateName !== propertyName);
50
+ return {
51
+ ...previousValue,
52
+ outputs: [...previousOutputsFiltered, outputToAdd],
53
+ };
54
+ }
55
+ return previousValue;
56
+ }, initialValue);
57
+ };
58
+ exports.getComponentInputsOutputs = getComponentInputsOutputs;
59
+ const isDeclarable = (component) => {
60
+ if (!component) {
61
+ return false;
62
+ }
63
+ const decorators = reflectionCapabilities.annotations(component);
64
+ return !!(decorators || []).find((d) => d instanceof core_1.Directive || d instanceof core_1.Pipe || d instanceof core_1.Component);
65
+ };
66
+ exports.isDeclarable = isDeclarable;
67
+ const isComponent = (component) => {
68
+ if (!component) {
69
+ return false;
70
+ }
71
+ const decorators = reflectionCapabilities.annotations(component);
72
+ return (decorators || []).some((d) => d instanceof core_1.Component);
73
+ };
74
+ exports.isComponent = isComponent;
75
+ const isStandaloneComponent = (component) => {
76
+ if (!component) {
77
+ return false;
78
+ }
79
+ const decorators = reflectionCapabilities.annotations(component);
80
+ // TODO: `standalone` is only available in Angular v14. Remove cast to `any` once
81
+ // Angular deps are updated to v14.x.x.
82
+ return (decorators || []).some((d) => (d instanceof core_1.Component || d instanceof core_1.Directive || d instanceof core_1.Pipe) && d.standalone);
83
+ };
84
+ exports.isStandaloneComponent = isStandaloneComponent;
85
+ /**
86
+ * Returns all component decorator properties
87
+ * is used to get all `@Input` and `@Output` Decorator
88
+ */
89
+ const getComponentPropsDecoratorMetadata = (component) => {
90
+ return reflectionCapabilities.propMetadata(component);
91
+ };
92
+ exports.getComponentPropsDecoratorMetadata = getComponentPropsDecoratorMetadata;
93
+ /**
94
+ * Returns component decorator `@Component`
95
+ */
96
+ const getComponentDecoratorMetadata = (component) => {
97
+ const decorators = reflectionCapabilities.annotations(component);
98
+ return decorators.reverse().find((d) => d instanceof core_1.Component);
99
+ };
100
+ exports.getComponentDecoratorMetadata = getComponentDecoratorMetadata;