@storybook/angular 7.0.0-beta.4 → 7.0.0-beta.40

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 (72) hide show
  1. package/README.md +66 -0
  2. package/dist/builders/build-storybook/index.d.ts +5 -3
  3. package/dist/builders/build-storybook/index.js +7 -3
  4. package/dist/builders/build-storybook/schema.json +14 -6
  5. package/dist/builders/start-storybook/index.d.ts +5 -3
  6. package/dist/builders/start-storybook/index.js +9 -5
  7. package/dist/builders/start-storybook/schema.json +10 -5
  8. package/dist/builders/utils/run-compodoc.js +11 -27
  9. package/dist/builders/utils/run-compodoc.spec.js +42 -0
  10. package/dist/builders/utils/standalone-options.d.ts +2 -2
  11. package/dist/client/angular-beta/AbstractRenderer.d.ts +3 -3
  12. package/dist/client/angular-beta/AbstractRenderer.js +30 -32
  13. package/dist/client/angular-beta/CanvasRenderer.js +1 -1
  14. package/dist/client/angular-beta/DocsRenderer.js +5 -3
  15. package/dist/client/angular-beta/RendererFactory.js +5 -4
  16. package/dist/client/angular-beta/StorybookModule.d.ts +3 -6
  17. package/dist/client/angular-beta/StorybookModule.js +4 -45
  18. package/dist/client/angular-beta/StorybookModule.test.js +51 -36
  19. package/dist/client/angular-beta/StorybookWrapperComponent.d.ts +3 -2
  20. package/dist/client/angular-beta/StorybookWrapperComponent.js +30 -2
  21. package/dist/client/angular-beta/utils/NgComponentAnalyzer.js +1 -1
  22. package/dist/client/angular-beta/utils/NgComponentAnalyzer.test.js +43 -5
  23. package/dist/client/angular-beta/utils/NgModulesAnalyzer.d.ts +1 -1
  24. package/dist/client/angular-beta/utils/NgModulesAnalyzer.js +4 -4
  25. package/dist/client/angular-beta/utils/NgModulesAnalyzer.test.js +3 -3
  26. package/dist/client/angular-beta/utils/PropertyExtractor.d.ts +34 -0
  27. package/dist/client/angular-beta/utils/PropertyExtractor.js +72 -0
  28. package/dist/client/angular-beta/utils/PropertyExtractor.test.d.ts +1 -0
  29. package/dist/client/angular-beta/utils/PropertyExtractor.test.js +97 -0
  30. package/dist/client/decorateStory.js +1 -1
  31. package/dist/client/docs/compodoc.js +5 -7
  32. package/dist/client/docs/config.js +1 -2
  33. package/dist/client/globals.d.ts +0 -8
  34. package/dist/client/globals.js +2 -29
  35. package/dist/client/render.d.ts +1 -0
  36. package/dist/client/render.js +1 -5
  37. package/dist/client/types.d.ts +0 -2
  38. package/dist/index.mjs +13 -0
  39. package/dist/preset.mjs +26 -0
  40. package/dist/renderer.d.ts +2 -1
  41. package/dist/renderer.js +4 -2
  42. package/dist/renderer.mjs +5 -0
  43. package/dist/server/framework-preset-angular-cli.d.ts +2 -1
  44. package/dist/server/framework-preset-angular-cli.js +21 -92
  45. package/dist/server/plugins/storybook-normalize-angular-entry-plugin.js +15 -13
  46. package/dist/server/preset-options.d.ts +3 -2
  47. package/dist/types.mjs +1 -0
  48. package/package.json +46 -45
  49. package/template/cli/Button.stories.ts +1 -1
  50. package/template/cli/Header.stories.ts +2 -2
  51. package/template/cli/button.component.ts +2 -0
  52. package/template/components/index.js +2 -2
  53. package/template/stories/angular-mdx.stories.mdx +1 -1
  54. package/template/stories/basics/component-without-selector/without-selector-ng-component-outlet.stories.ts +1 -1
  55. package/template/stories/basics/component-without-selector/without-selector-ng-factory-resolver.stories.ts +1 -1
  56. package/template/stories/basics/component-without-selector/without-selector.stories.ts +1 -1
  57. package/template/stories/basics/ng-module/import-module-chip.stories.ts +23 -0
  58. package/template/stories/basics/ng-module/import-module.stories.ts +2 -13
  59. package/template/stories/core/decorators/componentWrapperDecorator/decorators.stories.ts +0 -18
  60. package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.css +13 -0
  61. package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.html +7 -0
  62. package/template/stories/core/moduleMetadata/angular-src/open-close-component/open-close.component.ts +39 -0
  63. package/template/stories/core/moduleMetadata/with-browser-animations.stories.ts +30 -0
  64. package/template/stories/core/parameters/bootstrap-options.stories.ts +1 -5
  65. package/dist/client/angular/helpers.d.ts +0 -8
  66. package/dist/client/angular/helpers.js +0 -150
  67. package/dist/server/angular-read-workspace.d.ts +0 -13
  68. package/dist/server/angular-read-workspace.js +0 -78
  69. package/dist/server/utils/normalize-asset-patterns.d.ts +0 -7
  70. package/dist/server/utils/normalize-asset-patterns.js +0 -64
  71. package/dist/server/utils/normalize-optimization.d.ts +0 -3
  72. package/dist/server/utils/normalize-optimization.js +0 -21
