@storybook/angular 6.5.0-alpha.4 → 6.5.0-alpha.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 (60) hide show
  1. package/dist/ts3.4/client/preview/angular-beta/utils/NgComponentAnalyzer.d.ts +4 -2
  2. package/dist/ts3.4/server/angular-cli-webpack-older.d.ts +2 -1
  3. package/dist/ts3.4/server/framework-preset-angular.d.ts +3 -2
  4. package/dist/ts3.9/builders/build-storybook/index.js +33 -84
  5. package/dist/ts3.9/builders/start-storybook/index.js +40 -91
  6. package/dist/ts3.9/builders/utils/build-standalone-errors-handler.js +13 -11
  7. package/dist/ts3.9/builders/utils/run-compodoc.js +45 -20
  8. package/dist/ts3.9/client/preview/angular/app.token.js +1 -1
  9. package/dist/ts3.9/client/preview/angular/components/app.component.js +55 -59
  10. package/dist/ts3.9/client/preview/angular/helpers.js +66 -80
  11. package/dist/ts3.9/client/preview/angular-beta/AbstractRenderer.js +77 -125
  12. package/dist/ts3.9/client/preview/angular-beta/CanvasRenderer.js +18 -81
  13. package/dist/ts3.9/client/preview/angular-beta/ComputesTemplateFromComponent.js +75 -69
  14. package/dist/ts3.9/client/preview/angular-beta/DocsRenderer.js +41 -127
  15. package/dist/ts3.9/client/preview/angular-beta/RendererFactory.js +30 -66
  16. package/dist/ts3.9/client/preview/angular-beta/StorybookModule.js +42 -46
  17. package/dist/ts3.9/client/preview/angular-beta/StorybookProvider.js +15 -17
  18. package/dist/ts3.9/client/preview/angular-beta/StorybookWrapperComponent.js +63 -92
  19. package/dist/ts3.9/client/preview/angular-beta/utils/NgComponentAnalyzer.d.ts +4 -2
  20. package/dist/ts3.9/client/preview/angular-beta/utils/NgComponentAnalyzer.js +30 -77
  21. package/dist/ts3.9/client/preview/angular-beta/utils/NgModulesAnalyzer.js +10 -14
  22. package/dist/ts3.9/client/preview/decorateStory.js +16 -36
  23. package/dist/ts3.9/client/preview/decorators.js +22 -37
  24. package/dist/ts3.9/client/preview/globals.js +2 -2
  25. package/dist/ts3.9/client/preview/index.js +8 -21
  26. package/dist/ts3.9/client/preview/render.js +17 -56
  27. package/dist/ts3.9/demo/button.component.js +31 -22
  28. package/dist/ts3.9/demo/welcome.component.js +85 -18
  29. package/dist/ts3.9/server/__mocks-ng-workspace__/minimal-config/tsconfig.json +4 -1
  30. package/dist/ts3.9/server/__mocks-ng-workspace__/some-config/tsconfig.json +4 -1
  31. package/dist/ts3.9/server/__mocks-ng-workspace__/with-angularBrowserTarget/tsconfig.json +4 -1
  32. package/dist/ts3.9/server/__mocks-ng-workspace__/with-lib/tsconfig.json +4 -1
  33. package/dist/ts3.9/server/__mocks-ng-workspace__/with-nx/tsconfig.json +7 -2
  34. package/dist/ts3.9/server/__mocks-ng-workspace__/with-nx-workspace/tsconfig.json +7 -2
  35. package/dist/ts3.9/server/__mocks-ng-workspace__/with-options-styles/tsconfig.json +4 -1
  36. package/dist/ts3.9/server/__mocks-ng-workspace__/without-projects-entry/tsconfig.json +4 -1
  37. package/dist/ts3.9/server/__mocks-ng-workspace__/without-tsConfig/tsconfig.json +4 -1
  38. package/dist/ts3.9/server/angular-cli-webpack-12.2.x.js +38 -81
  39. package/dist/ts3.9/server/angular-cli-webpack-13.x.x.js +42 -85
  40. package/dist/ts3.9/server/angular-cli-webpack-older.d.ts +2 -1
  41. package/dist/ts3.9/server/angular-cli-webpack-older.js +77 -123
  42. package/dist/ts3.9/server/angular-devkit-build-webpack.js +72 -133
  43. package/dist/ts3.9/server/angular-read-workspace.js +44 -78
  44. package/dist/ts3.9/server/build.js +10 -47
  45. package/dist/ts3.9/server/create-fork-ts-checker-plugin.js +2 -2
  46. package/dist/ts3.9/server/framework-preset-angular-cli.js +111 -179
  47. package/dist/ts3.9/server/framework-preset-angular-ivy.js +35 -92
  48. package/dist/ts3.9/server/framework-preset-angular.d.ts +3 -2
  49. package/dist/ts3.9/server/framework-preset-angular.js +88 -62
  50. package/dist/ts3.9/server/index.js +2 -2
  51. package/dist/ts3.9/server/ngx-template-loader/index.js +15 -15
  52. package/dist/ts3.9/server/options.js +1 -1
  53. package/dist/ts3.9/server/preset.js +4 -13
  54. package/dist/ts3.9/server/ts_config.js +5 -5
  55. package/dist/ts3.9/server/utils/filter-out-styling-rules.js +4 -4
  56. package/dist/ts3.9/server/utils/module-is-available.js +1 -1
  57. package/dist/ts3.9/server/utils/normalize-asset-patterns.js +16 -31
  58. package/dist/ts3.9/server/utils/normalize-optimization.js +3 -3
  59. package/package.json +13 -21
  60. package/standalone.d.ts +3 -5
