@storybook/angular 6.5.0-alpha.28 → 6.5.0-alpha.31

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 (45) hide show
  1. package/dist/ts3.9/builders/build-storybook/index.js +33 -84
  2. package/dist/ts3.9/builders/start-storybook/index.js +40 -91
  3. package/dist/ts3.9/builders/utils/build-standalone-errors-handler.js +13 -11
  4. package/dist/ts3.9/builders/utils/run-compodoc.js +19 -25
  5. package/dist/ts3.9/client/preview/angular/app.token.js +1 -1
  6. package/dist/ts3.9/client/preview/angular/components/app.component.js +55 -59
  7. package/dist/ts3.9/client/preview/angular/helpers.js +66 -80
  8. package/dist/ts3.9/client/preview/angular-beta/AbstractRenderer.js +77 -125
  9. package/dist/ts3.9/client/preview/angular-beta/CanvasRenderer.js +18 -81
  10. package/dist/ts3.9/client/preview/angular-beta/ComputesTemplateFromComponent.js +53 -73
  11. package/dist/ts3.9/client/preview/angular-beta/DocsRenderer.js +41 -127
  12. package/dist/ts3.9/client/preview/angular-beta/RendererFactory.js +30 -66
  13. package/dist/ts3.9/client/preview/angular-beta/StorybookModule.js +42 -46
  14. package/dist/ts3.9/client/preview/angular-beta/StorybookProvider.js +15 -17
  15. package/dist/ts3.9/client/preview/angular-beta/StorybookWrapperComponent.js +63 -92
  16. package/dist/ts3.9/client/preview/angular-beta/utils/NgComponentAnalyzer.js +29 -49
  17. package/dist/ts3.9/client/preview/angular-beta/utils/NgModulesAnalyzer.js +10 -10
  18. package/dist/ts3.9/client/preview/decorateStory.js +18 -40
  19. package/dist/ts3.9/client/preview/decorators.js +27 -46
  20. package/dist/ts3.9/client/preview/globals.js +2 -2
  21. package/dist/ts3.9/client/preview/index.js +8 -21
  22. package/dist/ts3.9/client/preview/render.js +17 -56
  23. package/dist/ts3.9/demo/button.component.js +31 -22
  24. package/dist/ts3.9/demo/welcome.component.js +85 -18
  25. package/dist/ts3.9/server/angular-cli-webpack-12.2.x.js +38 -81
  26. package/dist/ts3.9/server/angular-cli-webpack-13.x.x.js +42 -85
  27. package/dist/ts3.9/server/angular-cli-webpack-older.js +77 -123
  28. package/dist/ts3.9/server/angular-devkit-build-webpack.js +72 -133
  29. package/dist/ts3.9/server/angular-read-workspace.js +44 -78
  30. package/dist/ts3.9/server/build.js +10 -47
  31. package/dist/ts3.9/server/create-fork-ts-checker-plugin.js +2 -2
  32. package/dist/ts3.9/server/framework-preset-angular-cli.js +111 -188
  33. package/dist/ts3.9/server/framework-preset-angular-ivy.js +35 -92
  34. package/dist/ts3.9/server/framework-preset-angular.js +62 -115
  35. package/dist/ts3.9/server/index.js +2 -2
  36. package/dist/ts3.9/server/ngx-template-loader/index.js +15 -15
  37. package/dist/ts3.9/server/options.js +1 -1
  38. package/dist/ts3.9/server/preset.js +4 -13
  39. package/dist/ts3.9/server/ts_config.js +5 -5
  40. package/dist/ts3.9/server/utils/filter-out-styling-rules.js +4 -4
  41. package/dist/ts3.9/server/utils/module-is-available.js +1 -1
  42. package/dist/ts3.9/server/utils/normalize-asset-patterns.js +16 -31
  43. package/dist/ts3.9/server/utils/normalize-optimization.js +3 -3
  44. package/package.json +9 -9
  45. package/standalone.d.ts +3 -5
@@ -1,27 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.storyPropsProvider = exports.STORY_PROPS = void 0;
4
- var core_1 = require("@angular/core");
5
- var rxjs_1 = require("rxjs");
4
+ const core_1 = require("@angular/core");
5
+ const rxjs_1 = require("rxjs");
6
6
  exports.STORY_PROPS = new core_1.InjectionToken('STORY_PROPS');
