@storybook/angular 7.0.0-beta.2 → 7.0.0-beta.21
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.
- package/dist/builders/build-storybook/schema.json +1 -1
- package/dist/builders/utils/run-compodoc.js +2 -2
- package/dist/builders/utils/run-compodoc.spec.js +42 -0
- package/dist/client/angular/helpers.js +2 -5
- package/dist/client/docs/compodoc.js +5 -7
- package/dist/client/docs/config.js +1 -2
- package/dist/client/globals.js +2 -6
- package/dist/index.mjs +13 -0
- package/dist/preset.mjs +26 -0
- package/dist/renderer.mjs +4 -0
- package/dist/server/plugins/storybook-normalize-angular-entry-plugin.js +15 -13
- package/dist/types.mjs +1 -0
- package/package.json +22 -17
- package/template/cli/Button.stories.ts +1 -1
- package/template/cli/Header.stories.ts +2 -2
- package/template/components/index.js +2 -2
- package/template/stories/angular-mdx.stories.mdx +1 -1
- package/template/stories/basics/component-without-selector/without-selector-ng-component-outlet.stories.ts +1 -1
- package/template/stories/basics/component-without-selector/without-selector-ng-factory-resolver.stories.ts +1 -1
- package/template/stories/basics/component-without-selector/without-selector.stories.ts +1 -1
|
@@ -28,6 +28,7 @@ const child_process_1 = require("child_process");
|
|
|
28
28
|
const rxjs_1 = require("rxjs");
|
|
29
29
|
const path = __importStar(require("path"));
|
|
30
30
|
const hasTsConfigArg = (args) => args.indexOf('-p') !== -1;
|
|
31
|
+
const hasOutputArg = (args) => args.indexOf('-d') !== -1 || args.indexOf('--output') !== -1;
|
|
31
32
|
// path.relative is necessary to workaround a compodoc issue with
|
|
32
33
|
// absolute paths on windows machines
|
|
33
34
|
const toRelativePath = (pathToTsConfig) => {
|
|
@@ -40,8 +41,7 @@ const runCompodoc = ({ compodocArgs, tsconfig }, context) => {
|
|
|
40
41
|
'compodoc',
|
|
41
42
|
// Default options
|
|
42
43
|
...(hasTsConfigArg(compodocArgs) ? [] : ['-p', tsConfigPath]),
|
|
43
|
-
'-d',
|
|
44
|
-
`${context.workspaceRoot}`,
|
|
44
|
+
...(hasOutputArg(compodocArgs) ? [] : ['-d', `${context.workspaceRoot}`]),
|
|
45
45
|
...compodocArgs,
|
|
46
46
|
];
|
|
47
47
|
try {
|
|
@@ -56,4 +56,46 @@ describe('runCompodoc', () => {
|
|
|
56
56
|
shell: true,
|
|
57
57
|
});
|
|
58
58
|
});
|
|
59
|
+
it('should run compodoc with default output folder.', async () => {
|
|
60
|
+
runCompodoc({
|
|
61
|
+
compodocArgs: [],
|
|
62
|
+
tsconfig: 'path/to/tsconfig.json',
|
|
63
|
+
}, {
|
|
64
|
+
workspaceRoot: 'path/to/project',
|
|
65
|
+
logger: builderContextLoggerMock,
|
|
66
|
+
})
|
|
67
|
+
.pipe((0, operators_1.take)(1))
|
|
68
|
+
.subscribe();
|
|
69
|
+
expect(cpSpawnMock.spawn).toHaveBeenCalledWith('npx', ['compodoc', '-p', 'path/to/tsconfig.json', '-d', 'path/to/project'], {
|
|
70
|
+
cwd: 'path/to/project',
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
it('should run with custom output folder specified with --output compodocArgs', async () => {
|
|
74
|
+
runCompodoc({
|
|
75
|
+
compodocArgs: ['--output', 'path/to/customFolder'],
|
|
76
|
+
tsconfig: 'path/to/tsconfig.json',
|
|
77
|
+
}, {
|
|
78
|
+
workspaceRoot: 'path/to/project',
|
|
79
|
+
logger: builderContextLoggerMock,
|
|
80
|
+
})
|
|
81
|
+
.pipe((0, operators_1.take)(1))
|
|
82
|
+
.subscribe();
|
|
83
|
+
expect(cpSpawnMock.spawn).toHaveBeenCalledWith('npx', ['compodoc', '-p', 'path/to/tsconfig.json', '--output', 'path/to/customFolder'], {
|
|
84
|
+
cwd: 'path/to/project',
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
it('should run with custom output folder specified with -d compodocArgs', async () => {
|
|
88
|
+
runCompodoc({
|
|
89
|
+
compodocArgs: ['-d', 'path/to/customFolder'],
|
|
90
|
+
tsconfig: 'path/to/tsconfig.json',
|
|
91
|
+
}, {
|
|
92
|
+
workspaceRoot: 'path/to/project',
|
|
93
|
+
logger: builderContextLoggerMock,
|
|
94
|
+
})
|
|
95
|
+
.pipe((0, operators_1.take)(1))
|
|
96
|
+
.subscribe();
|
|
97
|
+
expect(cpSpawnMock.spawn).toHaveBeenCalledWith('npx', ['compodoc', '-p', 'path/to/tsconfig.json', '-d', 'path/to/customFolder'], {
|
|
98
|
+
cwd: 'path/to/project',
|
|
99
|
+
});
|
|
100
|
+
});
|
|
59
101
|
});
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.renderNgApp = void 0;
|
|
7
|
-
const global_1 =
|
|
4
|
+
const global_1 = require("@storybook/global");
|
|
8
5
|
const core_1 = require("@angular/core");
|
|
9
6
|
const forms_1 = require("@angular/forms");
|
|
10
7
|
const platform_browser_dynamic_1 = require("@angular/platform-browser-dynamic");
|
|
@@ -12,7 +9,7 @@ const platform_browser_1 = require("@angular/platform-browser");
|
|
|
12
9
|
const rxjs_1 = require("rxjs");
|
|
13
10
|
const app_component_1 = require("./app.component");
|
|
14
11
|
const app_token_1 = require("./app.token");
|
|
15
|
-
const { document } = global_1.
|
|
12
|
+
const { document } = global_1.global;
|
|
16
13
|
let platform = null;
|
|
17
14
|
let promises = [];
|
|
18
15
|
let storyData = new rxjs_1.ReplaySubject(1);
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
/* eslint-disable no-underscore-dangle */
|
|
3
|
-
/* global window */
|
|
4
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
3
|
exports.extractComponentDescription = exports.extractArgTypes = exports.extractArgTypesFromData = exports.extractType = exports.findComponentByName = exports.checkValidCompodocJson = exports.checkValidComponentOrDirective = exports.getCompodocJson = exports.setCompodocJson = exports.isMethod = void 0;
|
|
4
|
+
/* eslint-disable no-underscore-dangle */
|
|
5
|
+
const global_1 = require("@storybook/global");
|
|
6
6
|
const client_logger_1 = require("@storybook/client-logger");
|
|
7
7
|
const isMethod = (methodOrProp) => {
|
|
8
8
|
return methodOrProp.args !== undefined;
|
|
9
9
|
};
|
|
10
10
|
exports.isMethod = isMethod;
|
|
11
11
|
const setCompodocJson = (compodocJson) => {
|
|
12
|
-
|
|
13
|
-
window.__STORYBOOK_COMPODOC_JSON__ = compodocJson;
|
|
12
|
+
global_1.global.__STORYBOOK_COMPODOC_JSON__ = compodocJson;
|
|
14
13
|
};
|
|
15
14
|
exports.setCompodocJson = setCompodocJson;
|
|
16
|
-
|
|
17
|
-
const getCompodocJson = () => window.__STORYBOOK_COMPODOC_JSON__;
|
|
15
|
+
const getCompodocJson = () => global_1.global.__STORYBOOK_COMPODOC_JSON__;
|
|
18
16
|
exports.getCompodocJson = getCompodocJson;
|
|
19
17
|
const checkValidComponentOrDirective = (component) => {
|
|
20
18
|
if (!component.name) {
|
|
@@ -167,7 +165,7 @@ const extractDefaultValueFromComments = (property, value) => {
|
|
|
167
165
|
let commentValue = value;
|
|
168
166
|
property.jsdoctags.forEach((tag) => {
|
|
169
167
|
if (['default', 'defaultvalue'].includes(tag.tagName.escapedText)) {
|
|
170
|
-
const dom = new
|
|
168
|
+
const dom = new global_1.global.DOMParser().parseFromString(tag.comment, 'text/html');
|
|
171
169
|
commentValue = dom.body.textContent;
|
|
172
170
|
}
|
|
173
171
|
});
|
|
@@ -6,8 +6,7 @@ const compodoc_1 = require("./compodoc");
|
|
|
6
6
|
const sourceDecorator_1 = require("./sourceDecorator");
|
|
7
7
|
exports.parameters = {
|
|
8
8
|
docs: {
|
|
9
|
-
|
|
10
|
-
inlineStories: false,
|
|
9
|
+
inlineStories: true,
|
|
11
10
|
extractArgTypes: compodoc_1.extractArgTypes,
|
|
12
11
|
extractComponentDescription: compodoc_1.extractComponentDescription,
|
|
13
12
|
source: {
|
package/dist/client/globals.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const global_1 =
|
|
3
|
+
const global_1 = require("@storybook/global");
|
|
7
4
|
/**
|
|
8
5
|
* This file includes polyfills needed by Angular and is loaded before the app.
|
|
9
6
|
* You can add your own extra polyfills to this file.
|
|
@@ -63,5 +60,4 @@ require("zone.js/dist/zone"); // Included with Angular CLI.
|
|
|
63
60
|
* Need to import at least one locale-data with intl.
|
|
64
61
|
*/
|
|
65
62
|
// import 'intl/locale-data/jsonp/en';
|
|
66
|
-
|
|
67
|
-
globalWindow.STORYBOOK_ENV = 'angular';
|
|
63
|
+
global_1.global.STORYBOOK_ENV = 'angular';
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './client/index';
|
|
2
|
+
export * from './types';
|
|
3
|
+
/*
|
|
4
|
+
* ATTENTION:
|
|
5
|
+
* - moduleMetadata
|
|
6
|
+
* - NgModuleMetadata
|
|
7
|
+
* - ICollection
|
|
8
|
+
*
|
|
9
|
+
* These typings are coped out of decorators.d.ts and types.d.ts in order to fix a bug with tsc
|
|
10
|
+
* It was imported out of dist before which was not the proper way of exporting public API
|
|
11
|
+
*
|
|
12
|
+
* This can be fixed by migrating app/angular to typescript
|
|
13
|
+
*/
|
package/dist/preset.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
export const addons = [
|
|
3
|
+
require.resolve('./server/framework-preset-angular-cli'),
|
|
4
|
+
require.resolve('./server/framework-preset-angular-ivy'),
|
|
5
|
+
require.resolve('./server/framework-preset-angular-docs'),
|
|
6
|
+
];
|
|
7
|
+
export const previewAnnotations = (entries = []) => [
|
|
8
|
+
...entries,
|
|
9
|
+
require.resolve('./client/config'),
|
|
10
|
+
];
|
|
11
|
+
export const core = async (config, options) => {
|
|
12
|
+
const framework = await options.presets.apply('framework');
|
|
13
|
+
return {
|
|
14
|
+
...config,
|
|
15
|
+
builder: {
|
|
16
|
+
name: path.dirname(require.resolve(path.join('@storybook/builder-webpack5', 'package.json'))),
|
|
17
|
+
options: typeof framework === 'string' ? {} : framework.options.builder || {},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export const typescript = async (config) => {
|
|
22
|
+
return {
|
|
23
|
+
...config,
|
|
24
|
+
skipBabel: true,
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { computesTemplateSourceFromComponent } from './client/angular-beta/ComputesTemplateFromComponent';
|
|
2
|
+
export { rendererFactory } from './client/render';
|
|
3
|
+
export { AbstractRenderer } from './client/angular-beta/AbstractRenderer';
|
|
4
|
+
export { getStorybookModuleMetadata } from './client/angular-beta/StorybookModule';
|
|
@@ -25,19 +25,21 @@ class StorybookNormalizeAngularEntryPlugin {
|
|
|
25
25
|
this.options = options;
|
|
26
26
|
}
|
|
27
27
|
apply(compiler) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
compiler.hooks.environment.tap(PLUGIN_NAME, () => {
|
|
29
|
+
const webpackOptions = compiler.options;
|
|
30
|
+
const entry = typeof webpackOptions.entry === 'function' ? webpackOptions.entry() : webpackOptions.entry;
|
|
31
|
+
webpackOptions.entry = async () => {
|
|
32
|
+
const entryResult = await entry;
|
|
33
|
+
if (entryResult.main && entryResult.styles) {
|
|
34
|
+
return {
|
|
35
|
+
main: {
|
|
36
|
+
import: Array.from(new Set([...entryResult.main.import, ...entryResult.styles.import])),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return entry;
|
|
41
|
+
};
|
|
42
|
+
});
|
|
41
43
|
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {
|
|
42
44
|
this.compilation = compilation;
|
|
43
45
|
});
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/angular",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.21",
|
|
4
4
|
"description": "Storybook for Angular: Develop Angular components in isolation with hot reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -21,31 +21,34 @@
|
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"main": "dist/index.js",
|
|
24
|
+
"module": "dist/index.mjs",
|
|
24
25
|
"types": "dist/index.d.ts",
|
|
25
26
|
"files": [
|
|
26
27
|
"dist/**/*",
|
|
27
28
|
"template/**/*",
|
|
28
29
|
"README.md",
|
|
29
30
|
"*.js",
|
|
31
|
+
"*.mjs",
|
|
30
32
|
"*.d.ts"
|
|
31
33
|
],
|
|
32
34
|
"scripts": {
|
|
33
35
|
"check": "../../../scripts/node_modules/.bin/tsc",
|
|
34
|
-
"prep": "
|
|
36
|
+
"prep": "../../../scripts/prepare/tsc.ts"
|
|
35
37
|
},
|
|
36
38
|
"dependencies": {
|
|
37
|
-
"@storybook/builder-webpack5": "7.0.0-beta.
|
|
38
|
-
"@storybook/client-logger": "7.0.0-beta.
|
|
39
|
-
"@storybook/core-client": "7.0.0-beta.
|
|
40
|
-
"@storybook/core-common": "7.0.0-beta.
|
|
41
|
-
"@storybook/core-events": "7.0.0-beta.
|
|
42
|
-
"@storybook/core-server": "7.0.0-beta.
|
|
43
|
-
"@storybook/core-webpack": "7.0.0-beta.
|
|
44
|
-
"@storybook/docs-tools": "7.0.0-beta.
|
|
45
|
-
"@storybook/
|
|
46
|
-
"@storybook/
|
|
47
|
-
"@storybook/
|
|
48
|
-
"@storybook/
|
|
39
|
+
"@storybook/builder-webpack5": "7.0.0-beta.21",
|
|
40
|
+
"@storybook/client-logger": "7.0.0-beta.21",
|
|
41
|
+
"@storybook/core-client": "7.0.0-beta.21",
|
|
42
|
+
"@storybook/core-common": "7.0.0-beta.21",
|
|
43
|
+
"@storybook/core-events": "7.0.0-beta.21",
|
|
44
|
+
"@storybook/core-server": "7.0.0-beta.21",
|
|
45
|
+
"@storybook/core-webpack": "7.0.0-beta.21",
|
|
46
|
+
"@storybook/docs-tools": "7.0.0-beta.21",
|
|
47
|
+
"@storybook/global": "^5.0.0",
|
|
48
|
+
"@storybook/manager-api": "7.0.0-beta.21",
|
|
49
|
+
"@storybook/node-logger": "7.0.0-beta.21",
|
|
50
|
+
"@storybook/preview-api": "7.0.0-beta.21",
|
|
51
|
+
"@storybook/types": "7.0.0-beta.21",
|
|
49
52
|
"@types/node": "^16.0.0",
|
|
50
53
|
"@types/react": "^16.14.34",
|
|
51
54
|
"@types/react-dom": "^16.9.14",
|
|
@@ -53,7 +56,6 @@
|
|
|
53
56
|
"@types/webpack-env": "^1.18.0",
|
|
54
57
|
"core-js": "^3.8.2",
|
|
55
58
|
"find-up": "^5.0.0",
|
|
56
|
-
"global": "^4.4.0",
|
|
57
59
|
"read-pkg-up": "^7.0.1",
|
|
58
60
|
"semver": "^7.3.7",
|
|
59
61
|
"telejson": "^7.0.3",
|
|
@@ -116,11 +118,14 @@
|
|
|
116
118
|
}
|
|
117
119
|
},
|
|
118
120
|
"engines": {
|
|
119
|
-
"node": ">=
|
|
121
|
+
"node": ">=16.0.0"
|
|
120
122
|
},
|
|
121
123
|
"publishConfig": {
|
|
122
124
|
"access": "public"
|
|
123
125
|
},
|
|
124
126
|
"builders": "dist/builders/builders.json",
|
|
125
|
-
"
|
|
127
|
+
"bundler": {
|
|
128
|
+
"tsConfig": "tsconfig.build.json"
|
|
129
|
+
},
|
|
130
|
+
"gitHead": "fb45d854842e10fa119a65c628333e3a5d495e77"
|
|
126
131
|
}
|
|
@@ -8,8 +8,8 @@ import Header from './header.component';
|
|
|
8
8
|
const meta: Meta<Header> = {
|
|
9
9
|
title: 'Example/Header',
|
|
10
10
|
component: Header,
|
|
11
|
-
// This component will have an automatically generated
|
|
12
|
-
tags: ['
|
|
11
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/7.0/angular/writing-docs/docs-page
|
|
12
|
+
tags: ['autodocs'],
|
|
13
13
|
render: (args) => ({ props: args }),
|
|
14
14
|
decorators: [
|
|
15
15
|
moduleMetadata({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { global } from '@storybook/global';
|
|
2
2
|
|
|
3
3
|
import Button from './button.component';
|
|
4
4
|
import Html from './html.component';
|
|
5
5
|
import Pre from './pre.component';
|
|
6
6
|
import Form from './form.component';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
global.Components = { Button, Html, Pre, Form };
|
|
@@ -59,7 +59,7 @@ WithCustomNgComponentOutletWrapper.argTypes = {
|
|
|
59
59
|
name: { control: 'text' },
|
|
60
60
|
color: { control: 'color' },
|
|
61
61
|
};
|
|
62
|
-
WithCustomNgComponentOutletWrapper.args = { name: '
|
|
62
|
+
WithCustomNgComponentOutletWrapper.args = { name: 'Color', color: 'green' };
|
|
63
63
|
WithCustomNgComponentOutletWrapper.decorators = [
|
|
64
64
|
moduleMetadata({
|
|
65
65
|
declarations: [NgComponentOutletWrapperComponent],
|
|
@@ -59,7 +59,7 @@ WithComponentFactoryResolver.argTypes = {
|
|
|
59
59
|
name: { control: 'text' },
|
|
60
60
|
color: { control: 'color' },
|
|
61
61
|
};
|
|
62
|
-
WithComponentFactoryResolver.args = { name: '
|
|
62
|
+
WithComponentFactoryResolver.args = { name: 'Color', color: 'chartreuse' };
|
|
63
63
|
WithComponentFactoryResolver.decorators = [
|
|
64
64
|
moduleMetadata({
|
|
65
65
|
declarations: [ComponentFactoryWrapperComponent],
|