@storybook/angular 6.4.0-beta.3 → 6.4.0-beta.30

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.
@@ -3,7 +3,7 @@ declare type RenderType = 'canvas' | 'docs';
3
3
  export declare class RendererFactory {
4
4
  private lastRenderType;
5
5
  private rendererMap;
6
- getRendererInstance(storyId: string, targetDOMNode: HTMLElement): Promise<AbstractRenderer>;
6
+ getRendererInstance(storyId: string, targetDOMNode: HTMLElement): Promise<AbstractRenderer | null>;
7
7
  private buildRenderer;
8
8
  }
9
9
  export declare const getRenderType: (targetDOMNode: HTMLElement) => RenderType;
@@ -1,4 +1,6 @@
1
+ import './globals';
1
2
  export { render, renderToDOM } from './render';
3
+ export { decorateStory } from './decorateStory';
2
4
  export declare const parameters: {
3
5
  framework: string;
4
6
  };
@@ -1,3 +1,4 @@
1
1
  import { DecoratorFunction, LegacyStoryFn } from '@storybook/csf';
2
2
  import { AngularFramework } from './types-6-0';
3
3
  export default function decorateStory(mainStoryFn: LegacyStoryFn<AngularFramework>, decorators: DecoratorFunction<AngularFramework>[]): LegacyStoryFn<AngularFramework>;
4
+ export { decorateStory };
@@ -2,5 +2,5 @@ import { Type } from '@angular/core';
2
2
  import { DecoratorFunction, StoryContext } from '@storybook/csf';
3
3
  import { ICollection, NgModuleMetadata } from './types';
4
4
  import { AngularFramework } from './types-6-0';