7
- exports.storyPropsProvider = function (storyProps$) { return ({
7
+ exports.storyPropsProvider = (storyProps$) => ({
8
8
  provide: exports.STORY_PROPS,
9
9
  useFactory: storyDataFactory(storyProps$.asObservable()),
10
10
  deps: [core_1.NgZone],
11
- }); };
11
+ });
12
12
  function storyDataFactory(data) {
13
- return function (ngZone) {
14
- return new rxjs_1.Observable(function (subscriber) {
15
- var sub = data.subscribe(function (v) {
16
- ngZone.run(function () { return subscriber.next(v); });
17
- }, function (err) {
18
- ngZone.run(function () { return subscriber.error(err); });
19
- }, function () {
20
- ngZone.run(function () { return subscriber.complete(); });
21
- });
22
- return function () {
23
- sub.unsubscribe();
24
- };
13
+ return (ngZone) => new rxjs_1.Observable((subscriber) => {
14
+ const sub = data.subscribe((v) => {
15
+ ngZone.run(() => subscriber.next(v));
16
+ }, (err) => {
17
+ ngZone.run(() => subscriber.error(err));
18
+ }, () => {
19
+ ngZone.run(() => subscriber.complete());
25
20
  });
26
- };
21
+ return () => {
22
+ sub.unsubscribe();
23
+ };
24
+ });
27
25
  }
@@ -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,97 +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");
23
- var reflectionCapabilities = new core_1.ɵReflectionCapabilities();
4
+ const core_1 = require("@angular/core");
5
+ const reflectionCapabilities = new core_1.ɵReflectionCapabilities();
24
6
  /**
25
7
  * Returns component Inputs / Outputs by browsing these properties and decorator
26
8
  */
27
- exports.getComponentInputsOutputs = function (component) {
28
- var _a, _b;
29
- var componentMetadata = exports.getComponentDecoratorMetadata(component);
30
- var componentPropsMetadata = exports.getComponentPropsDecoratorMetadata(component);
31
- var initialValue = {
9
+ exports.getComponentInputsOutputs = (component) => {
10
+ const componentMetadata = exports.getComponentDecoratorMetadata(component);
11
+ const componentPropsMetadata = exports.getComponentPropsDecoratorMetadata(component);
12
+ const initialValue = {
32
13
  inputs: [],
33
14
  outputs: [],
34
15
  };
35
16
  // Adds the I/O present in @Component metadata
36
17
  if (componentMetadata && componentMetadata.inputs) {
37
- (_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 })));
38
19
  }
39
20
  if (componentMetadata && componentMetadata.outputs) {
40
- (_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 })));
41
22
  }
42
23
  if (!componentPropsMetadata) {
43
24
  return initialValue;
44
25
  }
45
26
  // Browses component properties to extract I/O
46
27
  // Filters properties that have the same name as the one present in the @Component property
47
- return Object.entries(componentPropsMetadata).reduce(function (previousValue, _a) {
48
- var _b, _c;
49
- var propertyName = _a[0], values = _a[1];
50
- 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);
51
31
  if (value instanceof core_1.Input) {
52
- var inputToAdd = {
32
+ const inputToAdd = {
53
33
  propName: propertyName,
54
- templateName: (_b = value.bindingPropertyName) !== null && _b !== void 0 ? _b : propertyName,
34
+ templateName: (_a = value.bindingPropertyName) !== null && _a !== void 0 ? _a : propertyName,
55
35
  };
56
- var previousInputsFiltered = previousValue.inputs.filter(function (i) { return i.templateName !== propertyName; });
57
- 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] });
58
38
  }
59
39
  if (value instanceof core_1.Output) {
60
- var outputToAdd = {
40
+ const outputToAdd = {
61
41
  propName: propertyName,
62
- templateName: (_c = value.bindingPropertyName) !== null && _c !== void 0 ? _c : propertyName,
42
+ templateName: (_b = value.bindingPropertyName) !== null && _b !== void 0 ? _b : propertyName,
63
43
  };
64
- var previousOutputsFiltered = previousValue.outputs.filter(function (i) { return i.templateName !== propertyName; });
65
- 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] });
66
46
  }