@@ -1,78 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findAngularProjectTarget = exports.getDefaultProjectName = exports.readAngularWorkspaceConfig = void 0;
4
- /* eslint-disable global-require */
5
- const node_1 = require("@angular-devkit/core/node");
6
- const core_1 = require("@angular-devkit/core");
7
- /**
8
- * Returns the workspace definition
9
- *
10
- * - Either from NX if it is present
11
- * - Either from `@angular-devkit/core` -> https://github.com/angular/angular-cli/tree/master/packages/angular_devkit/core
12
- */
13
- const readAngularWorkspaceConfig = async (dirToSearch) => {
14
- const host = core_1.workspaces.createWorkspaceHost(new node_1.NodeJsSyncHost());
15
- try {
16
- /**
17
- * Apologies for the following line
18
- * If there's a better way to do it, let's do it
19
- */
20
- // catch if nx.json does not exist
21
- require('@nrwl/workspace').readNxJson();
22
- const nxWorkspace = require('@nrwl/workspace').readWorkspaceConfig({
23
- format: 'angularCli',
24
- path: dirToSearch,
25
- });
26
- // Use the workspace version of nx when angular looks for the angular.json file
27
- host.readFile = (path) => {
28
- if (typeof path === 'string' && path.endsWith('angular.json')) {
29
- return Promise.resolve(JSON.stringify(nxWorkspace));
30
- }
31
- return host.readFile(path);
32
- };
33
- host.isFile = (path) => {
34
- if (typeof path === 'string' && path.endsWith('angular.json')) {
35
- return Promise.resolve(true);
36
- }
37
- return host.isFile(path);
38
- };
39
- }
40
- catch (e) {
41
- // Ignore if the client does not use NX
42
- }
43
- return (await core_1.workspaces.readWorkspace(dirToSearch, host)).workspace;
44
- };
45
- exports.readAngularWorkspaceConfig = readAngularWorkspaceConfig;
46
- const getDefaultProjectName = (workspace) => {
47
- const environmentProjectName = process.env.STORYBOOK_ANGULAR_PROJECT;
48
- if (environmentProjectName) {
49
- return environmentProjectName;
50
- }
51
- if (workspace.projects.has('storybook')) {
52
- return 'storybook';
53
- }
54
- if (workspace.extensions.defaultProject) {
55
- return workspace.extensions.defaultProject;
56
- }
57
- const firstProjectName = workspace.projects.keys().next().value;
58
- if (firstProjectName) {
59
- return firstProjectName;
60
- }
61
- throw new Error('No angular projects found');
62
- };
63
- exports.getDefaultProjectName = getDefaultProjectName;
64
- const findAngularProjectTarget = (workspace, projectName, targetName) => {
65
- if (!workspace.projects || !Object.keys(workspace.projects).length) {
66
- throw new Error('No angular projects found');
67
- }
68
- const project = workspace.projects.get(projectName);
69
- if (!project) {
70
- throw new Error(`"${projectName}" project is not found in angular.json`);
71
- }
72
- if (!project.targets.has(targetName)) {
73
- throw new Error(`"${targetName}" target is not found in "${projectName}" project`);
74
- }
75
- const target = project.targets.get(targetName);
76
- return { project, target };
77
- };
78
- exports.findAngularProjectTarget = findAngularProjectTarget;
@@ -1,7 +0,0 @@
1
- import { Path, BaseException } from '@angular-devkit/core';
2
- import { AssetPattern } from '@angular-devkit/build-angular';
3
- import { AssetPatternClass } from '@angular-devkit/build-angular/src/builders/browser/schema';
4
- export declare class MissingAssetSourceRootException extends BaseException {
5
- constructor(path: string);
6
- }
7
- export declare function normalizeAssetPatterns(assetPatterns: AssetPattern[], root: Path, projectRoot: Path, maybeSourceRoot: Path | undefined): AssetPatternClass[];
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeAssetPatterns = exports.MissingAssetSourceRootException = void 0;
4
- /**
5
- * Clone of `normalizeAssetPatterns` function from angular-cli v11.2.*
6
- * > https://github.com/angular/angular-cli/blob/de63f41d669e42ada84f94ca1795d2791b9b45cc/packages/angular_devkit/build_angular/src/utils/normalize-asset-patterns.ts
7
- *
8
- * It is not possible to use the original because arguments have changed between version 6.1.* and 11.*.* of angular-cli
9
- */
10
- const fs_1 = require("fs");
11
- const core_1 = require("@angular-devkit/core");
12
- class MissingAssetSourceRootException extends core_1.BaseException {
13
- constructor(path) {
14
- super(`The ${path} asset path must start with the project source root.`);
15
- }
16
- }
17
- exports.MissingAssetSourceRootException = MissingAssetSourceRootException;
18
- function normalizeAssetPatterns(assetPatterns, root, projectRoot, maybeSourceRoot) {
19
- // When sourceRoot is not available, we default to ${projectRoot}/src.
20
- const sourceRoot = maybeSourceRoot || (0, core_1.join)(projectRoot, 'src');
21
- const resolvedSourceRoot = (0, core_1.resolve)(root, sourceRoot);
22
- if (assetPatterns.length === 0) {
23
- return [];
24
- }
25
- return assetPatterns.map((assetPattern) => {
26
- // Normalize string asset patterns to objects.
27
- if (typeof assetPattern === 'string') {
28
- const assetPath = (0, core_1.normalize)(assetPattern);
29
- const resolvedAssetPath = (0, core_1.resolve)(root, assetPath);
30
- // Check if the string asset is within sourceRoot.
31
- if (!resolvedAssetPath.startsWith(resolvedSourceRoot)) {
32
- throw new MissingAssetSourceRootException(assetPattern);
33
- }
34
- let glob;
35
- let input;
36
- let isDirectory = false;
37
- try {
38
- isDirectory = (0, fs_1.statSync)((0, core_1.getSystemPath)(resolvedAssetPath)).isDirectory();
39
- }
40
- catch {
41
- isDirectory = true;
42
- }
43
- if (isDirectory) {
44
- // Folders get a recursive star glob.
45
- glob = '**/*';
46
- // Input directory is their original path.
47
- input = assetPath;
48
- }
49
- else {
50
- // Files are their own glob.
51
- glob = (0, core_1.basename)(assetPath);
52
- // Input directory is their original dirname.
53
- input = (0, core_1.dirname)(assetPath);
54
- }
55
- // Output directory for both is the relative path from source root to input.
56
- const output = (0, core_1.relative)(resolvedSourceRoot, (0, core_1.resolve)(root, input));
57
- // Return the asset pattern in object format.
58
- return { glob, input, output };
59
- }
60
- // It's already an AssetPatternObject, no need to convert.
61
- return assetPattern;
62
- });
63
- }
64
- exports.normalizeAssetPatterns = normalizeAssetPatterns;
@@ -1,3 +0,0 @@
1
- import { OptimizationUnion } from '@angular-devkit/build-angular';
2
- import { NormalizedOptimizationOptions } from '@angular-devkit/build-angular/src/utils/normalize-optimization';
3
- export declare const normalizeOptimization: (options: OptimizationUnion) => NormalizedOptimizationOptions;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeOptimization = void 0;
4
- const module_is_available_1 = require("./module-is-available");
5
- const importAngularCliNormalizeOptimization = () => {
6
- // First we look for webpack config according to directory structure of Angular
7
- // present since the version 7.2.0
8
- if ((0, module_is_available_1.moduleIsAvailable)('@angular-devkit/build-angular/src/utils/normalize-optimization')) {
9
- // eslint-disable-next-line global-require
10
- return require('@angular-devkit/build-angular/src/utils/normalize-optimization');
11
- }
12
- return undefined;
13
- };
14
- const normalizeOptimization = (options) => {
15
- if (importAngularCliNormalizeOptimization()) {
16
- return importAngularCliNormalizeOptimization().normalizeOptimization(options);
17
- }
18
- // Best effort to stay compatible with 6.1.*
19
- return options;
20
- };
21
- exports.normalizeOptimization = normalizeOptimization;