@storybook/angular 7.0.2 → 7.1.0-alpha.1
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/README.md +2 -2
- package/dist/client/angular-beta/AbstractRenderer.d.ts +3 -3
- package/dist/client/angular-beta/AbstractRenderer.js +11 -9
- package/dist/client/angular-beta/DocsRenderer.d.ts +1 -1
- package/dist/client/angular-beta/DocsRenderer.js +2 -2
- package/package.json +15 -15
- package/template/cli/Button.stories.ts +2 -2
- package/template/cli/Header.stories.ts +2 -2
- package/template/cli/Page.stories.ts +2 -2
package/README.md
CHANGED
|
@@ -27,12 +27,12 @@ So you can develop UI components in isolation without worrying about app specifi
|
|
|
27
27
|
|
|
28
28
|
```sh
|
|
29
29
|
cd my-angular-app
|
|
30
|
-
npx storybook init
|
|
30
|
+
npx storybook@latest init
|
|
31
31
|
```
|
|
32
32
|
|
|
33
33
|
## Setup Storybook for your Angular projects
|
|
34
34
|
|
|
35
|
-
Storybook supports Angular multi-project workspace. You can setup Storybook for each project in the workspace. When running `npx storybook init` you will be asked for which project Storybook should be set up. Essentially, during initialization, the `.storybook` folder will be created and the `angular.json` will be edited to add the Storybook configuration for the selected project. The configuration looks approximately like this:
|
|
35
|
+
Storybook supports Angular multi-project workspace. You can setup Storybook for each project in the workspace. When running `npx storybook@latest init` you will be asked for which project Storybook should be set up. Essentially, during initialization, the `.storybook` folder will be created and the `angular.json` will be edited to add the Storybook configuration for the selected project. The configuration looks approximately like this:
|
|
36
36
|
|
|
37
37
|
```json
|
|
38
38
|
// angular.json
|
|
@@ -9,16 +9,16 @@ export declare abstract class AbstractRenderer {
|
|
|
9
9
|
/**
|
|
10
10
|
* Wait and destroy the platform
|
|
11
11
|
*/
|
|
12
|
-
static resetApplications(): void;
|
|
12
|
+
static resetApplications(domNode?: HTMLElement): void;
|
|
13
13
|
/**
|
|
14
14
|
* Reset compiled components because we often want to compile the same component with
|
|
15
15
|
* more than one NgModule.
|
|
16
16
|
*/
|
|
17
17
|
protected static resetCompiledComponents: () => Promise<void>;
|
|
18
|
-
protected previousStoryRenderInfo: StoryRenderInfo
|
|
18
|
+
protected previousStoryRenderInfo: Map<HTMLElement, StoryRenderInfo>;
|
|
19
19
|
protected storyProps$: Subject<ICollection | undefined>;
|
|
20
20
|
constructor(storyId: string);
|
|
21
|
-
protected abstract beforeFullRender(): Promise<void>;
|
|
21
|
+
protected abstract beforeFullRender(domNode?: HTMLElement): Promise<void>;
|
|
22
22
|
protected abstract afterFullRender(): Promise<void>;
|
|
23
23
|
/**
|
|
24
24
|
* Bootstrap main angular module with main component or send only new `props` with storyProps$
|
|
@@ -33,21 +33,22 @@ const StorybookModule_1 = require("./StorybookModule");
|
|
|
33
33
|
const StorybookProvider_1 = require("./StorybookProvider");
|
|
34
34
|
const StorybookWrapperComponent_1 = require("./StorybookWrapperComponent");
|
|
35
35
|
const PropertyExtractor_1 = require("./utils/PropertyExtractor");
|
|
36
|
-
const applicationRefs = new
|
|
36
|
+
const applicationRefs = new Map();
|
|
37
37
|
class AbstractRenderer {
|
|
38
38
|
/**
|
|
39
39
|
* Wait and destroy the platform
|
|
40
40
|
*/
|
|
41
|
-
static resetApplications() {
|
|
41
|
+
static resetApplications(domNode) {
|
|
42
42
|
StorybookWrapperComponent_1.componentNgModules.clear();
|
|
43
|
-
applicationRefs.forEach((appRef) => {
|
|
44
|
-
if (!appRef.destroyed) {
|
|
43
|
+
applicationRefs.forEach((appRef, appDOMNode) => {
|
|
44
|
+
if (!appRef.destroyed && (!domNode || appDOMNode === domNode)) {
|
|
45
45
|
appRef.destroy();
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
constructor(storyId) {
|
|
50
50
|
this.storyId = storyId;
|
|
51
|
+
this.previousStoryRenderInfo = new Map();
|
|
51
52
|
if (typeof NODE_ENV === 'string' && NODE_ENV !== 'development') {
|
|
52
53
|
try {
|
|
53
54
|
// platform should be set after enableProdMode()
|
|
@@ -73,6 +74,7 @@ class AbstractRenderer {
|
|
|
73
74
|
const targetSelector = this.generateTargetSelectorFromStoryId(targetDOMNode.id);
|
|
74
75
|
const newStoryProps$ = new rxjs_1.BehaviorSubject(storyFnAngular.props);
|
|
75
76
|
if (!this.fullRendererRequired({
|
|
77
|
+
targetDOMNode,
|
|
76
78
|
storyFnAngular,
|
|
77
79
|
moduleMetadata: {
|
|
78
80
|
...storyFnAngular.moduleMetadata,
|
|
@@ -82,7 +84,7 @@ class AbstractRenderer {
|
|
|
82
84
|
this.storyProps$.next(storyFnAngular.props);
|
|
83
85
|
return;
|
|
84
86
|
}
|
|
85
|
-
await this.beforeFullRender();
|
|
87
|
+
await this.beforeFullRender(targetDOMNode);
|
|
86
88
|
// Complete last BehaviorSubject and set a new one for the current module
|
|
87
89
|
if (this.storyProps$) {
|
|
88
90
|
this.storyProps$.complete();
|
|
@@ -104,7 +106,7 @@ class AbstractRenderer {
|
|
|
104
106
|
...(storyFnAngular.applicationConfig?.providers ?? []),
|
|
105
107
|
],
|
|
106
108
|
});
|
|
107
|
-
applicationRefs.
|
|
109
|
+
applicationRefs.set(targetDOMNode, applicationRef);
|
|
108
110
|
await this.afterFullRender();
|
|
109
111
|
}
|
|
110
112
|
/**
|
|
@@ -130,13 +132,13 @@ class AbstractRenderer {
|
|
|
130
132
|
targetDOMNode.innerHTML = '';
|
|
131
133
|
targetDOMNode.appendChild(document.createElement(targetSelector));
|
|
132
134
|
}
|
|
133
|
-
fullRendererRequired({ storyFnAngular, moduleMetadata, forced, }) {
|
|
134
|
-
const
|
|
135
|
+
fullRendererRequired({ targetDOMNode, storyFnAngular, moduleMetadata, forced, }) {
|
|
136
|
+
const previousStoryRenderInfo = this.previousStoryRenderInfo.get(targetDOMNode);
|
|
135
137
|
const currentStoryRender = {
|
|
136
138
|
storyFnAngular,
|
|
137
139
|
moduleMetadataSnapshot: (0, telejson_1.stringify)(moduleMetadata),
|
|
138
140
|
};
|
|
139
|
-
this.previousStoryRenderInfo
|
|
141
|
+
this.previousStoryRenderInfo.set(targetDOMNode, currentStoryRender);
|
|
140
142
|
if (
|
|
141
143
|
// check `forceRender` of story RenderContext
|
|
142
144
|
!forced ||
|
|
@@ -8,6 +8,6 @@ export declare class DocsRenderer extends AbstractRenderer {
|
|
|
8
8
|
parameters: Parameters;
|
|
9
9
|
targetDOMNode: HTMLElement;
|
|
10
10
|
}): Promise<void>;
|
|
11
|
-
beforeFullRender(): Promise<void>;
|
|
11
|
+
beforeFullRender(domNode?: HTMLElement): Promise<void>;
|
|
12
12
|
afterFullRender(): Promise<void>;
|
|
13
13
|
}
|
|
@@ -30,8 +30,8 @@ class DocsRenderer extends AbstractRenderer_1.AbstractRenderer {
|
|
|
30
30
|
});
|
|
31
31
|
await super.render({ ...options, forced: false });
|
|
32
32
|
}
|
|
33
|
-
async beforeFullRender() {
|
|
34
|
-
DocsRenderer.resetApplications();
|
|
33
|
+
async beforeFullRender(domNode) {
|
|
34
|
+
DocsRenderer.resetApplications(domNode);
|
|
35
35
|
}
|
|
36
36
|
async afterFullRender() {
|
|
37
37
|
await AbstractRenderer_1.AbstractRenderer.resetCompiledComponents();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/angular",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.1.0-alpha.1",
|
|
4
4
|
"description": "Storybook for Angular: Develop Angular components in isolation with hot reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -36,20 +36,20 @@
|
|
|
36
36
|
"prep": "../../../scripts/prepare/tsc.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@storybook/builder-webpack5": "7.0.
|
|
40
|
-
"@storybook/cli": "7.0.
|
|
41
|
-
"@storybook/client-logger": "7.0.
|
|
42
|
-
"@storybook/core-client": "7.0.
|
|
43
|
-
"@storybook/core-common": "7.0.
|
|
44
|
-
"@storybook/core-events": "7.0.
|
|
45
|
-
"@storybook/core-server": "7.0.
|
|
46
|
-
"@storybook/core-webpack": "7.0.
|
|
47
|
-
"@storybook/docs-tools": "7.0.
|
|
39
|
+
"@storybook/builder-webpack5": "7.1.0-alpha.1",
|
|
40
|
+
"@storybook/cli": "7.1.0-alpha.1",
|
|
41
|
+
"@storybook/client-logger": "7.1.0-alpha.1",
|
|
42
|
+
"@storybook/core-client": "7.1.0-alpha.1",
|
|
43
|
+
"@storybook/core-common": "7.1.0-alpha.1",
|
|
44
|
+
"@storybook/core-events": "7.1.0-alpha.1",
|
|
45
|
+
"@storybook/core-server": "7.1.0-alpha.1",
|
|
46
|
+
"@storybook/core-webpack": "7.1.0-alpha.1",
|
|
47
|
+
"@storybook/docs-tools": "7.1.0-alpha.1",
|
|
48
48
|
"@storybook/global": "^5.0.0",
|
|
49
|
-
"@storybook/manager-api": "7.0.
|
|
50
|
-
"@storybook/node-logger": "7.0.
|
|
51
|
-
"@storybook/preview-api": "7.0.
|
|
52
|
-
"@storybook/types": "7.0.
|
|
49
|
+
"@storybook/manager-api": "7.1.0-alpha.1",
|
|
50
|
+
"@storybook/node-logger": "7.1.0-alpha.1",
|
|
51
|
+
"@storybook/preview-api": "7.1.0-alpha.1",
|
|
52
|
+
"@storybook/types": "7.1.0-alpha.1",
|
|
53
53
|
"@types/node": "^16.0.0",
|
|
54
54
|
"@types/react": "^16.14.34",
|
|
55
55
|
"@types/react-dom": "^16.9.14",
|
|
@@ -123,5 +123,5 @@
|
|
|
123
123
|
"bundler": {
|
|
124
124
|
"tsConfig": "tsconfig.build.json"
|
|
125
125
|
},
|
|
126
|
-
"gitHead": "
|
|
126
|
+
"gitHead": "48a1df25493b1cc26a405096e723301f4bb04b4e"
|
|
127
127
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/angular';
|
|
2
2
|
import Button from './button.component';
|
|
3
3
|
|
|
4
|
-
// More on how to set up stories at: https://storybook.js.org/docs/
|
|
4
|
+
// More on how to set up stories at: https://storybook.js.org/docs/angular/writing-stories/introduction
|
|
5
5
|
const meta: Meta<Button> = {
|
|
6
6
|
title: 'Example/Button',
|
|
7
7
|
component: Button,
|
|
@@ -22,7 +22,7 @@ const meta: Meta<Button> = {
|
|
|
22
22
|
export default meta;
|
|
23
23
|
type Story = StoryObj<Button>;
|
|
24
24
|
|
|
25
|
-
// More on writing stories with args: https://storybook.js.org/docs/
|
|
25
|
+
// More on writing stories with args: https://storybook.js.org/docs/angular/writing-stories/args
|
|
26
26
|
export const Primary: Story = {
|
|
27
27
|
args: {
|
|
28
28
|
primary: true,
|
|
@@ -8,7 +8,7 @@ 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 Autodocs entry: https://storybook.js.org/docs/
|
|
11
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/angular/writing-docs/autodocs
|
|
12
12
|
tags: ['autodocs'],
|
|
13
13
|
render: (args) => ({ props: args }),
|
|
14
14
|
decorators: [
|
|
@@ -18,7 +18,7 @@ const meta: Meta<Header> = {
|
|
|
18
18
|
}),
|
|
19
19
|
],
|
|
20
20
|
parameters: {
|
|
21
|
-
// More on how to position stories at: https://storybook.js.org/docs/
|
|
21
|
+
// More on how to position stories at: https://storybook.js.org/docs/angular/configure/story-layout
|
|
22
22
|
layout: 'fullscreen',
|
|
23
23
|
},
|
|
24
24
|
};
|
|
@@ -11,7 +11,7 @@ const meta: Meta<Page> = {
|
|
|
11
11
|
title: 'Example/Page',
|
|
12
12
|
component: Page,
|
|
13
13
|
parameters: {
|
|
14
|
-
// More on how to position stories at: https://storybook.js.org/docs/
|
|
14
|
+
// More on how to position stories at: https://storybook.js.org/docs/angular/configure/story-layout
|
|
15
15
|
layout: 'fullscreen',
|
|
16
16
|
},
|
|
17
17
|
decorators: [
|
|
@@ -31,7 +31,7 @@ export const LoggedOut: Story = {
|
|
|
31
31
|
}),
|
|
32
32
|
};
|
|
33
33
|
|
|
34
|
-
// More on interaction testing: https://storybook.js.org/docs/
|
|
34
|
+
// More on interaction testing: https://storybook.js.org/docs/angular/writing-tests/interaction-testing
|
|
35
35
|
export const LoggedIn: Story = {
|
|
36
36
|
render: (args: Page) => ({
|
|
37
37
|
props: args,
|