@storybook/angular 7.0.0-alpha.0 → 7.0.0-alpha.3
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/types/client/docs/config.d.ts +0 -1
- package/dist/types/client/docs/config.js +0 -2
- package/dist/types/client/preview/angular-beta/StorybookModule.js +8 -2
- package/dist/types/client/preview/angular-beta/utils/NgComponentAnalyzer.d.ts +1 -0
- package/dist/types/client/preview/angular-beta/utils/NgComponentAnalyzer.js +11 -1
- package/dist/types/preset.d.ts +2 -1
- package/dist/types/preset.js +13 -2
- package/dist/types/server/framework-preset-angular-cli.js +1 -1
- package/package.json +13 -13
- package/dist/types/client/docs/prepareForInline.d.ts +0 -7
- package/dist/types/client/docs/prepareForInline.js +0 -37
|
@@ -2,7 +2,6 @@ import { SourceType } from '@storybook/docs-tools';
|
|
|
2
2
|
export declare const parameters: {
|
|
3
3
|
docs: {
|
|
4
4
|
inlineStories: boolean;
|
|
5
|
-
prepareForInline: (storyFn: import("@storybook/csf").PartialStoryFn<import("..").AngularFramework, import("@storybook/csf").Args>, { id, parameters, component }: import("..").StoryContext) => import("react").DetailedReactHTMLElement<import("react").HTMLAttributes<undefined>, undefined>;
|
|
6
5
|
extractArgTypes: (component: import("./types").Directive) => import("lib/api/dist/types").ArgTypes;
|
|
7
6
|
extractComponentDescription: (component: import("./types").Directive) => string;
|
|
8
7
|
source: {
|
|
@@ -4,12 +4,10 @@ exports.argTypesEnhancers = exports.decorators = exports.parameters = void 0;
|
|
|
4
4
|
const docs_tools_1 = require("@storybook/docs-tools");
|
|
5
5
|
const compodoc_1 = require("./compodoc");
|
|
6
6
|
const sourceDecorator_1 = require("./sourceDecorator");
|
|
7
|
-
const prepareForInline_1 = require("./prepareForInline");
|
|
8
7
|
exports.parameters = {
|
|
9
8
|
docs: {
|
|
10
9
|
// probably set this to true by default once it's battle-tested
|
|
11
10
|
inlineStories: false,
|
|
12
|
-
prepareForInline: prepareForInline_1.prepareForInline,
|
|
13
11
|
extractArgTypes: compodoc_1.extractArgTypes,
|
|
14
12
|
extractComponentDescription: compodoc_1.extractComponentDescription,
|
|
15
13
|
source: {
|
|
@@ -44,16 +44,22 @@ const getStorybookModuleMetadata = ({ storyFnAngular, component: annotatedCompon
|
|
|
44
44
|
* Create a component that wraps generated template and gives it props
|
|
45
45
|
*/
|
|
46
46
|
const ComponentToInject = (0, StorybookWrapperComponent_1.createStorybookWrapperComponent)(targetSelector, template, component, styles, props);
|
|
47
|
+
const isStandalone = (0, NgComponentAnalyzer_1.isStandaloneComponent)(component);
|
|
47
48
|
// Look recursively (deep) if the component is not already declared by an import module
|
|
48
49
|
const requiresComponentDeclaration = (0, NgComponentAnalyzer_1.isDeclarable)(component) &&
|
|
49
|
-
!(0, NgModulesAnalyzer_1.isComponentAlreadyDeclaredInModules)(component, moduleMetadata.declarations, moduleMetadata.imports)
|
|
50
|
+
!(0, NgModulesAnalyzer_1.isComponentAlreadyDeclaredInModules)(component, moduleMetadata.declarations, moduleMetadata.imports) &&
|
|
51
|
+
!isStandalone;
|
|
50
52
|
return {
|
|
51
53
|
declarations: [
|
|
52
54
|
...(requiresComponentDeclaration ? [component] : []),
|
|
53
55
|
ComponentToInject,
|
|
54
56
|
...(moduleMetadata.declarations ?? []),
|
|
55
57
|
],
|
|
56
|
-
imports: [
|
|
58
|
+
imports: [
|
|
59
|
+
platform_browser_1.BrowserModule,
|
|
60
|
+
...(isStandalone ? [component] : []),
|
|
61
|
+
...(moduleMetadata.imports ?? []),
|
|
62
|
+
],
|
|
57
63
|
providers: [(0, StorybookProvider_1.storyPropsProvider)(storyProps$), ...(moduleMetadata.providers ?? [])],
|
|
58
64
|
entryComponents: [...(moduleMetadata.entryComponents ?? [])],
|
|
59
65
|
schemas: [...(moduleMetadata.schemas ?? [])],
|
|
@@ -15,6 +15,7 @@ export declare type ComponentInputsOutputs = {
|
|
|
15
15
|
export declare const getComponentInputsOutputs: (component: any) => ComponentInputsOutputs;
|
|
16
16
|
export declare const isDeclarable: (component: any) => boolean;
|
|
17
17
|
export declare const isComponent: (component: any) => component is Type<unknown>;
|
|
18
|
+
export declare const isStandaloneComponent: (component: any) => component is Type<unknown>;
|
|
18
19
|
/**
|
|
19
20
|
* Returns all component decorator properties
|
|
20
21
|
* is used to get all `@Input` and `@Output` Decorator
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getComponentDecoratorMetadata = exports.getComponentPropsDecoratorMetadata = exports.isComponent = exports.isDeclarable = exports.getComponentInputsOutputs = void 0;
|
|
3
|
+
exports.getComponentDecoratorMetadata = exports.getComponentPropsDecoratorMetadata = exports.isStandaloneComponent = exports.isComponent = exports.isDeclarable = exports.getComponentInputsOutputs = void 0;
|
|
4
4
|
const core_1 = require("@angular/core");
|
|
5
5
|
const reflectionCapabilities = new core_1.ɵReflectionCapabilities();
|
|
6
6
|
/**
|
|
@@ -69,6 +69,16 @@ const isComponent = (component) => {
|
|
|
69
69
|
return (decorators || []).some((d) => d instanceof core_1.Component);
|
|
70
70
|
};
|
|
71
71
|
exports.isComponent = isComponent;
|
|
72
|
+
const isStandaloneComponent = (component) => {
|
|
73
|
+
if (!component) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
const decorators = reflectionCapabilities.annotations(component);
|
|
77
|
+
// TODO: `standalone` is only available in Angular v14. Remove cast to `any` once
|
|
78
|
+
// Angular deps are updated to v14.x.x.
|
|
79
|
+
return (decorators || []).some((d) => d instanceof core_1.Component && d.standalone);
|
|
80
|
+
};
|
|
81
|
+
exports.isStandaloneComponent = isStandaloneComponent;
|
|
72
82
|
/**
|
|
73
83
|
* Returns all component decorator properties
|
|
74
84
|
* is used to get all `@Input` and `@Output` Decorator
|
package/dist/types/preset.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { StorybookConfig } from './types';
|
|
2
2
|
export declare const previewAnnotations: StorybookConfig['previewAnnotations'];
|
|
3
3
|
export declare const addons: StorybookConfig['addons'];
|
|
4
4
|
export declare const core: (config: StorybookConfig['core']) => Promise<{
|
|
@@ -10,3 +10,4 @@ export declare const core: (config: StorybookConfig['core']) => Promise<{
|
|
|
10
10
|
enableCrashReports?: boolean;
|
|
11
11
|
crossOriginIsolated?: boolean;
|
|
12
12
|
}>;
|
|
13
|
+
export declare const typescript: (config: StorybookConfig['typescript']) => Promise<StorybookConfig['typescript']>;
|
package/dist/types/preset.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.core = exports.addons = exports.previewAnnotations = void 0;
|
|
6
|
+
exports.typescript = exports.core = exports.addons = exports.previewAnnotations = void 0;
|
|
7
|
+
const path_1 = __importDefault(require("path"));
|
|
4
8
|
const previewAnnotations = (entries = []) => [
|
|
5
9
|
...entries,
|
|
6
10
|
require.resolve('./client/preview/config'),
|
|
@@ -15,7 +19,14 @@ exports.addons = [
|
|
|
15
19
|
const core = async (config) => {
|
|
16
20
|
return {
|
|
17
21
|
...config,
|
|
18
|
-
builder: require.resolve('@storybook/builder-webpack5'),
|
|
22
|
+
builder: path_1.default.dirname(require.resolve(path_1.default.join('@storybook/builder-webpack5', 'package.json'))),
|
|
19
23
|
};
|
|
20
24
|
};
|
|
21
25
|
exports.core = core;
|
|
26
|
+
const typescript = async (config) => {
|
|
27
|
+
return {
|
|
28
|
+
...config,
|
|
29
|
+
skipBabel: true,
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.typescript = typescript;
|
|
@@ -163,7 +163,7 @@ async function getLegacyDefaultBuildOptions(options) {
|
|
|
163
163
|
project: (0, angular_read_workspace_1.getDefaultProjectName)(workspaceConfig),
|
|
164
164
|
target: 'build',
|
|
165
165
|
};
|
|
166
|
-
const { target
|
|
166
|
+
const { target } = (0, angular_read_workspace_1.findAngularProjectTarget)(workspaceConfig, browserTarget.project, browserTarget.target);
|
|
167
167
|
node_logger_1.logger.info(`=> Using angular project "${browserTarget.project}:${browserTarget.target}" for configuring Storybook`);
|
|
168
168
|
return { ...target.options };
|
|
169
169
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/angular",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.3",
|
|
4
4
|
"description": "Storybook for Angular: Develop Angular components in isolation with hot reloading.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -33,19 +33,19 @@
|
|
|
33
33
|
"prepare": "node ../../scripts/prepare.js"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@storybook/addons": "7.0.0-alpha.
|
|
37
|
-
"@storybook/api": "7.0.0-alpha.
|
|
38
|
-
"@storybook/builder-webpack5": "7.0.0-alpha.
|
|
39
|
-
"@storybook/client-logger": "7.0.0-alpha.
|
|
40
|
-
"@storybook/core-client": "7.0.0-alpha.
|
|
41
|
-
"@storybook/core-common": "7.0.0-alpha.
|
|
42
|
-
"@storybook/core-events": "7.0.0-alpha.
|
|
43
|
-
"@storybook/core-server": "7.0.0-alpha.
|
|
36
|
+
"@storybook/addons": "7.0.0-alpha.3",
|
|
37
|
+
"@storybook/api": "7.0.0-alpha.3",
|
|
38
|
+
"@storybook/builder-webpack5": "7.0.0-alpha.3",
|
|
39
|
+
"@storybook/client-logger": "7.0.0-alpha.3",
|
|
40
|
+
"@storybook/core-client": "7.0.0-alpha.3",
|
|
41
|
+
"@storybook/core-common": "7.0.0-alpha.3",
|
|
42
|
+
"@storybook/core-events": "7.0.0-alpha.3",
|
|
43
|
+
"@storybook/core-server": "7.0.0-alpha.3",
|
|
44
44
|
"@storybook/csf": "0.0.2--canary.4566f4d.1",
|
|
45
|
-
"@storybook/docs-tools": "7.0.0-alpha.
|
|
46
|
-
"@storybook/node-logger": "7.0.0-alpha.
|
|
45
|
+
"@storybook/docs-tools": "7.0.0-alpha.3",
|
|
46
|
+
"@storybook/node-logger": "7.0.0-alpha.3",
|
|
47
47
|
"@storybook/semver": "^7.3.2",
|
|
48
|
-
"@storybook/store": "7.0.0-alpha.
|
|
48
|
+
"@storybook/store": "7.0.0-alpha.3",
|
|
49
49
|
"@types/node": "^14.14.20 || ^16.0.0",
|
|
50
50
|
"@types/react": "^16.14.23",
|
|
51
51
|
"@types/react-dom": "^16.9.14",
|
|
@@ -128,5 +128,5 @@
|
|
|
128
128
|
"access": "public"
|
|
129
129
|
},
|
|
130
130
|
"builders": "dist/types/builders/builders.json",
|
|
131
|
-
"gitHead": "
|
|
131
|
+
"gitHead": "629b056190993bcee6445471b8cb27208eb401a9"
|
|
132
132
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { PartialStoryFn } from '@storybook/csf';
|
|
3
|
-
import { AngularFramework, StoryContext } from '..';
|
|
4
|
-
/**
|
|
5
|
-
* Uses the angular renderer to generate a story. Uses p-limit to run synchronously
|
|
6
|
-
*/
|
|
7
|
-
export declare const prepareForInline: (storyFn: PartialStoryFn<AngularFramework>, { id, parameters, component }: StoryContext) => React.DetailedReactHTMLElement<React.HTMLAttributes<undefined>, undefined>;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.prepareForInline = void 0;
|
|
7
|
-
const react_1 = __importDefault(require("react"));
|
|
8
|
-
const p_limit_1 = __importDefault(require("p-limit"));
|
|
9
|
-
const nanoid_1 = require("nanoid");
|
|
10
|
-
const renderer_1 = require("../../renderer");
|
|
11
|
-
const limit = (0, p_limit_1.default)(1);
|
|
12
|
-
/**
|
|
13
|
-
* Uses the angular renderer to generate a story. Uses p-limit to run synchronously
|
|
14
|
-
*/
|
|
15
|
-
const prepareForInline = (storyFn, { id, parameters, component }) => {
|
|
16
|
-
const el = react_1.default.useRef();
|
|
17
|
-
react_1.default.useEffect(() => {
|
|
18
|
-
(async () => {
|
|
19
|
-
limit(async () => {
|
|
20
|
-
const renderer = await renderer_1.rendererFactory.getRendererInstance(`${id}-${(0, nanoid_1.nanoid)(10)}`.toLowerCase(), el.current);
|
|
21
|
-
if (renderer) {
|
|
22
|
-
await renderer.render({
|
|
23
|
-
forced: false,
|
|
24
|
-
component,
|
|
25
|
-
parameters,
|
|
26
|
-
storyFnAngular: storyFn(),
|
|
27
|
-
targetDOMNode: el.current,
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
})();
|
|
32
|
-
});
|
|
33
|
-
return react_1.default.createElement('div', {
|
|
34
|
-
ref: el,
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
exports.prepareForInline = prepareForInline;
|