@storybook/angular 9.1.0-alpha.6 → 9.1.0-alpha.8

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 -83
  4. package/dist/builders/start-storybook/index.js +31 -104
  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 -84
  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 -81
  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 -102
  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 -82
  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,730 +0,0 @@
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
- const core_1 = require("@angular/core");
10
- const vitest_1 = require("vitest");
11
- const ComputesTemplateFromComponent_1 = require("./ComputesTemplateFromComponent");
12
- const input_component_1 = require("./__testfixtures__/input.component");
13
- (0, vitest_1.describe)('angular template decorator', () => {
14
- (0, vitest_1.it)('with props should generate tag with properties', () => {
15
- const component = input_component_1.InputComponent;
16
- const props = {
17
- isDisabled: true,
18
- label: 'Hello world',
19
- accent: input_component_1.ButtonAccent.High,
20
- counter: 4,
21
- 'aria-label': 'Hello world',
22
- };
23
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
24
- (0, vitest_1.expect)(source).toEqual(`<doc-button [counter]="counter" [accent]="accent" [isDisabled]="isDisabled" [label]="label" [aria-label]="this['aria-label']"></doc-button>`);
25
- });
26
- (0, vitest_1.it)('with props should generate tag with outputs', () => {
27
- const component = input_component_1.InputComponent;
28
- const props = {
29
- isDisabled: true,
30
- label: 'Hello world',
31
- onClick: ($event) => { },
32
- 'dash-out': ($event) => { },
33
- };
34
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
35
- (0, vitest_1.expect)(source).toEqual(`<doc-button [isDisabled]="isDisabled" [label]="label" (onClick)="onClick($event)" (dash-out)="this['dash-out']($event)"></doc-button>`);
36
- });
37
- (0, vitest_1.it)('with no props should generate simple tag', () => {
38
- const component = input_component_1.InputComponent;
39
- const props = {};
40
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
41
- (0, vitest_1.expect)(source).toEqual('<doc-button></doc-button>');
42
- });
43
- (0, vitest_1.describe)('with component without selector', () => {
44
- let WithoutSelectorComponent = class WithoutSelectorComponent {
45
- };
46
- WithoutSelectorComponent = __decorate([
47
- (0, core_1.Component)({
48
- template: `The content`,
49
- })
50
- ], WithoutSelectorComponent);
51
- (0, vitest_1.it)('should add component ng-container', async () => {
52
- const component = WithoutSelectorComponent;
53
- const props = {};
54
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
55
- (0, vitest_1.expect)(source).toEqual(`<ng-container *ngComponentOutlet="storyComponent"></ng-container>`);
56
- });
57
- });
58
- (0, vitest_1.describe)('with component with attribute selector', () => {
59
- let WithAttributeComponent = class WithAttributeComponent {
60
- };
61
- WithAttributeComponent = __decorate([
62
- (0, core_1.Component)({
63
- selector: 'doc-button[foo]',
64
- template: '<button></button>',
65
- })
66
- ], WithAttributeComponent);
67
- (0, vitest_1.it)('should add attribute to template', async () => {
68
- const component = WithAttributeComponent;
69
- const props = {};
70
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
71
- (0, vitest_1.expect)(source).toEqual(`<doc-button foo></doc-button>`);
72
- });
73
- });
74
- (0, vitest_1.describe)('with component with attribute and value selector', () => {
75
- let WithAttributeValueComponent = class WithAttributeValueComponent {
76
- };
77
- WithAttributeValueComponent = __decorate([
78
- (0, core_1.Component)({
79
- selector: 'doc-button[foo="bar"]',
80
- template: '<button></button>',
81
- })
82
- ], WithAttributeValueComponent);
83
- (0, vitest_1.it)('should add attribute to template', async () => {
84
- const component = WithAttributeValueComponent;
85
- const props = {};
86
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
87
- (0, vitest_1.expect)(source).toEqual(`<doc-button foo="bar"></doc-button>`);
88
- });
89
- });
90
- (0, vitest_1.describe)('with component with attribute only selector', () => {
91
- let WithAttributeOnlyComponent = class WithAttributeOnlyComponent {
92
- };
93
- WithAttributeOnlyComponent = __decorate([
94
- (0, core_1.Component)({
95
- selector: '[foo]',
96
- template: '<button></button>',
97
- })
98
- ], WithAttributeOnlyComponent);
99
- (0, vitest_1.it)('should create a div and add attribute to template', async () => {
100
- const component = WithAttributeOnlyComponent;
101
- const props = {};
102
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
103
- (0, vitest_1.expect)(source).toEqual(`<div foo></div>`);
104
- });
105
- });
106
- (0, vitest_1.describe)('with component with void element and attribute selector', () => {
107
- let VoidElementWithAttributeComponent = class VoidElementWithAttributeComponent {
108
- };
109
- VoidElementWithAttributeComponent = __decorate([
110
- (0, core_1.Component)({
111
- selector: 'input[foo]',
112
- template: '<button></button>',
113
- })
114
- ], VoidElementWithAttributeComponent);
115
- (0, vitest_1.it)('should create without separate closing tag', async () => {
116
- const component = VoidElementWithAttributeComponent;
117
- const props = {};
118
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
119
- (0, vitest_1.expect)(source).toEqual(`<input foo />`);
120
- });
121
- });
122
- (0, vitest_1.describe)('with component with attribute and value only selector', () => {
123
- let WithAttributeOnlyComponent = class WithAttributeOnlyComponent {
124
- };
125
- WithAttributeOnlyComponent = __decorate([
126
- (0, core_1.Component)({
127
- selector: '[foo="bar"]',
128
- template: '<button></button>',
129
- })
130
- ], WithAttributeOnlyComponent);
131
- (0, vitest_1.it)('should create a div and add attribute to template', async () => {
132
- const component = WithAttributeOnlyComponent;
133
- const props = {};
134
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
135
- (0, vitest_1.expect)(source).toEqual(`<div foo="bar"></div>`);
136
- });
137
- });
138
- (0, vitest_1.describe)('with component with void element, attribute and value only selector', () => {
139
- let VoidElementWithAttributeComponent = class VoidElementWithAttributeComponent {
140
- };
141
- VoidElementWithAttributeComponent = __decorate([
142
- (0, core_1.Component)({
143
- selector: 'input[foo="bar"]',
144
- template: '<button></button>',
145
- })
146
- ], VoidElementWithAttributeComponent);
147
- (0, vitest_1.it)('should create and add attribute to template without separate closing tag', async () => {
148
- const component = VoidElementWithAttributeComponent;
149
- const props = {};
150
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
151
- (0, vitest_1.expect)(source).toEqual(`<input foo="bar" />`);
152
- });
153
- });
154
- (0, vitest_1.describe)('with component with class selector', () => {
155
- let WithClassComponent = class WithClassComponent {
156
- };
157
- WithClassComponent = __decorate([
158
- (0, core_1.Component)({
159
- selector: 'doc-button.foo',
160
- template: '<button></button>',
161
- })
162
- ], WithClassComponent);
163
- (0, vitest_1.it)('should add class to template', async () => {
164
- const component = WithClassComponent;
165
- const props = {};
166
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
167
- (0, vitest_1.expect)(source).toEqual(`<doc-button class="foo"></doc-button>`);
168
- });
169
- });
170
- (0, vitest_1.describe)('with component with class only selector', () => {
171
- let WithClassComponent = class WithClassComponent {
172
- };
173
- WithClassComponent = __decorate([
174
- (0, core_1.Component)({
175
- selector: '.foo',
176
- template: '<button></button>',
177
- })
178
- ], WithClassComponent);
179
- (0, vitest_1.it)('should create a div and add attribute to template', async () => {
180
- const component = WithClassComponent;
181
- const props = {};
182
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
183
- (0, vitest_1.expect)(source).toEqual(`<div class="foo"></div>`);
184
- });
185
- });
186
- (0, vitest_1.describe)('with component with multiple selectors', () => {
187
- let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
188
- };
189
- WithMultipleSelectorsComponent = __decorate([
190
- (0, core_1.Component)({
191
- selector: 'doc-button, doc-button2',
192
- template: '<button></button>',
193
- })
194
- ], WithMultipleSelectorsComponent);
195
- (0, vitest_1.it)('should use the first selector', async () => {
196
- const component = WithMultipleSelectorsComponent;
197
- const props = {};
198
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
199
- (0, vitest_1.expect)(source).toEqual(`<doc-button></doc-button>`);
200
- });
201
- });
202
- (0, vitest_1.describe)('with component with multiple selectors starting with attribute', () => {
203
- let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
204
- };
205
- WithMultipleSelectorsComponent = __decorate([
206
- (0, core_1.Component)({
207
- selector: 'doc-button[foo], doc-button2',
208
- template: '<button></button>',
209
- })
210
- ], WithMultipleSelectorsComponent);
211
- (0, vitest_1.it)('should use the first selector', async () => {
212
- const component = WithMultipleSelectorsComponent;
213
- const props = {};
214
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
215
- (0, vitest_1.expect)(source).toEqual(`<doc-button foo></doc-button>`);
216
- });
217
- });
218
- (0, vitest_1.describe)('with component with multiple selectors starting with attribute and value', () => {
219
- let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
220
- };
221
- WithMultipleSelectorsComponent = __decorate([
222
- (0, core_1.Component)({
223
- selector: 'doc-button[foo="bar"], doc-button2',
224
- template: '<button></button>',
225
- })
226
- ], WithMultipleSelectorsComponent);
227
- (0, vitest_1.it)('should use the first selector', async () => {
228
- const component = WithMultipleSelectorsComponent;
229
- const props = {};
230
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
231
- (0, vitest_1.expect)(source).toEqual(`<doc-button foo="bar"></doc-button>`);
232
- });
233
- });
234
- (0, vitest_1.describe)('with component with multiple selectors including 2 attributes and a class', () => {
235
- let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
236
- };
237
- WithMultipleSelectorsComponent = __decorate([
238
- (0, core_1.Component)({
239
- selector: 'doc-button, button[foo], .button[foo], button[baz]',
240
- template: '<button></button>',
241
- })
242
- ], WithMultipleSelectorsComponent);
243
- (0, vitest_1.it)('should use the first selector', async () => {
244
- const component = WithMultipleSelectorsComponent;
245
- const props = {};
246
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
247
- (0, vitest_1.expect)(source).toEqual(`<doc-button></doc-button>`);
248
- });
249
- });
250
- (0, vitest_1.describe)('with component with multiple selectors with line breaks', () => {
251
- let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
252
- };
253
- WithMultipleSelectorsComponent = __decorate([
254
- (0, core_1.Component)({
255
- selector: `doc-button,
256
- doc-button2`,
257
- template: '<button></button>',
258
- })
259
- ], WithMultipleSelectorsComponent);
260
- (0, vitest_1.it)('should use the first selector', async () => {
261
- const component = WithMultipleSelectorsComponent;
262
- const props = {};
263
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
264
- (0, vitest_1.expect)(source).toEqual(`<doc-button></doc-button>`);
265
- });
266
- });
267
- (0, vitest_1.describe)('with component with multiple selectors starting with attribute only with line breaks', () => {
268
- let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
269
- };
270
- WithMultipleSelectorsComponent = __decorate([
271
- (0, core_1.Component)({
272
- selector: `[foo],
273
- doc-button2`,
274
- template: '<button></button>',
275
- })
276
- ], WithMultipleSelectorsComponent);
277
- (0, vitest_1.it)('should use the first selector', async () => {
278
- const component = WithMultipleSelectorsComponent;
279
- const props = {};
280
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
281
- (0, vitest_1.expect)(source).toEqual(`<div foo></div>`);
282
- });
283
- });
284
- (0, vitest_1.it)('with props should generate tag with properties', () => {
285
- const component = input_component_1.InputComponent;
286
- const props = {
287
- isDisabled: true,
288
- label: 'Hello world',
289
- accent: input_component_1.ButtonAccent.High,
290
- counter: 4,
291
- };
292
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
293
- (0, vitest_1.expect)(source).toEqual(`<doc-button [counter]="counter" [accent]="accent" [isDisabled]="isDisabled" [label]="label"></doc-button>`);
294
- });
295
- (0, vitest_1.it)('with props should generate tag with outputs', () => {
296
- const component = input_component_1.InputComponent;
297
- const props = {
298
- isDisabled: true,
299
- label: 'Hello world',
300
- onClick: ($event) => { },
301
- };
302
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
303
- (0, vitest_1.expect)(source).toEqual(`<doc-button [isDisabled]="isDisabled" [label]="label" (onClick)="onClick($event)"></doc-button>`);
304
- });
305
- (0, vitest_1.it)('should generate correct property for overridden name for Input', () => {
306
- const component = input_component_1.InputComponent;
307
- const props = {
308
- color: '#ffffff',
309
- };
310
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props);
311
- (0, vitest_1.expect)(source).toEqual(`<doc-button [color]="color"></doc-button>`);
312
- });
313
- });
314
- (0, vitest_1.describe)('angular source decorator', () => {
315
- (0, vitest_1.it)('with no props should generate simple tag', () => {
316
- const component = input_component_1.InputComponent;
317
- const props = {};
318
- const argTypes = {};
319
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
320
- (0, vitest_1.expect)(source).toEqual('<doc-button></doc-button>');
321
- });
322
- (0, vitest_1.describe)('with component without selector', () => {
323
- let WithoutSelectorComponent = class WithoutSelectorComponent {
324
- };
325
- WithoutSelectorComponent = __decorate([
326
- (0, core_1.Component)({
327
- template: `The content`,
328
- })
329
- ], WithoutSelectorComponent);
330
- (0, vitest_1.it)('should add component ng-container', async () => {
331
- const component = WithoutSelectorComponent;
332
- const props = {};
333
- const argTypes = {};
334
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
335
- (0, vitest_1.expect)(source).toEqual(`<ng-container *ngComponentOutlet="WithoutSelectorComponent"></ng-container>`);
336
- });
337
- });
338
- (0, vitest_1.describe)('with component with attribute selector', () => {
339
- let WithAttributeComponent = class WithAttributeComponent {
340
- };
341
- WithAttributeComponent = __decorate([
342
- (0, core_1.Component)({
343
- selector: 'doc-button[foo]',
344
- template: '<button></button>',
345
- })
346
- ], WithAttributeComponent);
347
- (0, vitest_1.it)('should add attribute to template', async () => {
348
- const component = WithAttributeComponent;
349
- const props = {};
350
- const argTypes = {};
351
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
352
- (0, vitest_1.expect)(source).toEqual(`<doc-button foo></doc-button>`);
353
- });
354
- });
355
- (0, vitest_1.describe)('with component with attribute and value selector', () => {
356
- let WithAttributeValueComponent = class WithAttributeValueComponent {
357
- };
358
- WithAttributeValueComponent = __decorate([
359
- (0, core_1.Component)({
360
- selector: 'doc-button[foo="bar"]',
361
- template: '<button></button>',
362
- })
363
- ], WithAttributeValueComponent);
364
- (0, vitest_1.it)('should add attribute to template', async () => {
365
- const component = WithAttributeValueComponent;
366
- const props = {};
367
- const argTypes = {};
368
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
369
- (0, vitest_1.expect)(source).toEqual(`<doc-button foo="bar"></doc-button>`);
370
- });
371
- });
372
- (0, vitest_1.describe)('with component with attribute only selector', () => {
373
- let WithAttributeOnlyComponent = class WithAttributeOnlyComponent {
374
- };
375
- WithAttributeOnlyComponent = __decorate([
376
- (0, core_1.Component)({
377
- selector: '[foo]',
378
- template: '<button></button>',
379
- })
380
- ], WithAttributeOnlyComponent);
381
- (0, vitest_1.it)('should create a div and add attribute to template', async () => {
382
- const component = WithAttributeOnlyComponent;
383
- const props = {};
384
- const argTypes = {};
385
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
386
- (0, vitest_1.expect)(source).toEqual(`<div foo></div>`);
387
- });
388
- });
389
- (0, vitest_1.describe)('with component with void element and attribute selector', () => {
390
- let VoidElementWithAttributeComponent = class VoidElementWithAttributeComponent {
391
- };
392
- VoidElementWithAttributeComponent = __decorate([
393
- (0, core_1.Component)({
394
- selector: 'input[foo]',
395
- template: '<button></button>',
396
- })
397
- ], VoidElementWithAttributeComponent);
398
- (0, vitest_1.it)('should create without separate closing tag', async () => {
399
- const component = VoidElementWithAttributeComponent;
400
- const props = {};
401
- const argTypes = {};
402
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
403
- (0, vitest_1.expect)(source).toEqual(`<input foo />`);
404
- });
405
- });
406
- (0, vitest_1.describe)('with component with attribute and value only selector', () => {
407
- let WithAttributeOnlyComponent = class WithAttributeOnlyComponent {
408
- };
409
- WithAttributeOnlyComponent = __decorate([
410
- (0, core_1.Component)({
411
- selector: '[foo="bar"]',
412
- template: '<button></button>',
413
- })
414
- ], WithAttributeOnlyComponent);
415
- (0, vitest_1.it)('should create a div and add attribute to template', async () => {
416
- const component = WithAttributeOnlyComponent;
417
- const props = {};
418
- const argTypes = {};
419
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
420
- (0, vitest_1.expect)(source).toEqual(`<div foo="bar"></div>`);
421
- });
422
- });
423
- (0, vitest_1.describe)('with component with void element, attribute and value only selector', () => {
424
- let VoidElementWithAttributeComponent = class VoidElementWithAttributeComponent {
425
- };
426
- VoidElementWithAttributeComponent = __decorate([
427
- (0, core_1.Component)({
428
- selector: 'input[foo="bar"]',
429
- template: '<button></button>',
430
- })
431
- ], VoidElementWithAttributeComponent);
432
- (0, vitest_1.it)('should create and add attribute to template without separate closing tag', async () => {
433
- const component = VoidElementWithAttributeComponent;
434
- const props = {};
435
- const argTypes = {};
436
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
437
- (0, vitest_1.expect)(source).toEqual(`<input foo="bar" />`);
438
- });
439
- });
440
- (0, vitest_1.describe)('with component with class selector', () => {
441
- let WithClassComponent = class WithClassComponent {
442
- };
443
- WithClassComponent = __decorate([
444
- (0, core_1.Component)({
445
- selector: 'doc-button.foo',
446
- template: '<button></button>',
447
- })
448
- ], WithClassComponent);
449
- (0, vitest_1.it)('should add class to template', async () => {
450
- const component = WithClassComponent;
451
- const props = {};
452
- const argTypes = {};
453
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
454
- (0, vitest_1.expect)(source).toEqual(`<doc-button class="foo"></doc-button>`);
455
- });
456
- });
457
- (0, vitest_1.describe)('with component with class only selector', () => {
458
- let WithClassComponent = class WithClassComponent {
459
- };
460
- WithClassComponent = __decorate([
461
- (0, core_1.Component)({
462
- selector: '.foo',
463
- template: '<button></button>',
464
- })
465
- ], WithClassComponent);
466
- (0, vitest_1.it)('should create a div and add attribute to template', async () => {
467
- const component = WithClassComponent;
468
- const props = {};
469
- const argTypes = {};
470
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
471
- (0, vitest_1.expect)(source).toEqual(`<div class="foo"></div>`);
472
- });
473
- });
474
- (0, vitest_1.describe)('with component with multiple selectors', () => {
475
- let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
476
- };
477
- WithMultipleSelectorsComponent = __decorate([
478
- (0, core_1.Component)({
479
- selector: 'doc-button, doc-button2',
480
- template: '<button></button>',
481
- })
482
- ], WithMultipleSelectorsComponent);
483
- (0, vitest_1.it)('should use the first selector', async () => {
484
- const component = WithMultipleSelectorsComponent;
485
- const props = {};
486
- const argTypes = {};
487
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
488
- (0, vitest_1.expect)(source).toEqual(`<doc-button></doc-button>`);
489
- });
490
- });
491
- (0, vitest_1.describe)('with component with multiple selectors starting with attribute', () => {
492
- let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
493
- };
494
- WithMultipleSelectorsComponent = __decorate([
495
- (0, core_1.Component)({
496
- selector: 'doc-button[foo], doc-button2',
497
- template: '<button></button>',
498
- })
499
- ], WithMultipleSelectorsComponent);
500
- (0, vitest_1.it)('should use the first selector', async () => {
501
- const component = WithMultipleSelectorsComponent;
502
- const props = {};
503
- const argTypes = {};
504
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
505
- (0, vitest_1.expect)(source).toEqual(`<doc-button foo></doc-button>`);
506
- });
507
- });
508
- (0, vitest_1.describe)('with component with multiple selectors starting with attribute and value', () => {
509
- let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
510
- };
511
- WithMultipleSelectorsComponent = __decorate([
512
- (0, core_1.Component)({
513
- selector: 'doc-button[foo="bar"], doc-button2',
514
- template: '<button></button>',
515
- })
516
- ], WithMultipleSelectorsComponent);
517
- (0, vitest_1.it)('should use the first selector', async () => {
518
- const component = WithMultipleSelectorsComponent;
519
- const props = {};
520
- const argTypes = {};
521
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
522
- (0, vitest_1.expect)(source).toEqual(`<doc-button foo="bar"></doc-button>`);
523
- });
524
- });
525
- (0, vitest_1.describe)('with component with multiple selectors including 2 attributes and a class', () => {
526
- let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
527
- };
528
- WithMultipleSelectorsComponent = __decorate([
529
- (0, core_1.Component)({
530
- selector: 'doc-button, button[foo], .button[foo], button[baz]',
531
- template: '<button></button>',
532
- })
533
- ], WithMultipleSelectorsComponent);
534
- (0, vitest_1.it)('should use the first selector', async () => {
535
- const component = WithMultipleSelectorsComponent;
536
- const props = {};
537
- const argTypes = {};
538
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
539
- (0, vitest_1.expect)(source).toEqual(`<doc-button></doc-button>`);
540
- });
541
- });
542
- (0, vitest_1.describe)('with component with multiple selectors with line breaks', () => {
543
- let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
544
- };
545
- WithMultipleSelectorsComponent = __decorate([
546
- (0, core_1.Component)({
547
- selector: `doc-button,
548
- doc-button2`,
549
- template: '<button></button>',
550
- })
551
- ], WithMultipleSelectorsComponent);
552
- (0, vitest_1.it)('should use the first selector', async () => {
553
- const component = WithMultipleSelectorsComponent;
554
- const props = {};
555
- const argTypes = {};
556
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
557
- (0, vitest_1.expect)(source).toEqual(`<doc-button></doc-button>`);
558
- });
559
- });
560
- (0, vitest_1.describe)('with component with multiple selectors starting with attribute only with line breaks', () => {
561
- let WithMultipleSelectorsComponent = class WithMultipleSelectorsComponent {
562
- };
563
- WithMultipleSelectorsComponent = __decorate([
564
- (0, core_1.Component)({
565
- selector: `[foo],
566
- doc-button2`,
567
- template: '<button></button>',
568
- })
569
- ], WithMultipleSelectorsComponent);
570
- (0, vitest_1.it)('should use the first selector', async () => {
571
- const component = WithMultipleSelectorsComponent;
572
- const props = {};
573
- const argTypes = {};
574
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
575
- (0, vitest_1.expect)(source).toEqual(`<div foo></div>`);
576
- });
577
- });
578
- (0, vitest_1.describe)('no argTypes', () => {
579
- (0, vitest_1.it)('should generate tag-only template with no props', () => {
580
- const component = input_component_1.InputComponent;
581
- const props = {};
582
- const argTypes = {};
583
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
584
- (0, vitest_1.expect)(source).toEqual(`<doc-button></doc-button>`);
585
- });
586
- (0, vitest_1.it)('with props should generate tag with properties', () => {
587
- const component = input_component_1.InputComponent;
588
- const props = {
589
- isDisabled: true,
590
- label: 'Hello world',
591
- accent: input_component_1.ButtonAccent.High,
592
- counter: 4,
593
- 'aria-label': 'Hello world',
594
- };
595
- const argTypes = {};
596
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
597
- (0, vitest_1.expect)(source).toEqual(`<doc-button [counter]="4" [accent]="'High'" [isDisabled]="true" [label]="'Hello world'" [aria-label]="'Hello world'"></doc-button>`);
598
- });
599
- (0, vitest_1.it)('with props should generate tag with outputs', () => {
600
- const component = input_component_1.InputComponent;
601
- const props = {
602
- isDisabled: true,
603
- label: 'Hello world',
604
- onClick: ($event) => { },
605
- 'dash-out': ($event) => { },
606
- };
607
- const argTypes = {};
608
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
609
- (0, vitest_1.expect)(source).toEqual(`<doc-button [isDisabled]="true" [label]="'Hello world'" (onClick)="onClick($event)" (dash-out)="this['dash-out']($event)"></doc-button>`);
610
- });
611
- (0, vitest_1.it)('should generate correct property for overridden name for Input', () => {
612
- const component = input_component_1.InputComponent;
613
- const props = {
614
- color: '#ffffff',
615
- };
616
- const argTypes = {};
617
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
618
- (0, vitest_1.expect)(source).toEqual(`<doc-button [color]="'#ffffff'"></doc-button>`);
619
- });
620
- });
621
- (0, vitest_1.describe)('with argTypes (from compodoc)', () => {
622
- (0, vitest_1.it)('should handle enum as strongly typed enum', () => {
623
- const component = input_component_1.InputComponent;
624
- const props = {
625
- isDisabled: false,
626
- label: 'Hello world',
627
- accent: input_component_1.ButtonAccent.High,
628
- };
629
- const argTypes = {
630
- accent: {
631
- control: {
632
- options: ['Normal', 'High'],
633
- type: 'radio',
634
- },
635
- defaultValue: undefined,
636
- table: {
637
- category: 'inputs',
638
- },
639
- type: {
640
- name: 'enum',
641
- required: true,
642
- value: [],
643
- },
644
- },
645
- };
646
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
647
- (0, vitest_1.expect)(source).toEqual(`<doc-button [accent]="'High'" [isDisabled]="false" [label]="'Hello world'"></doc-button>`);
648
- });
649
- (0, vitest_1.it)('should handle enum without values as string', () => {
650
- const component = input_component_1.InputComponent;
651
- const props = {
652
- isDisabled: false,
653
- label: 'Hello world',
654
- accent: input_component_1.ButtonAccent.High,
655
- };
656
- const argTypes = {
657
- accent: {
658
- control: {
659
- options: ['Normal', 'High'],
660
- type: 'radio',
661
- },
662
- defaultValue: undefined,
663
- table: {
664
- category: 'inputs',
665
- },
666
- type: {
667
- name: 'object',
668
- required: true,
669
- value: {},
670
- },
671
- },
672
- };
673
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, argTypes);
674
- (0, vitest_1.expect)(source).toEqual(`<doc-button [accent]="'High'" [isDisabled]="false" [label]="'Hello world'"></doc-button>`);
675
- });
676
- (0, vitest_1.it)('should handle simple object as stringified', () => {
677
- const component = input_component_1.InputComponent;
678
- const someDataObject = {
679
- one: 'Hello world',
680
- two: true,
681
- three: [
682
- `a string literal with "double quotes"`,
683
- `a string literal with 'single quotes'`,
684
- 'a single quoted string with "double quotes"',
685
- "a double quoted string with 'single quotes'",
686
- "a single quoted string with escaped 'single quotes'",
687
- 'a double quoted string with escaped "double quotes"',
688
- `a string literal with \'escaped single quotes\'`,
689
- `a string literal with \"escaped double quotes\"`,
690
- ],
691
- };
692
- const props = {
693
- isDisabled: false,
694
- label: 'Hello world',
695
- someDataObject,
696
- };
697
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, null);
698
- // Ideally we should stringify the object, but that could cause the story to break because of unescaped values in the JSON object.
699
- // This will have to do for now
700
- (0, vitest_1.expect)(source).toEqual(`<doc-button [isDisabled]="false" [label]="'Hello world'" [someDataObject]="{one: 'Hello world', two: true, three: ['a string literal with \\'double quotes\\'', 'a string literal with \\'single quotes\\'', 'a single quoted string with \\'double quotes\\'', 'a double quoted string with \\'single quotes\\'', 'a single quoted string with escaped \\'single quotes\\'', 'a double quoted string with escaped \\'double quotes\\'', 'a string literal with \\'escaped single quotes\\'', 'a string literal with \\'escaped double quotes\\'']}"></doc-button>`);
701
- });
702
- (0, vitest_1.it)('should handle circular object as stringified', () => {
703
- const component = input_component_1.InputComponent;
704
- const someDataObject = {
705
- one: 'Hello world',
706
- two: true,
707
- three: [
708
- `a string literal with "double quotes"`,
709
- `a string literal with 'single quotes'`,
710
- 'a single quoted string with "double quotes"',
711
- "a double quoted string with 'single quotes'",
712
- "a single quoted string with escaped 'single quotes'",
713
- 'a double quoted string with escaped "double quotes"',
714
- `a string literal with \'escaped single quotes\'`,
715
- `a string literal with \"escaped double quotes\"`,
716
- ],
717
- };
718
- someDataObject.ref = someDataObject;
719
- const props = {
720
- isDisabled: false,
721
- label: 'Hello world',
722
- someDataObject,
723
- };
724
- const source = (0, ComputesTemplateFromComponent_1.computesTemplateSourceFromComponent)(component, props, null);
725
- // Ideally we should stringify the object, but that could cause the story to break because of unescaped values in the JSON object.
726
- // This will have to do for now
727
- (0, vitest_1.expect)(source).toEqual(`<doc-button [isDisabled]="false" [label]="'Hello world'" [someDataObject]="{one: 'Hello world', two: true, three: ['a string literal with \\'double quotes\\'', 'a string literal with \\'single quotes\\'', 'a single quoted string with \\'double quotes\\'', 'a double quoted string with \\'single quotes\\'', 'a single quoted string with escaped \\'single quotes\\'', 'a double quoted string with escaped \\'double quotes\\'', 'a string literal with \\'escaped single quotes\\'', 'a string literal with \\'escaped double quotes\\''], ref: '[Circular]'}"></doc-button>`);
728
- });
729
- });
730
- });