67
47
  return previousValue;
68
48
  }, initialValue);
69
49
  };
70
- exports.isDeclarable = function (component) {
50
+ exports.isDeclarable = (component) => {
71
51
  if (!component) {
72
52
  return false;
73
53
  }
74
- var decorators = reflectionCapabilities.annotations(component);
75
- 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);
76
56
  };
77
- exports.isComponent = function (component) {
57
+ exports.isComponent = (component) => {
78
58
  if (!component) {
79
59
  return false;
80
60
  }
81
- var decorators = reflectionCapabilities.annotations(component);
82
- 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);
83
63
  };
84
64
  /**
85
65
  * Returns all component decorator properties
86
66
  * is used to get all `@Input` and `@Output` Decorator
87
67
  */
88
- exports.getComponentPropsDecoratorMetadata = function (component) {
68
+ exports.getComponentPropsDecoratorMetadata = (component) => {
89
69
  return reflectionCapabilities.propMetadata(component);
90
70
  };
91
71
  /**
92
72
  * Returns component decorator `@Component`
93
73
  */
94
- exports.getComponentDecoratorMetadata = function (component) {
95
- var decorators = reflectionCapabilities.annotations(component);
96
- return decorators.reverse().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);
97
77
  };
@@ -1,24 +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");
5
- var reflectionCapabilities = new core_1.ɵReflectionCapabilities();
4
+ const core_1 = require("@angular/core");
5
+ const reflectionCapabilities = new core_1.ɵReflectionCapabilities();
6
6
  /**
7
7
  * Avoid component redeclaration
8
8
  *
9
9
  * Checks recursively if the component has already been declared in all import Module
10
10
  */
11
- exports.isComponentAlreadyDeclaredInModules = function (componentToFind, moduleDeclarations, moduleImports) {
11
+ exports.isComponentAlreadyDeclaredInModules = (componentToFind, moduleDeclarations, moduleImports) => {
12
12
  if (moduleDeclarations &&
13
- moduleDeclarations.some(function (declaration) { return declaration === componentToFind; })) {
13
+ moduleDeclarations.some((declaration) => declaration === componentToFind)) {
14
14
  // Found component in declarations array
15
15
  return true;
16
16
  }
17
17
  if (!moduleImports) {
18
18
  return false;
19
19
  }
20
- return moduleImports.some(function (importItem) {
21
- var extractedNgModuleMetadata = extractNgModuleMetadata(importItem);
20
+ return moduleImports.some((importItem) => {
21
+ const extractedNgModuleMetadata = extractNgModuleMetadata(importItem);
22
22
  if (!extractedNgModuleMetadata) {
23
23
  // Not an NgModule
24
24
  return false;
@@ -26,13 +26,13 @@ exports.isComponentAlreadyDeclaredInModules = function (componentToFind, moduleD
26
26
  return exports.isComponentAlreadyDeclaredInModules(componentToFind, extractedNgModuleMetadata.declarations, extractedNgModuleMetadata.imports);
27
27
  });
28
28
  };
29
- var extractNgModuleMetadata = function (importItem) {
30
- var target = importItem && importItem.ngModule ? importItem.ngModule : importItem;
31
- var decorators = reflectionCapabilities.annotations(target);
29
+ const extractNgModuleMetadata = (importItem) => {
30
+ const target = importItem && importItem.ngModule ? importItem.ngModule : importItem;
31
+ const decorators = reflectionCapabilities.annotations(target);
32
32
  if (!decorators || decorators.length === 0) {
33
33
  return null;
34
34
  }
35
- var ngModuleDecorator = decorators.find(function (decorator) { return decorator instanceof core_1.NgModule; });
35
+ const ngModuleDecorator = decorators.find((decorator) => decorator instanceof core_1.NgModule);
36
36
  if (!ngModuleDecorator) {
37
37
  return null;
38
38
  }
@@ -1,64 +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) {
26
- return function (context) {
27
- var decoratedStory = decorator(function (update) {
28
- return previousStoryFn(__assign(__assign({}, context), store_1.sanitizeStoryContextUpdate(update)));
29
- }, context);
30
- return decoratedStory;
31
- };
32
- }, function (context) { return prepareMain(mainStoryFn(context), context); });
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)));
10
+ }, context);
11
+ return decoratedStory;
12
+ }, (context) => prepareMain(mainStoryFn(context), context));
33
13
  return returnDecorators;