@@ -1,15 +1,4 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
2
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
14
3
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
15
4
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -22,29 +11,21 @@ var __metadata = (this && this.__metadata) || function (k, v) {
22
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
23
12
  return function (target, key) { decorator(target, key, paramIndex); }
24
13
  };
25
- var __spreadArrays = (this && this.__spreadArrays) || function () {
26
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
27
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
28
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
29
- r[k] = a[j];
30
- return r;
31
- };
32
14
  Object.defineProperty(exports, "__esModule", { value: true });
33
15
  exports.createStorybookWrapperComponent = void 0;
34
- var core_1 = require("@angular/core");
35
- var rxjs_1 = require("rxjs");
36
- var operators_1 = require("rxjs/operators");
37
- var StorybookProvider_1 = require("./StorybookProvider");
38
- var NgComponentAnalyzer_1 = require("./utils/NgComponentAnalyzer");
39
- var getNonInputsOutputsProps = function (ngComponentInputsOutputs, props) {
40
- if (props === void 0) { props = {}; }
41
- var inputs = ngComponentInputsOutputs.inputs
42
- .filter(function (i) { return i.templateName in props; })
43
- .map(function (i) { return i.templateName; });
44
- var outputs = ngComponentInputsOutputs.outputs
45
- .filter(function (o) { return o.templateName in props; })
46
- .map(function (o) { return o.templateName; });
47
- return Object.keys(props).filter(function (k) { return !__spreadArrays(inputs, outputs).includes(k); });
16
+ const core_1 = require("@angular/core");
17
+ const rxjs_1 = require("rxjs");
18
+ const operators_1 = require("rxjs/operators");
19
+ const StorybookProvider_1 = require("./StorybookProvider");
20
+ const NgComponentAnalyzer_1 = require("./utils/NgComponentAnalyzer");
21
+ const getNonInputsOutputsProps = (ngComponentInputsOutputs, props = {}) => {
22
+ const inputs = ngComponentInputsOutputs.inputs
23
+ .filter((i) => i.templateName in props)
24
+ .map((i) => i.templateName);
25
+ const outputs = ngComponentInputsOutputs.outputs
26
+ .filter((o) => o.templateName in props)
27
+ .map((o) => o.templateName);
28
+ return Object.keys(props).filter((k) => ![...inputs, ...outputs].includes(k));
48
29
  };
49
30
  /**
50
31
  * Wraps the story template into a component
@@ -52,39 +33,36 @@ var getNonInputsOutputsProps = function (ngComponentInputsOutputs, props) {
52
33
  * @param storyComponent
53
34
  * @param initialProps
54
35
  */
55
- exports.createStorybookWrapperComponent = function (selector, template, storyComponent, styles, initialProps) {
36
+ exports.createStorybookWrapperComponent = (selector, template, storyComponent, styles, initialProps) => {
56
37
  // In ivy, a '' selector is not allowed, therefore we need to just set it to anything if
57
38
  // storyComponent was not provided.
58
- var viewChildSelector = storyComponent !== null && storyComponent !== void 0 ? storyComponent : '__storybook-noop';
59
- var StorybookWrapperComponent = /** @class */ (function () {
39
+ const viewChildSelector = storyComponent !== null && storyComponent !== void 0 ? storyComponent : '__storybook-noop';
40
+ let StorybookWrapperComponent = class StorybookWrapperComponent {
60
41
  // eslint-disable-next-line no-useless-constructor
61
- function StorybookWrapperComponent(storyProps$, changeDetectorRef) {
42
+ constructor(storyProps$, changeDetectorRef) {
62
43
  this.storyProps$ = storyProps$;
63
44
  this.changeDetectorRef = changeDetectorRef;
64
45
  // Used in case of a component without selector
65
46
  this.storyComponent = storyComponent !== null && storyComponent !== void 0 ? storyComponent : '';
66
47
  }
67
- StorybookWrapperComponent.prototype.ngOnInit = function () {
68
- var _this = this;
48
+ ngOnInit() {
69
49
  // Subscribes to the observable storyProps$ to keep these properties up to date
70
- this.storyWrapperPropsSubscription = this.storyProps$.subscribe(function (storyProps) {
71
- if (storyProps === void 0) { storyProps = {}; }
50
+ this.storyWrapperPropsSubscription = this.storyProps$.subscribe((storyProps = {}) => {
72
51
  // All props are added as component properties
73
- Object.assign(_this, storyProps);
74
- _this.changeDetectorRef.detectChanges();
75
- _this.changeDetectorRef.markForCheck();
52
+ Object.assign(this, storyProps);
53
+ this.changeDetectorRef.detectChanges();
54
+ this.changeDetectorRef.markForCheck();
76
55
  });
77
- };
78
- StorybookWrapperComponent.prototype.ngAfterViewInit = function () {
79
- var _this = this;
56
+ }
57
+ ngAfterViewInit() {
80
58
  // Bind properties to component, if the story have component
81
59
  if (this.storyComponentElementRef) {
82
- var ngComponentInputsOutputs_1 = NgComponentAnalyzer_1.getComponentInputsOutputs(storyComponent);
83
- var initialOtherProps = getNonInputsOutputsProps(ngComponentInputsOutputs_1, initialProps);
60
+ const ngComponentInputsOutputs = NgComponentAnalyzer_1.getComponentInputsOutputs(storyComponent);
61
+ const initialOtherProps = getNonInputsOutputsProps(ngComponentInputsOutputs, initialProps);
84
62
  // Initializes properties that are not Inputs | Outputs
85
63
  // Allows story props to override local component properties
86
- initialOtherProps.forEach(function (p) {
87
- _this.storyComponentElementRef[p] = initialProps[p];
64
+ initialOtherProps.forEach((p) => {
65
+ this.storyComponentElementRef[p] = initialProps[p];
88
66
  });
89
67
  // `markForCheck` the component in case this uses changeDetection: OnPush
90
68
  // And then forces the `detectChanges`
@@ -92,64 +70,57 @@ exports.createStorybookWrapperComponent = function (selector, template, storyCom
92
70
  this.changeDetectorRef.detectChanges();
93
71
  // Once target component has been initialized, the storyProps$ observable keeps target component inputs up to date
94
72
  this.storyComponentPropsSubscription = this.storyProps$
95
- .pipe(operators_1.skip(1), operators_1.map(function (props) {
73
+ .pipe(operators_1.skip(1), operators_1.map((props) => {
96
74
  // removes component output in props
97
- var outputsKeyToRemove = ngComponentInputsOutputs_1.outputs.map(function (o) { return o.templateName; });
98
- return Object.entries(props).reduce(function (prev, _a) {
99
- var _b;
100
- var key = _a[0], value = _a[1];
101
- return (__assign(__assign({}, prev), (!outputsKeyToRemove.includes(key) && (_b = {},
102
- _b[key] = value,
103
- _b))));
104
- }, {});
105
- }), operators_1.map(function (props) {
75
+ const outputsKeyToRemove = ngComponentInputsOutputs.outputs.map((o) => o.templateName);
76
+ return Object.entries(props).reduce((prev, [key, value]) => (Object.assign(Object.assign({}, prev), (!outputsKeyToRemove.includes(key) && {
77
+ [key]: value,
78
+ }))), {});
79
+ }), operators_1.map((props) => {
106
80
  // In case a component uses an input with `bindingPropertyName` (ex: @Input('name'))
107
81
  // find the value of the local propName in the component Inputs
108
82
  // otherwise use the input key
109
- return Object.entries(props).reduce(function (prev, _a) {
110
- var _b, _c;
111
- var propKey = _a[0], value = _a[1];
112
- var input = ngComponentInputsOutputs_1.inputs.find(function (o) { return o.templateName === propKey; });
113
- return __assign(__assign({}, prev), (input ? (_b = {}, _b[input.propName] = value, _b) : (_c = {}, _c[propKey] = value, _c)));
83
+ return Object.entries(props).reduce((prev, [propKey, value]) => {
84
+ const input = ngComponentInputsOutputs.inputs.find((o) => o.templateName === propKey);
85
+ return Object.assign(Object.assign({}, prev), (input ? { [input.propName]: value } : { [propKey]: value }));
114
86
  }, {});
115
87
  }))
116
- .subscribe(function (props) {
88
+ .subscribe((props) => {
117
89
  // Replace inputs with new ones from props
118
- Object.assign(_this.storyComponentElementRef, props);
90
+ Object.assign(this.storyComponentElementRef, props);
119
91
  // `markForCheck` the component in case this uses changeDetection: OnPush
120
92
  // And then forces the `detectChanges`
121
- _this.storyComponentViewContainerRef.injector.get(core_1.ChangeDetectorRef).markForCheck();
122
- _this.changeDetectorRef.detectChanges();
93
+ this.storyComponentViewContainerRef.injector.get(core_1.ChangeDetectorRef).markForCheck();
94
+ this.changeDetectorRef.detectChanges();
123
95
  });
124
96
  }
125
- };
126
- StorybookWrapperComponent.prototype.ngOnDestroy = function () {
97
+ }
98
+ ngOnDestroy() {
127
99
  if (this.storyComponentPropsSubscription != null) {
128
100
  this.storyComponentPropsSubscription.unsubscribe();
129
101
  }
130
102
  if (this.storyWrapperPropsSubscription != null) {
131
103
  this.storyWrapperPropsSubscription.unsubscribe();
132
104
  }
133
- };
134
- __decorate([
135
- core_1.ViewChild(viewChildSelector, { static: true }),
136
- __metadata("design:type", core_1.ElementRef)
137
- ], StorybookWrapperComponent.prototype, "storyComponentElementRef", void 0);
138
- __decorate([
139
- core_1.ViewChild(viewChildSelector, { read: core_1.ViewContainerRef, static: true }),
140
- __metadata("design:type", core_1.ViewContainerRef)
141
- ], StorybookWrapperComponent.prototype, "storyComponentViewContainerRef", void 0);
142
- StorybookWrapperComponent = __decorate([
143
- core_1.Component({
144
- selector: selector,
145
- template: template,
146
- styles: styles,
147
- }),
148
- __param(0, core_1.Inject(StorybookProvider_1.STORY_PROPS)),
149
- __metadata("design:paramtypes", [rxjs_1.Subject,
150
- core_1.ChangeDetectorRef])
151
- ], StorybookWrapperComponent);
152
- return StorybookWrapperComponent;
153
- }());
105
+ }
106
+ };
107
+ __decorate([
108
+ core_1.ViewChild(viewChildSelector, { static: true }),
109
+ __metadata("design:type", core_1.ElementRef)
110
+ ], StorybookWrapperComponent.prototype, "storyComponentElementRef", void 0);
111
+ __decorate([
112
+ core_1.ViewChild(viewChildSelector, { read: core_1.ViewContainerRef, static: true }),
113
+ __metadata("design:type", core_1.ViewContainerRef)
114
+ ], StorybookWrapperComponent.prototype, "storyComponentViewContainerRef", void 0);
115
+ StorybookWrapperComponent = __decorate([
116
+ core_1.Component({
117
+ selector,
118
+ template,
119
+ styles,
120
+ }),
121
+ __param(0, core_1.Inject(StorybookProvider_1.STORY_PROPS)),
122
+ __metadata("design:paramtypes", [rxjs_1.Subject,
123
+ core_1.ChangeDetectorRef])
124
+ ], StorybookWrapperComponent);
154
125
  return StorybookWrapperComponent;
155
126
  };
@@ -1,4 +1,4 @@
1
- import { Component, Input, Output, Type } from '@angular/core';
1
+ import { Component, Type } from '@angular/core';
2
2
  export declare type ComponentInputsOutputs = {
3
3
  inputs: {
4
4
  propName: string;
@@ -19,7 +19,9 @@ export declare const isComponent: (component: any) => component is Type<unknown>
19
19
  * Returns all component decorator properties
20
20
  * is used to get all `@Input` and `@Output` Decorator
21
21
  */
22
- export declare const getComponentPropsDecoratorMetadata: (component: any) => Record<string, (Input | Output)[]>;
22
+ export declare const getComponentPropsDecoratorMetadata: (component: any) => {
23
+ [key: string]: any[];
24
+ };
23
25
  /**
24
26
  * Returns component decorator `@Component`
25
27
  */
@@ -1,124 +1,77 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __spreadArrays = (this && this.__spreadArrays) || function () {
14
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
15
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
16
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
17
- r[k] = a[j];
18
- return r;
19
- };
20
2
  Object.defineProperty(exports, "__esModule", { value: true });
21
3
  exports.getComponentDecoratorMetadata = exports.getComponentPropsDecoratorMetadata = exports.isComponent = exports.isDeclarable = exports.getComponentInputsOutputs = void 0;
22
- var core_1 = require("@angular/core");
4
+ const core_1 = require("@angular/core");
5
+ const reflectionCapabilities = new core_1.ɵReflectionCapabilities();
23
6
  /**
24
7
  * Returns component Inputs / Outputs by browsing these properties and decorator
25
8
  */
26
- exports.getComponentInputsOutputs = function (component) {
27
- var _a, _b;
28
- var componentMetadata = exports.getComponentDecoratorMetadata(component);
29
- var componentPropsMetadata = exports.getComponentPropsDecoratorMetadata(component);
30
- var initialValue = {
9
+ exports.getComponentInputsOutputs = (component) => {
10
+ const componentMetadata = exports.getComponentDecoratorMetadata(component);
11
+ const componentPropsMetadata = exports.getComponentPropsDecoratorMetadata(component);
12
+ const initialValue = {
31
13
  inputs: [],
32
14
  outputs: [],
33
15
  };
34
16
  // Adds the I/O present in @Component metadata
35
17
  if (componentMetadata && componentMetadata.inputs) {
36
- (_a = initialValue.inputs).push.apply(_a, componentMetadata.inputs.map(function (i) { return ({ propName: i, templateName: i }); }));
18
+ initialValue.inputs.push(...componentMetadata.inputs.map((i) => ({ propName: i, templateName: i })));
37
19
  }
38
20
  if (componentMetadata && componentMetadata.outputs) {
39
- (_b = initialValue.outputs).push.apply(_b, componentMetadata.outputs.map(function (i) { return ({ propName: i, templateName: i }); }));
21
+ initialValue.outputs.push(...componentMetadata.outputs.map((i) => ({ propName: i, templateName: i })));
40
22
  }
41
23
  if (!componentPropsMetadata) {
42
24
  return initialValue;
43
25
  }
44
26
  // Browses component properties to extract I/O
45
27
  // Filters properties that have the same name as the one present in the @Component property
46
- return Object.entries(componentPropsMetadata).reduce(function (previousValue, _a) {
47
- var _b, _c;
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; });
28
+ return Object.entries(componentPropsMetadata).reduce((previousValue, [propertyName, values]) => {
29
+ var _a, _b;
30
+ const value = values.find((v) => v instanceof core_1.Input || v instanceof core_1.Output);
50
31
  if (value instanceof core_1.Input) {
51
- var inputToAdd = {
32
+ const inputToAdd = {
52
33
  propName: propertyName,
53
- templateName: (_b = value.bindingPropertyName) !== null && _b !== void 0 ? _b : propertyName,
34
+ templateName: (_a = value.bindingPropertyName) !== null && _a !== void 0 ? _a : propertyName,
54
35
  };
55
- var previousInputsFiltered = previousValue.inputs.filter(function (i) { return i.templateName !== propertyName; });
56
- return __assign(__assign({}, previousValue), { inputs: __spreadArrays(previousInputsFiltered, [inputToAdd]) });
36
+ const previousInputsFiltered = previousValue.inputs.filter((i) => i.templateName !== propertyName);
37
+ return Object.assign(Object.assign({}, previousValue), { inputs: [...previousInputsFiltered, inputToAdd] });
57
38
  }
58
39
  if (value instanceof core_1.Output) {
59
- var outputToAdd = {
40
+ const outputToAdd = {
60
41
  propName: propertyName,
61
- templateName: (_c = value.bindingPropertyName) !== null && _c !== void 0 ? _c : propertyName,
42
+ templateName: (_b = value.bindingPropertyName) !== null && _b !== void 0 ? _b : propertyName,
62
43
  };
63
- var previousOutputsFiltered = previousValue.outputs.filter(function (i) { return i.templateName !== propertyName; });
64
- return __assign(__assign({}, previousValue), { outputs: __spreadArrays(previousOutputsFiltered, [outputToAdd]) });
44
+ const previousOutputsFiltered = previousValue.outputs.filter((i) => i.templateName !== propertyName);
45
+ return Object.assign(Object.assign({}, previousValue), { outputs: [...previousOutputsFiltered, outputToAdd] });
65
46
  }
66
47
  return previousValue;
67
48
  }, initialValue);
68
49
  };
69
- exports.isDeclarable = function (component) {
50
+ exports.isDeclarable = (component) => {
70
51
  if (!component) {
71
52
  return false;
72
53
  }
73
- var decoratorKey = '__annotations__';
74
- var decorators = Reflect.getOwnPropertyDescriptor(component, decoratorKey)
75
- ? Reflect.getOwnPropertyDescriptor(component, decoratorKey).value
76
- : component[decoratorKey];
77
- return !!(decorators || []).find(function (d) { return d instanceof core_1.Directive || d instanceof core_1.Pipe || d instanceof core_1.Component; });
54
+ const decorators = reflectionCapabilities.annotations(component);
55
+ return !!(decorators || []).find((d) => d instanceof core_1.Directive || d instanceof core_1.Pipe || d instanceof core_1.Component);
78
56
  };
79
- exports.isComponent = function (component) {
57
+ exports.isComponent = (component) => {
80
58
  if (!component) {
81
59
  return false;
82
60
  }
83
- var decoratorKey = '__annotations__';
84
- var decorators = Reflect.getOwnPropertyDescriptor(component, decoratorKey)
85
- ? Reflect.getOwnPropertyDescriptor(component, decoratorKey).value
86
- : component[decoratorKey];
87
- return (decorators || []).some(function (d) { return d instanceof core_1.Component; });
61
+ const decorators = reflectionCapabilities.annotations(component);
62
+ return (decorators || []).some((d) => d instanceof core_1.Component);
88
63
  };
89
64
  /**
90
65
  * Returns all component decorator properties
91
66
  * is used to get all `@Input` and `@Output` Decorator
92
67
  */
93
- exports.getComponentPropsDecoratorMetadata = function (component) {
94
- var decoratorKey = '__prop__metadata__';
95
- var propsDecorators = Reflect &&
96
- Reflect.getOwnPropertyDescriptor &&
97
- Reflect.getOwnPropertyDescriptor(component, decoratorKey)
98
- ? Reflect.getOwnPropertyDescriptor(component, decoratorKey).value
99
- : component[decoratorKey];
100
- var parent = Reflect && Reflect.getPrototypeOf && Reflect.getPrototypeOf(component);
101
- if (parent) {
102
- var parentPropsDecorators = exports.getComponentPropsDecoratorMetadata(parent);
103
- propsDecorators = __assign(__assign({}, parentPropsDecorators), propsDecorators);
104
- }
105
- return propsDecorators;
68
+ exports.getComponentPropsDecoratorMetadata = (component) => {
69
+ return reflectionCapabilities.propMetadata(component);
106
70
  };
107
71
  /**
108
72
  * Returns component decorator `@Component`
109
73
  */
110
- exports.getComponentDecoratorMetadata = function (component) {
111
- var decoratorKey = '__annotations__';
112
- var decorators = Reflect &&
113
- Reflect.getOwnPropertyDescriptor &&
114
- Reflect.getOwnPropertyDescriptor(component, decoratorKey)
115
- ? Reflect.getOwnPropertyDescriptor(component, decoratorKey).value
116
- : component[decoratorKey];
117
- if (!decorators) {
118
- return (component.decorators &&
119
- component.decorators[0] &&
120
- component.decorators[0].args &&
121
- component.decorators[0].args[0]);
122
- }
123
- return decorators.find(function (d) { return d instanceof core_1.Component; });
74
+ exports.getComponentDecoratorMetadata = (component) => {
75
+ const decorators = reflectionCapabilities.annotations(component);
76
+ return decorators.reverse().find((d) => d instanceof core_1.Component);
124
77
  };
@@ -1,23 +1,24 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isComponentAlreadyDeclaredInModules = void 0;
4
- var core_1 = require("@angular/core");
4
+ const core_1 = require("@angular/core");
5
+ const reflectionCapabilities = new core_1.ɵReflectionCapabilities();
5
6
  /**
6
7
  * Avoid component redeclaration
7
8
  *
8
9
  * Checks recursively if the component has already been declared in all import Module
9
10
  */
10
- exports.isComponentAlreadyDeclaredInModules = function (componentToFind, moduleDeclarations, moduleImports) {
11
+ exports.isComponentAlreadyDeclaredInModules = (componentToFind, moduleDeclarations, moduleImports) => {
11
12
  if (moduleDeclarations &&
12
- moduleDeclarations.some(function (declaration) { return declaration === componentToFind; })) {
13
+ moduleDeclarations.some((declaration) => declaration === componentToFind)) {
13
14
  // Found component in declarations array
14
15
  return true;
15
16
  }
16
17
  if (!moduleImports) {
17
18
  return false;
18
19
  }
19
- return moduleImports.some(function (importItem) {
20
- var extractedNgModuleMetadata = extractNgModuleMetadata(importItem);
20
+ return moduleImports.some((importItem) => {
21
+ const extractedNgModuleMetadata = extractNgModuleMetadata(importItem);
21
22
  if (!extractedNgModuleMetadata) {
22
23
  // Not an NgModule
23
24
  return false;
@@ -25,18 +26,13 @@ exports.isComponentAlreadyDeclaredInModules = function (componentToFind, moduleD
25
26
  return exports.isComponentAlreadyDeclaredInModules(componentToFind, extractedNgModuleMetadata.declarations, extractedNgModuleMetadata.imports);
26
27
  });
27
28
  };
28
- var extractNgModuleMetadata = function (importItem) {
29
- var target = importItem && importItem.ngModule ? importItem.ngModule : importItem;
30
- var decoratorKey = '__annotations__';
31
- var decorators = Reflect &&
32
- Reflect.getOwnPropertyDescriptor &&
33
- Reflect.getOwnPropertyDescriptor(target, decoratorKey)
34
- ? Reflect.getOwnPropertyDescriptor(target, decoratorKey).value
35
- : target[decoratorKey];
29
+ const extractNgModuleMetadata = (importItem) => {
30
+ const target = importItem && importItem.ngModule ? importItem.ngModule : importItem;
31
+ const decorators = reflectionCapabilities.annotations(target);
36
32
  if (!decorators || decorators.length === 0) {
37
33
  return null;
38
34
  }
39
- var ngModuleDecorator = decorators.find(function (decorator) { return decorator instanceof core_1.NgModule; });
35
+ const ngModuleDecorator = decorators.find((decorator) => decorator instanceof core_1.NgModule);
40
36
  if (!ngModuleDecorator) {
41
37
  return null;
42
38
  }
@@ -1,62 +1,42 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __spreadArrays = (this && this.__spreadArrays) || function () {
14
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
15
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
16
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
17
- r[k] = a[j];
18
- return r;
19
- };
20
2
  Object.defineProperty(exports, "__esModule", { value: true });
21
3
  exports.decorateStory = void 0;
22
- var store_1 = require("@storybook/store");
23
- var ComputesTemplateFromComponent_1 = require("./angular-beta/ComputesTemplateFromComponent");
4
+ const store_1 = require("@storybook/store");
5
+ const ComputesTemplateFromComponent_1 = require("./angular-beta/ComputesTemplateFromComponent");
24
6
  function decorateStory(mainStoryFn, decorators) {
25
- var returnDecorators = __spreadArrays([cleanArgsDecorator], decorators).reduce(function (previousStoryFn, decorator) { return function (context) {
26
- var decoratedStory = decorator(function (update) {
27
- return previousStoryFn(__assign(__assign({}, context), store_1.sanitizeStoryContextUpdate(update)));
7
+ const returnDecorators = [cleanArgsDecorator, ...decorators].reduce((previousStoryFn, decorator) => (context) => {
8
+ const decoratedStory = decorator((update) => {
9
+ return previousStoryFn(Object.assign(Object.assign({}, context), store_1.sanitizeStoryContextUpdate(update)));
28
10
  }, context);
29
11
  return decoratedStory;
30
- }; }, function (context) { return prepareMain(mainStoryFn(context), context); });
12
+ }, (context) => prepareMain(mainStoryFn(context), context));
31
13
  return returnDecorators;
32
14
  }
33
15
  exports.default = decorateStory;
34
16
  exports.decorateStory = decorateStory;
35
- var prepareMain = function (story, context) {
17
+ const prepareMain = (story, context) => {
36
18
  var _a;
37
- var template = story.template;
38
- var component = (_a = story.component) !== null && _a !== void 0 ? _a : context.component;
39
- var userDefinedTemplate = !hasNoTemplate(template);
19
+ let { template } = story;
20
+ const component = (_a = story.component) !== null && _a !== void 0 ? _a : context.component;
21
+ const userDefinedTemplate = !hasNoTemplate(template);
40
22
  if (!userDefinedTemplate && component) {
41
23
  template = ComputesTemplateFromComponent_1.computesTemplateFromComponent(component, story.props, '');
42
24
  }
43
- return __assign(__assign({}, story), (template ? { template: template, userDefinedTemplate: userDefinedTemplate } : {}));
25
+ return Object.assign(Object.assign({}, story), (template ? { template, userDefinedTemplate } : {}));
44
26
  };
45
27
  function hasNoTemplate(template) {
46
28
  return template === null || template === undefined;
47
29
  }
48
- var cleanArgsDecorator = function (storyFn, context) {
30
+ const cleanArgsDecorator = (storyFn, context) => {
49
31
  if (!context.argTypes || !context.args) {
50
32
  return storyFn();
51
33
  }
52
- var argsToClean = context.args;
53
- context.args = Object.entries(argsToClean).reduce(function (obj, _a) {
54
- var _b;
55
- var key = _a[0], arg = _a[1];
56
- var argType = context.argTypes[key];
34
+ const argsToClean = context.args;
35
+ context.args = Object.entries(argsToClean).reduce((obj, [key, arg]) => {
36
+ const argType = context.argTypes[key];
57
37
  // Only keeps args with a control or an action in argTypes
58
38
  if (argType.action || argType.control) {
59
- return __assign(__assign({}, obj), (_b = {}, _b[key] = arg, _b));
39
+ return Object.assign(Object.assign({}, obj), { [key]: arg });
60
40
  }
61
41
  return obj;
62
42
  }, {});
@@ -1,49 +1,34 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __spreadArrays = (this && this.__spreadArrays) || function () {
14
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
15
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
16
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
17
- r[k] = a[j];
18
- return r;
19
- };
20
2
  Object.defineProperty(exports, "__esModule", { value: true });
21
3
  exports.componentWrapperDecorator = exports.moduleMetadata = void 0;
22
- var ComputesTemplateFromComponent_1 = require("./angular-beta/ComputesTemplateFromComponent");
23
- var NgComponentAnalyzer_1 = require("./angular-beta/utils/NgComponentAnalyzer");
4
+ const ComputesTemplateFromComponent_1 = require("./angular-beta/ComputesTemplateFromComponent");
5
+ const NgComponentAnalyzer_1 = require("./angular-beta/utils/NgComponentAnalyzer");
24
6
  // We use `any` here as the default type rather than `Args` because we need something that is
25
7
  // castable to any component-specific args type when the user is being careful.
26
- exports.moduleMetadata = function (metadata) { return function (storyFn) {
27
- var story = storyFn();
28
- var storyMetadata = story.moduleMetadata || {};
8
+ exports.moduleMetadata = (metadata) => (storyFn) => {
9
+ const story = storyFn();
10
+ const storyMetadata = story.moduleMetadata || {};
29
11
  metadata = metadata || {};
30
- return __assign(__assign({}, story), { moduleMetadata: {
31
- declarations: __spreadArrays((metadata.declarations || []), (storyMetadata.declarations || [])),
32
- entryComponents: __spreadArrays((metadata.entryComponents || []), (storyMetadata.entryComponents || [])),
33
- imports: __spreadArrays((metadata.imports || []), (storyMetadata.imports || [])),
34
- schemas: __spreadArrays((metadata.schemas || []), (storyMetadata.schemas || [])),
35
- providers: __spreadArrays((metadata.providers || []), (storyMetadata.providers || [])),
12
+ return Object.assign(Object.assign({}, story), { moduleMetadata: {
13
+ declarations: [...(metadata.declarations || []), ...(storyMetadata.declarations || [])],
14
+ entryComponents: [
15
+ ...(metadata.entryComponents || []),
16
+ ...(storyMetadata.entryComponents || []),
17
+ ],
18
+ imports: [...(metadata.imports || []), ...(storyMetadata.imports || [])],
19
+ schemas: [...(metadata.schemas || []), ...(storyMetadata.schemas || [])],
20
+ providers: [...(metadata.providers || []), ...(storyMetadata.providers || [])],
36
21
  } });
37
- }; };
38
- exports.componentWrapperDecorator = function (element, props) { return function (storyFn, storyContext) {
39
- var story = storyFn();
40
- var currentProps = typeof props === 'function' ? props(storyContext) : props;
41
- var template = NgComponentAnalyzer_1.isComponent(element)
22
+ };
23
+ exports.componentWrapperDecorator = (element, props) => (storyFn, storyContext) => {
24
+ const story = storyFn();
25
+ const currentProps = typeof props === 'function' ? props(storyContext) : props;
26
+ const template = NgComponentAnalyzer_1.isComponent(element)
42
27
  ? ComputesTemplateFromComponent_1.computesTemplateFromComponent(element, currentProps !== null && currentProps !== void 0 ? currentProps : {}, story.template)
43
28
  : element(story.template);
44
- return __assign(__assign(__assign({}, story), { template: template }), (currentProps || story.props
29
+ return Object.assign(Object.assign(Object.assign({}, story), { template }), (currentProps || story.props
45
30
  ? {
46
- props: __assign(__assign({}, currentProps), story.props),
31
+ props: Object.assign(Object.assign({}, currentProps), story.props),
47
32
  }
48
33
  : {}));
49
- }; };
34
+ };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var global_1 = __importDefault(require("global"));
6
+ const global_1 = __importDefault(require("global"));
7
7
  require("./angular-polyfills");
8
- var globalWindow = global_1.default.window;
8
+ const { window: globalWindow } = global_1.default;
9
9
  globalWindow.STORYBOOK_ENV = 'angular';