5
- export declare const moduleMetadata: (metadata: Partial<NgModuleMetadata>) => DecoratorFunction<AngularFramework>;
6
- export declare const componentWrapperDecorator: (element: Type<unknown> | ((story: string) => string), props?: ICollection | ((storyContext: StoryContext<AngularFramework>) => ICollection)) => DecoratorFunction<AngularFramework>;
5
+ export declare const moduleMetadata: <TArgs = any>(metadata: Partial<NgModuleMetadata>) => DecoratorFunction<AngularFramework, TArgs>;
6
+ export declare const componentWrapperDecorator: <TArgs = any>(element: Type<unknown> | ((story: string) => string), props?: ICollection | ((storyContext: StoryContext<AngularFramework, TArgs>) => ICollection)) => DecoratorFunction<AngularFramework, TArgs>;
@@ -27,4 +27,4 @@ export declare type AngularCliWebpackConfig = {
27
27
  * Uses angular cli to extract webpack configuration.
28
28
  * The `AngularCliWebpackConfig` type lists the parts used by storybook
29
29
  */
30
- export declare function extractAngularCliWebpackConfig(dirToSearch: string, project: workspaces.ProjectDefinition, target: workspaces.TargetDefinition): Promise<AngularCliWebpackConfig>;
30
+ export declare function extractAngularCliWebpackConfig(dirToSearch: string, project: workspaces.ProjectDefinition, target: workspaces.TargetDefinition, confName?: string): Promise<AngularCliWebpackConfig>;
@@ -0,0 +1,3 @@
1
+ import { StorybookConfig } from '@storybook/core-common';
2
+ export declare const config: StorybookConfig['config'];
3
+ export declare const addons: StorybookConfig['addons'];
@@ -3,7 +3,7 @@ declare type RenderType = 'canvas' | 'docs';
3
3
  export declare class RendererFactory {
4
4
  private lastRenderType;
5
5
  private rendererMap;
6
- getRendererInstance(storyId: string, targetDOMNode: HTMLElement): Promise<AbstractRenderer>;
6
+ getRendererInstance(storyId: string, targetDOMNode: HTMLElement): Promise<AbstractRenderer | null>;
7
7
  private buildRenderer;
8
8
  }
9
9
  export declare const getRenderType: (targetDOMNode: HTMLElement) => RenderType;
@@ -50,6 +50,12 @@ var RendererFactory = /** @class */ (function () {
50
50
  return __generator(this, function (_a) {
51
51
  switch (_a.label) {
52
52
  case 0:
53
+ // do nothing if the target node is null
54
+ // fix a problem when the docs asks 2 times the same component at the same time
55
+ // the 1st targetDOMNode of the 1st requested rendering becomes null 🤷‍♂️
56
+ if (targetDOMNode === null) {
57
+ return [2 /*return*/, null];
58
+ }
53
59
  renderType = exports.getRenderType(targetDOMNode);
54
60
  if (!(this.lastRenderType && this.lastRenderType !== renderType)) return [3 /*break*/, 2];
55
61
  return [4 /*yield*/, AbstractRenderer_1.AbstractRenderer.resetPlatformBrowserDynamic()];
@@ -45,7 +45,8 @@ exports.getComponentInputsOutputs = function (component) {
45
45
  // Filters properties that have the same name as the one present in the @Component property
46
46
  return Object.entries(componentPropsMetadata).reduce(function (previousValue, _a) {
47
47
  var _b, _c;
48
- var propertyName = _a[0], value = _a[1][0];
48
+ var propertyName = _a[0], values = _a[1];
49
+ var value = values.find(function (v) { return v instanceof core_1.Input || v instanceof core_1.Output; });
49
50
  if (value instanceof core_1.Input) {
50
51
  var inputToAdd = {
51
52
  propName: propertyName,
@@ -1,4 +1,6 @@
1
+ import './globals';
1
2
  export { render, renderToDOM } from './render';
3
+ export { decorateStory } from './decorateStory';
2
4
  export declare const parameters: {
3
5
  framework: string;
4
6
  };
@@ -1,7 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parameters = void 0;
4
+ require("./globals");
4
5
  var render_1 = require("./render");
5
6
  Object.defineProperty(exports, "render", { enumerable: true, get: function () { return render_1.render; } });
6
7
  Object.defineProperty(exports, "renderToDOM", { enumerable: true, get: function () { return render_1.renderToDOM; } });
8
+ var decorateStory_1 = require("./decorateStory");
9
+ Object.defineProperty(exports, "decorateStory", { enumerable: true, get: function () { return decorateStory_1.decorateStory; } });
7
10
  exports.parameters = { framework: 'angular' };
@@ -1,3 +1,4 @@
1
1
  import { DecoratorFunction, LegacyStoryFn } from '@storybook/csf';
2
2
  import { AngularFramework } from './types-6-0';
3
3
  export default function decorateStory(mainStoryFn: LegacyStoryFn<AngularFramework>, decorators: DecoratorFunction<AngularFramework>[]): LegacyStoryFn<AngularFramework>;
4
+ export { decorateStory };
@@ -18,6 +18,7 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
18
18
  return r;
19
19
  };
20
20
  Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.decorateStory = void 0;
21
22
  var store_1 = require("@storybook/store");
22
23
  var ComputesTemplateFromComponent_1 = require("./angular-beta/ComputesTemplateFromComponent");
23
24
  function decorateStory(mainStoryFn, decorators) {
@@ -30,6 +31,7 @@ function decorateStory(mainStoryFn, decorators) {
30
31
  return returnDecorators;
31
32
  }
32
33
  exports.default = decorateStory;
34
+ exports.decorateStory = decorateStory;
33
35
  var prepareMain = function (story, context) {
34
36
  var _a;
35
37
  var template = story.template;
@@ -2,5 +2,5 @@ import { Type } from '@angular/core';
2
2
  import { DecoratorFunction, StoryContext } from '@storybook/csf';
3
3
  import { ICollection, NgModuleMetadata } from './types';
4
4
  import { AngularFramework } from './types-6-0';
5
- export declare const moduleMetadata: (metadata: Partial<NgModuleMetadata>) => DecoratorFunction<AngularFramework>;
6
- export declare const componentWrapperDecorator: (element: Type<unknown> | ((story: string) => string), props?: ICollection | ((storyContext: StoryContext<AngularFramework>) => ICollection)) => DecoratorFunction<AngularFramework>;
5
+ export declare const moduleMetadata: <TArgs = any>(metadata: Partial<NgModuleMetadata>) => DecoratorFunction<AngularFramework, TArgs>;
6
+ export declare const componentWrapperDecorator: <TArgs = any>(element: Type<unknown> | ((story: string) => string), props?: ICollection | ((storyContext: StoryContext<AngularFramework, TArgs>) => ICollection)) => DecoratorFunction<AngularFramework, TArgs>;
@@ -21,6 +21,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
21
  exports.componentWrapperDecorator = exports.moduleMetadata = void 0;
22
22
  var ComputesTemplateFromComponent_1 = require("./angular-beta/ComputesTemplateFromComponent");
23
23
  var NgComponentAnalyzer_1 = require("./angular-beta/utils/NgComponentAnalyzer");
24
+ // We use `any` here as the default type rather than `Args` because we need something that is
25
+ // castable to any component-specific args type when the user is being careful.
24
26
  exports.moduleMetadata = function (metadata) { return function (storyFn) {
25
27
  var story = storyFn();
26
28
  var storyMetadata = story.moduleMetadata || {};
@@ -12,6 +12,33 @@
12
12
  }
13
13
  }
14
14
  },
15
+ "no-confs-project": {
16
+ "root": "",
17
+ "architect": {
18
+ "target-build": {
19
+ "options": {
20
+ "tsConfig": "src/tsconfig.app.json",
21
+ "assets": []
22
+ }
23
+ }
24
+ }
25
+ },
26
+ "no-target-conf-project": {
27
+ "root": "",
28
+ "architect": {
29
+ "target-build": {
30
+ "options": {
31
+ "tsConfig": "src/tsconfig.app.json",
32
+ "assets": []
33
+ },
34
+ "configurations": {
35
+ "other-conf": {
36
+ "styles": ["src/styles.css"]
37
+ }
38
+ }
39
+ }
40
+ }
41
+ },
15
42
  "target-project": {
16
43
  "root": "",
17
44
  "architect": {
@@ -19,6 +46,11 @@
19
46
  "options": {
20
47
  "tsConfig": "src/tsconfig.app.json",
21
48
  "assets": []
49
+ },
50
+ "configurations": {
51
+ "target-conf": {
52
+ "styles": ["src/styles.css"]
53
+ }
22
54
  }
23
55
  }
24
56
  }
@@ -27,4 +27,4 @@ export declare type AngularCliWebpackConfig = {
27
27
  * Uses angular cli to extract webpack configuration.
28
28
  * The `AngularCliWebpackConfig` type lists the parts used by storybook
29
29
  */
30
- export declare function extractAngularCliWebpackConfig(dirToSearch: string, project: workspaces.ProjectDefinition, target: workspaces.TargetDefinition): Promise<AngularCliWebpackConfig>;
30
+ export declare function extractAngularCliWebpackConfig(dirToSearch: string, project: workspaces.ProjectDefinition, target: workspaces.TargetDefinition, confName?: string): Promise<AngularCliWebpackConfig>;
@@ -122,12 +122,22 @@ var importAngularCliReadTsconfigUtil = function () {
122
122
  }
123
123
  throw new Error('ReadTsconfig not found in "@angular-devkit/build-angular"');
124
124
  };
125
- var buildWebpackConfigOptions = function (dirToSearch, project, target) { return __awaiter(void 0, void 0, void 0, function () {
126
- var _a, projectBuildOptions, requiredOptions, workspaceRootNormalized, projectRootNormalized, sourceRootNormalized, tsConfigPath, tsConfig, ts, scriptTarget, buildOptions;
127
- return __generator(this, function (_b) {
128
- switch (_b.label) {
125
+ var buildWebpackConfigOptions = function (dirToSearch, project, target, confName) { return __awaiter(void 0, void 0, void 0, function () {
126
+ var conf, projectBuildOptions, requiredOptions, workspaceRootNormalized, projectRootNormalized, sourceRootNormalized, tsConfigPath, tsConfig, ts, scriptTarget, buildOptions;
127
+ return __generator(this, function (_a) {
128
+ switch (_a.label) {
129
129
  case 0:
130
- _a = target.options, projectBuildOptions = _a === void 0 ? {} : _a;
130
+ conf = {};
131
+ if (confName) {
132
+ if (!target.configurations) {
133
+ throw new Error('Missing "configurations" section in project target');
134
+ }
135
+ if (!target.configurations[confName]) {
136
+ throw new Error("Missing required configuration in project target. Check \"" + confName + "\"");
137
+ }
138
+ conf = target.configurations[confName];
139
+ }
140
+ projectBuildOptions = __assign(__assign({}, target.options), conf);
131
141
  requiredOptions = ['tsConfig'];
132
142
  if (!requiredOptions.every(function (key) { return !!projectBuildOptions[key]; })) {
133
143
  throw new Error("Missing required options in project target. Check \"" + requiredOptions.join(', ') + "\"");
@@ -141,7 +151,7 @@ var buildWebpackConfigOptions = function (dirToSearch, project, target) { return
141
151
  tsConfig = importAngularCliReadTsconfigUtil().readTsconfig(tsConfigPath);
142
152
  return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require('typescript')); })];
143
153
  case 1:
144
- ts = _b.sent();
154
+ ts = _a.sent();
145
155
  scriptTarget = tsConfig.options.target || ts.ScriptTarget.ES5;
146
156
  buildOptions = __assign(__assign({
147
157
  // Default options
@@ -166,7 +176,7 @@ var buildWebpackConfigOptions = function (dirToSearch, project, target) { return
166
176
  * Uses angular cli to extract webpack configuration.
167
177
  * The `AngularCliWebpackConfig` type lists the parts used by storybook
168
178
  */
169
- function extractAngularCliWebpackConfig(dirToSearch, project, target) {
179
+ function extractAngularCliWebpackConfig(dirToSearch, project, target, confName) {
170
180
  var _a;
171
181
  return __awaiter(this, void 0, void 0, function () {
172
182
  var _b, getCommonConfig, getStylesConfig, webpackConfigOptions, cliCommonConfig, cliStyleConfig;
@@ -174,7 +184,7 @@ function extractAngularCliWebpackConfig(dirToSearch, project, target) {
174
184
  switch (_c.label) {
175
185
  case 0:
176
186
  _b = importAngularCliWebpackConfigGenerator(), getCommonConfig = _b.getCommonConfig, getStylesConfig = _b.getStylesConfig;
177
- return [4 /*yield*/, buildWebpackConfigOptions(dirToSearch, project, target)];
187
+ return [4 /*yield*/, buildWebpackConfigOptions(dirToSearch, project, target, confName)];
178
188
  case 1:
179
189
  webpackConfigOptions = _c.sent();
180
190
  cliCommonConfig = getCommonConfig(webpackConfigOptions);
@@ -67,7 +67,7 @@ var module_is_available_1 = require("./utils/module-is-available");
67
67
  var filter_out_styling_rules_1 = require("./utils/filter-out-styling-rules");
68
68
  function webpackFinal(baseConfig, options) {
69
69
  return __awaiter(this, void 0, void 0, function () {
70
- var dirToSearch, workspaceConfig, error_1, project, target, browserTarget, fondProject, angularCliWebpackConfig, error_2;
70
+ var dirToSearch, workspaceConfig, error_1, project, target, confName, browserTarget, fondProject, angularCliWebpackConfig, error_2;
71
71
  return __generator(this, function (_a) {
72
72
  switch (_a.label) {
73
73
  case 0:
@@ -103,7 +103,8 @@ function webpackFinal(baseConfig, options) {
103
103
  fondProject = angular_read_workspace_1.findAngularProjectTarget(workspaceConfig, browserTarget.project, browserTarget.target);
104
104
  project = fondProject.project;
105
105
  target = fondProject.target;
106
- node_logger_1.logger.info("=> Using angular project \"" + browserTarget.project + ":" + browserTarget.target + "\" for configuring Storybook");
106
+ confName = browserTarget.configuration;
107
+ node_logger_1.logger.info("=> Using angular project \"" + browserTarget.project + ":" + browserTarget.target + (confName ? ":" + confName : '') + "\" for configuring Storybook");
107
108
  }
108
109
  // Start storybook when only tsConfig is provided.
109
110
  if (options.angularBrowserTarget === null && options.tsConfig) {
@@ -120,7 +121,7 @@ function webpackFinal(baseConfig, options) {
120
121
  _a.label = 5;
121
122
  case 5:
122
123
  _a.trys.push([5, 7, , 8]);
123
- return [4 /*yield*/, angular_devkit_build_webpack_1.extractAngularCliWebpackConfig(dirToSearch, project, target)];
124
+ return [4 /*yield*/, angular_devkit_build_webpack_1.extractAngularCliWebpackConfig(dirToSearch, project, target, confName)];
124
125
  case 6:
125
126
  angularCliWebpackConfig = _a.sent();
126
127
  node_logger_1.logger.info("=> Using angular-cli webpack config");
@@ -4,9 +4,5 @@ var read_pkg_up_1 = require("read-pkg-up");
4
4
  exports.default = {
5
5
  packageJson: read_pkg_up_1.sync({ cwd: __dirname }).packageJson,
6
6
  framework: 'angular',
7
- frameworkPresets: [
8
- require.resolve('./framework-preset-angular'),
9
- require.resolve('./framework-preset-angular-cli'),
10
- require.resolve('./framework-preset-angular-ivy'),
11
- ],
7
+ frameworkPresets: [require.resolve('./preset')],
12
8
  };
@@ -0,0 +1,3 @@
1
+ import type { StorybookConfig } from '@storybook/core-common';
2
+ export declare const config: StorybookConfig['config'];
3
+ export declare const addons: StorybookConfig['addons'];
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __spreadArrays = (this && this.__spreadArrays) || function () {
3
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
4
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
5
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
6
+ r[k] = a[j];
7
+ return r;
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.addons = exports.config = void 0;
11
+ exports.config = function (entries) {
12
+ if (entries === void 0) { entries = []; }
13
+ return __spreadArrays(entries, [
14
+ require.resolve('../client/preview/config'),
15
+ ]);
16
+ };
17
+ exports.addons = [
18
+ require.resolve('./framework-preset-angular'),
19
+ require.resolve('./framework-preset-angular-cli'),
20
+ require.resolve('./framework-preset-angular-ivy'),
21
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/angular",
3
- "version": "6.4.0-beta.3",
3
+ "version": "6.4.0-beta.30",
4
4
  "description": "Storybook for Angular: Develop Angular Components in isolation with Hot Reloading.",
5
5
  "keywords": [
6
6
  "storybook"
@@ -45,14 +45,14 @@
45
45
  "prepare": "node ../../scripts/prepare.js"
46
46
  },
47
47
  "dependencies": {
48
- "@storybook/addons": "6.4.0-beta.3",
49
- "@storybook/api": "6.4.0-beta.3",
50
- "@storybook/core": "6.4.0-beta.3",
51
- "@storybook/core-common": "6.4.0-beta.3",
52
- "@storybook/core-events": "6.4.0-beta.3",
53
- "@storybook/csf": "0.0.2--canary.6aca495.0",
54
- "@storybook/node-logger": "6.4.0-beta.3",
55
- "@storybook/store": "6.4.0-beta.3",
48
+ "@storybook/addons": "6.4.0-beta.30",
49
+ "@storybook/api": "6.4.0-beta.30",
50
+ "@storybook/core": "6.4.0-beta.30",
51
+ "@storybook/core-common": "6.4.0-beta.30",
52
+ "@storybook/core-events": "6.4.0-beta.30",
53
+ "@storybook/csf": "0.0.2--canary.87bc651.0",
54
+ "@storybook/node-logger": "6.4.0-beta.30",
55
+ "@storybook/store": "6.4.0-beta.30",
56
56
  "@types/webpack-env": "^1.16.0",
57
57
  "autoprefixer": "^9.8.6",
58
58
  "core-js": "^3.8.2",
@@ -131,5 +131,5 @@
131
131
  "access": "public"
132
132
  },
133
133
  "builders": "dist/ts3.9/builders/builders.json",
134
- "gitHead": "0fc9200599c97a5797c5af886792200cd29e2046"
134
+ "gitHead": "061df7c81746e8aa9afd4c6648f090aeff10b85f"
135
135
  }
package/preset.js CHANGED
@@ -1,7 +1 @@
1
- function config(entry = []) {
2
- return [...entry, require.resolve('./dist/esm/client/preview/config')];
3
- }
4
-
5
- module.exports = {
6
- config,
7
- };
1
+ module.exports = require('./dist/ts3.9/server/preset');
package/types-7-0.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/ts3.9/client/preview/types-7-0.d';