34
14
  }
35
15
  exports.default = decorateStory;
36
16
  exports.decorateStory = decorateStory;
37
- var prepareMain = function (story, context) {
17
+ const prepareMain = (story, context) => {
38
18
  var _a;
39
- var template = story.template;
40
- var component = (_a = story.component) !== null && _a !== void 0 ? _a : context.component;
41
- 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);
42
22
  if (!userDefinedTemplate && component) {
43
23
  template = ComputesTemplateFromComponent_1.computesTemplateFromComponent(component, story.props, '');
44
24
  }
45
- return __assign(__assign({}, story), (template ? { template: template, userDefinedTemplate: userDefinedTemplate } : {}));
25
+ return Object.assign(Object.assign({}, story), (template ? { template, userDefinedTemplate } : {}));
46
26
  };
47
27
  function hasNoTemplate(template) {
48
28
  return template === null || template === undefined;
49
29
  }
50
- var cleanArgsDecorator = function (storyFn, context) {
30
+ const cleanArgsDecorator = (storyFn, context) => {
51
31
  if (!context.argTypes || !context.args) {
52
32
  return storyFn();
53
33
  }
54
- var argsToClean = context.args;
55
- context.args = Object.entries(argsToClean).reduce(function (obj, _a) {
56
- var _b;
57
- var key = _a[0], arg = _a[1];
58
- 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];
59
37
  // Only keeps args with a control or an action in argTypes
60
38
  if (argType.action || argType.control) {
61
- return __assign(__assign({}, obj), (_b = {}, _b[key] = arg, _b));
39
+ return Object.assign(Object.assign({}, obj), { [key]: arg });
62
40
  }
63
41
  return obj;
64
42
  }, {});
@@ -1,53 +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) {
27
- return function (storyFn) {
28
- var story = storyFn();
29
- var storyMetadata = story.moduleMetadata || {};
30
- metadata = metadata || {};
31
- return __assign(__assign({}, story), { moduleMetadata: {
32
- declarations: __spreadArrays((metadata.declarations || []), (storyMetadata.declarations || [])),
33
- entryComponents: __spreadArrays((metadata.entryComponents || []), (storyMetadata.entryComponents || [])),
34
- imports: __spreadArrays((metadata.imports || []), (storyMetadata.imports || [])),
35
- schemas: __spreadArrays((metadata.schemas || []), (storyMetadata.schemas || [])),
36
- providers: __spreadArrays((metadata.providers || []), (storyMetadata.providers || [])),
37
- } });
38
- };
8
+ exports.moduleMetadata = (metadata) => (storyFn) => {
9
+ const story = storyFn();
10
+ const storyMetadata = story.moduleMetadata || {};
11
+ metadata = metadata || {};
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 || [])],
21
+ } });
39
22
  };
40
- exports.componentWrapperDecorator = function (element, props) {
41
- return function (storyFn, storyContext) {
42
- var story = storyFn();
43
- var currentProps = typeof props === 'function' ? props(storyContext) : props;
44
- var template = NgComponentAnalyzer_1.isComponent(element)
45
- ? ComputesTemplateFromComponent_1.computesTemplateFromComponent(element, currentProps !== null && currentProps !== void 0 ? currentProps : {}, story.template)
46
- : element(story.template);
47
- return __assign(__assign(__assign({}, story), { template: template }), (currentProps || story.props
48
- ? {
49
- props: __assign(__assign({}, currentProps), story.props),
50
- }
51
- : {}));
52
- };
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)
27
+ ? ComputesTemplateFromComponent_1.computesTemplateFromComponent(element, currentProps !== null && currentProps !== void 0 ? currentProps : {}, story.template)
28
+ : element(story.template);
29
+ return Object.assign(Object.assign(Object.assign({}, story), { template }), (currentProps || story.props
30
+ ? {
31
+ props: Object.assign(Object.assign({}, currentProps), story.props),
32
+ }
33
+ : {}));
53
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';