@storybook/angular 6.5.0-alpha.7 → 6.5.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/ts3.4/builders/build-storybook/index.d.ts +1 -1
- package/dist/ts3.4/client/docs/compodoc.d.ts +18 -0
- package/dist/ts3.4/client/docs/config.d.ts +15 -0
- package/dist/ts3.4/client/docs/index.d.ts +1 -0
- package/dist/ts3.4/client/docs/prepareForInline.d.ts +7 -0
- package/dist/ts3.4/client/docs/sourceDecorator.d.ts +9 -0
- package/dist/ts3.4/client/docs/types.d.ts +102 -0
- package/dist/ts3.4/client/preview/angular-beta/utils/NgComponentAnalyzer.d.ts +4 -2
- package/dist/ts3.4/server/angular-cli-webpack-older.d.ts +2 -1
- package/dist/ts3.4/server/framework-preset-angular-docs.d.ts +2 -0
- package/dist/ts3.4/server/framework-preset-angular.d.ts +3 -2
- package/dist/ts3.4/server/preset.d.ts +1 -1
- package/dist/ts3.9/builders/build-storybook/index.d.ts +2 -2
- package/dist/ts3.9/builders/build-storybook/index.js +34 -84
- package/dist/ts3.9/builders/build-storybook/schema.json +6 -2
- package/dist/ts3.9/builders/start-storybook/index.d.ts +1 -1
- package/dist/ts3.9/builders/start-storybook/index.js +40 -91
- package/dist/ts3.9/builders/start-storybook/schema.json +1 -2
- package/dist/ts3.9/builders/utils/build-standalone-errors-handler.js +13 -11
- package/dist/ts3.9/builders/utils/run-compodoc.js +41 -21
- package/dist/ts3.9/client/docs/compodoc.d.ts +18 -0
- package/dist/ts3.9/client/docs/compodoc.js +247 -0
- package/dist/ts3.9/client/docs/config.d.ts +15 -0
- package/dist/ts3.9/client/docs/config.js +22 -0
- package/dist/ts3.9/client/docs/index.d.ts +1 -0
- package/dist/ts3.9/client/docs/index.js +13 -0
- package/dist/ts3.9/client/docs/prepareForInline.d.ts +7 -0
- package/dist/ts3.9/client/docs/prepareForInline.js +45 -0
- package/dist/ts3.9/client/docs/sourceDecorator.d.ts +9 -0
- package/dist/ts3.9/client/docs/sourceDecorator.js +49 -0
- package/dist/ts3.9/client/docs/types.d.ts +102 -0
- package/dist/ts3.9/client/docs/types.js +2 -0
- package/dist/ts3.9/client/preview/angular/app.token.js +1 -1
- package/dist/ts3.9/client/preview/angular/components/app.component.js +55 -59
- package/dist/ts3.9/client/preview/angular/helpers.d.ts +2 -2
- package/dist/ts3.9/client/preview/angular/helpers.js +66 -80
- package/dist/ts3.9/client/preview/angular-beta/AbstractRenderer.js +77 -125
- package/dist/ts3.9/client/preview/angular-beta/CanvasRenderer.js +18 -81
- package/dist/ts3.9/client/preview/angular-beta/ComputesTemplateFromComponent.d.ts +3 -3
- package/dist/ts3.9/client/preview/angular-beta/ComputesTemplateFromComponent.js +75 -69
- package/dist/ts3.9/client/preview/angular-beta/DocsRenderer.js +41 -127
- package/dist/ts3.9/client/preview/angular-beta/RendererFactory.js +30 -66
- package/dist/ts3.9/client/preview/angular-beta/StorybookModule.js +42 -46
- package/dist/ts3.9/client/preview/angular-beta/StorybookProvider.js +15 -17
- package/dist/ts3.9/client/preview/angular-beta/StorybookWrapperComponent.js +58 -98
- package/dist/ts3.9/client/preview/angular-beta/utils/NgComponentAnalyzer.d.ts +4 -2
- package/dist/ts3.9/client/preview/angular-beta/utils/NgComponentAnalyzer.js +30 -77
- package/dist/ts3.9/client/preview/angular-beta/utils/NgModulesAnalyzer.js +10 -14
- package/dist/ts3.9/client/preview/decorateStory.d.ts +2 -2
- package/dist/ts3.9/client/preview/decorateStory.js +16 -36
- package/dist/ts3.9/client/preview/decorators.d.ts +4 -4
- package/dist/ts3.9/client/preview/decorators.js +22 -37
- package/dist/ts3.9/client/preview/globals.js +2 -2
- package/dist/ts3.9/client/preview/index.d.ts +3 -3
- package/dist/ts3.9/client/preview/index.js +8 -21
- package/dist/ts3.9/client/preview/render.d.ts +3 -3
- package/dist/ts3.9/client/preview/render.js +17 -56
- package/dist/ts3.9/client/preview/types-6-0.d.ts +2 -2
- package/dist/ts3.9/client/preview/types-7-0.d.ts +1 -1
- package/dist/ts3.9/demo/button.component.js +31 -22
- package/dist/ts3.9/demo/welcome.component.js +85 -18
- package/dist/ts3.9/server/__mocks-ng-workspace__/minimal-config/tsconfig.json +4 -1
- package/dist/ts3.9/server/__mocks-ng-workspace__/some-config/tsconfig.json +4 -1
- package/dist/ts3.9/server/__mocks-ng-workspace__/with-angularBrowserTarget/tsconfig.json +4 -1
- package/dist/ts3.9/server/__mocks-ng-workspace__/with-lib/tsconfig.json +4 -1
- package/dist/ts3.9/server/__mocks-ng-workspace__/with-nx/tsconfig.json +7 -2
- package/dist/ts3.9/server/__mocks-ng-workspace__/with-nx-workspace/tsconfig.json +7 -2
- package/dist/ts3.9/server/__mocks-ng-workspace__/with-options-styles/tsconfig.json +4 -1
- package/dist/ts3.9/server/__mocks-ng-workspace__/without-projects-entry/tsconfig.json +4 -1
- package/dist/ts3.9/server/__mocks-ng-workspace__/without-tsConfig/tsconfig.json +4 -1
- package/dist/ts3.9/server/angular-cli-webpack-12.2.x.js +38 -81
- package/dist/ts3.9/server/angular-cli-webpack-13.x.x.js +42 -85
- package/dist/ts3.9/server/angular-cli-webpack-older.d.ts +2 -1
- package/dist/ts3.9/server/angular-cli-webpack-older.js +77 -123
- package/dist/ts3.9/server/angular-devkit-build-webpack.js +72 -133
- package/dist/ts3.9/server/angular-read-workspace.js +44 -78
- package/dist/ts3.9/server/build.js +10 -47
- package/dist/ts3.9/server/create-fork-ts-checker-plugin.js +3 -3
- package/dist/ts3.9/server/framework-preset-angular-cli.js +111 -179
- package/dist/ts3.9/server/framework-preset-angular-docs.d.ts +2 -0
- package/dist/ts3.9/server/framework-preset-angular-docs.js +13 -0
- package/dist/ts3.9/server/framework-preset-angular-ivy.js +35 -92
- package/dist/ts3.9/server/framework-preset-angular.d.ts +3 -2
- package/dist/ts3.9/server/framework-preset-angular.js +88 -62
- package/dist/ts3.9/server/index.js +2 -2
- package/dist/ts3.9/server/ngx-template-loader/index.js +15 -15
- package/dist/ts3.9/server/options.d.ts +1 -1
- package/dist/ts3.9/server/options.js +1 -1
- package/dist/ts3.9/server/preset.d.ts +1 -1
- package/dist/ts3.9/server/preset.js +6 -14
- package/dist/ts3.9/server/ts_config.js +5 -5
- package/dist/ts3.9/server/utils/filter-out-styling-rules.js +4 -4
- package/dist/ts3.9/server/utils/module-is-available.js +1 -1
- package/dist/ts3.9/server/utils/normalize-asset-patterns.js +16 -31
- package/dist/ts3.9/server/utils/normalize-optimization.js +3 -3
- package/dist/ts3.9/types/index.d.ts +1 -1
- package/package.json +24 -26
- package/standalone.d.ts +5 -7
|
@@ -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
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
.
|
|
46
|
-
|
|
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,104 +33,83 @@ var getNonInputsOutputsProps = function (ngComponentInputsOutputs, props) {
|
|
|
52
33
|
* @param storyComponent
|
|
53
34
|
* @param initialProps
|
|
54
35
|
*/
|
|
55
|
-
exports.createStorybookWrapperComponent =
|
|
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
|
-
|
|
59
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
|
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(
|
|
74
|
-
|
|
75
|
-
|
|
52
|
+
Object.assign(this, storyProps);
|
|
53
|
+
this.changeDetectorRef.detectChanges();
|
|
54
|
+
this.changeDetectorRef.markForCheck();
|
|
76
55
|
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
var _this = this;
|
|
56
|
+
}
|
|
57
|
+
ngAfterViewInit() {
|
|
80
58
|
// Bind properties to component, if the story have component
|
|
81
59
|
if (this.storyComponentElementRef) {
|
|
82
|
-
|
|
83
|
-
|
|
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(
|
|
87
|
-
|
|
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`
|
|
91
69
|
this.storyComponentViewContainerRef.injector.get(core_1.ChangeDetectorRef).markForCheck();
|
|
92
70
|
this.changeDetectorRef.detectChanges();
|
|
93
|
-
// Once target component has been initialized, the storyProps$ observable keeps target component
|
|
71
|
+
// Once target component has been initialized, the storyProps$ observable keeps target component properties than are not Input|Output up to date
|
|
94
72
|
this.storyComponentPropsSubscription = this.storyProps$
|
|
95
|
-
.pipe(operators_1.skip(1), operators_1.map(
|
|
96
|
-
|
|
97
|
-
|
|
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) {
|
|
106
|
-
// In case a component uses an input with `bindingPropertyName` (ex: @Input('name'))
|
|
107
|
-
// find the value of the local propName in the component Inputs
|
|
108
|
-
// 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)));
|
|
114
|
-
}, {});
|
|
73
|
+
.pipe(operators_1.skip(1), operators_1.map((props) => {
|
|
74
|
+
const propsKeyToKeep = getNonInputsOutputsProps(ngComponentInputsOutputs, props);
|
|
75
|
+
return propsKeyToKeep.reduce((acc, p) => (Object.assign(Object.assign({}, acc), { [p]: props[p] })), {});
|
|
115
76
|
}))
|
|
116
|
-
.subscribe(
|
|
77
|
+
.subscribe((props) => {
|
|
117
78
|
// Replace inputs with new ones from props
|
|
118
|
-
Object.assign(
|
|
79
|
+
Object.assign(this.storyComponentElementRef, props);
|
|
119
80
|
// `markForCheck` the component in case this uses changeDetection: OnPush
|
|
120
81
|
// And then forces the `detectChanges`
|
|
121
|
-
|
|
122
|
-
|
|
82
|
+
this.storyComponentViewContainerRef.injector.get(core_1.ChangeDetectorRef).markForCheck();
|
|
83
|
+
this.changeDetectorRef.detectChanges();
|
|
123
84
|
});
|
|
124
85
|
}
|
|
125
|
-
}
|
|
126
|
-
|
|
86
|
+
}
|
|
87
|
+
ngOnDestroy() {
|
|
127
88
|
if (this.storyComponentPropsSubscription != null) {
|
|
128
89
|
this.storyComponentPropsSubscription.unsubscribe();
|
|
129
90
|
}
|
|
130
91
|
if (this.storyWrapperPropsSubscription != null) {
|
|
131
92
|
this.storyWrapperPropsSubscription.unsubscribe();
|
|
132
93
|
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}());
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
__decorate([
|
|
97
|
+
core_1.ViewChild(viewChildSelector, { static: true }),
|
|
98
|
+
__metadata("design:type", core_1.ElementRef)
|
|
99
|
+
], StorybookWrapperComponent.prototype, "storyComponentElementRef", void 0);
|
|
100
|
+
__decorate([
|
|
101
|
+
core_1.ViewChild(viewChildSelector, { read: core_1.ViewContainerRef, static: true }),
|
|
102
|
+
__metadata("design:type", core_1.ViewContainerRef)
|
|
103
|
+
], StorybookWrapperComponent.prototype, "storyComponentViewContainerRef", void 0);
|
|
104
|
+
StorybookWrapperComponent = __decorate([
|
|
105
|
+
core_1.Component({
|
|
106
|
+
selector,
|
|
107
|
+
template,
|
|
108
|
+
styles,
|
|
109
|
+
}),
|
|
110
|
+
__param(0, core_1.Inject(StorybookProvider_1.STORY_PROPS)),
|
|
111
|
+
__metadata("design:paramtypes", [rxjs_1.Subject,
|
|
112
|
+
core_1.ChangeDetectorRef])
|
|
113
|
+
], StorybookWrapperComponent);
|
|
154
114
|
return StorybookWrapperComponent;
|
|
155
115
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Component,
|
|
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) =>
|
|
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
|
-
|
|
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 =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
18
|
+
initialValue.inputs.push(...componentMetadata.inputs.map((i) => ({ propName: i, templateName: i })));
|
|
37
19
|
}
|
|
38
20
|
if (componentMetadata && componentMetadata.outputs) {
|
|
39
|
-
|
|
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(
|
|
47
|
-
var
|
|
48
|
-
|
|
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
|
-
|
|
32
|
+
const inputToAdd = {
|
|
52
33
|
propName: propertyName,
|
|
53
|
-
templateName: (
|
|
34
|
+
templateName: (_a = value.bindingPropertyName) !== null && _a !== void 0 ? _a : propertyName,
|
|
54
35
|
};
|
|
55
|
-
|
|
56
|
-
return
|
|
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
|
-
|
|
40
|
+
const outputToAdd = {
|
|
60
41
|
propName: propertyName,
|
|
61
|
-
templateName: (
|
|
42
|
+
templateName: (_b = value.bindingPropertyName) !== null && _b !== void 0 ? _b : propertyName,
|
|
62
43
|
};
|
|
63
|
-
|
|
64
|
-
return
|
|
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 =
|
|
50
|
+
exports.isDeclarable = (component) => {
|
|
70
51
|
if (!component) {
|
|
71
52
|
return false;
|
|
72
53
|
}
|
|
73
|
-
|
|
74
|
-
|
|
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 =
|
|
57
|
+
exports.isComponent = (component) => {
|
|
80
58
|
if (!component) {
|
|
81
59
|
return false;
|
|
82
60
|
}
|
|
83
|
-
|
|
84
|
-
|
|
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 =
|
|
94
|
-
|
|
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 =
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
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 =
|
|
11
|
+
exports.isComponentAlreadyDeclaredInModules = (componentToFind, moduleDeclarations, moduleImports) => {
|
|
11
12
|
if (moduleDeclarations &&
|
|
12
|
-
moduleDeclarations.some(
|
|
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(
|
|
20
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
35
|
+
const ngModuleDecorator = decorators.find((decorator) => decorator instanceof core_1.NgModule);
|
|
40
36
|
if (!ngModuleDecorator) {
|
|
41
37
|
return null;
|
|
42
38
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DecoratorFunction, LegacyStoryFn } from '@storybook/csf';
|
|
2
|
-
import { AngularFramework } from './types-6-0';
|
|
1
|
+
import type { DecoratorFunction, LegacyStoryFn } from '@storybook/csf';
|
|
2
|
+
import type { AngularFramework } from './types-6-0';
|
|
3
3
|
export default function decorateStory(mainStoryFn: LegacyStoryFn<AngularFramework>, decorators: DecoratorFunction<AngularFramework>[]): LegacyStoryFn<AngularFramework>;
|
|
4
4
|
export { decorateStory };
|
|
@@ -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
|
-
|
|
23
|
-
|
|
4
|
+
const store_1 = require("@storybook/store");
|
|
5
|
+
const ComputesTemplateFromComponent_1 = require("./angular-beta/ComputesTemplateFromComponent");
|
|
24
6
|
function decorateStory(mainStoryFn, decorators) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return previousStoryFn(
|
|
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
|
-
}
|
|
12
|
+
}, (context) => prepareMain(mainStoryFn(context), context));
|
|
31
13
|
return returnDecorators;
|
|
32
14
|
}
|
|
33
15
|
exports.default = decorateStory;
|
|
34
16
|
exports.decorateStory = decorateStory;
|
|
35
|
-
|
|
17
|
+
const prepareMain = (story, context) => {
|
|
36
18
|
var _a;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
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
|
-
|
|
30
|
+
const cleanArgsDecorator = (storyFn, context) => {
|
|
49
31
|
if (!context.argTypes || !context.args) {
|
|
50
32
|
return storyFn();
|
|
51
33
|
}
|
|
52
|
-
|
|
53
|
-
context.args = Object.entries(argsToClean).reduce(
|
|
54
|
-
|
|
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
|
|
39
|
+
return Object.assign(Object.assign({}, obj), { [key]: arg });
|
|
60
40
|
}
|
|
61
41
|
return obj;
|
|
62
42
|
}, {});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Type } from '@angular/core';
|
|
2
|
-
import { DecoratorFunction, StoryContext } from '@storybook/csf';
|
|
3
|
-
import { ICollection, NgModuleMetadata } from './types';
|
|
4
|
-
import { AngularFramework } from './types-6-0';
|
|
1
|
+
import type { Type } from '@angular/core';
|
|
2
|
+
import type { DecoratorFunction, StoryContext } from '@storybook/csf';
|
|
3
|
+
import type { ICollection, NgModuleMetadata } from './types';
|
|
4
|
+
import type { AngularFramework } from './types-6-0';
|
|
5
5
|
export declare const moduleMetadata: <TArgs = any>(metadata: Partial<NgModuleMetadata>) => DecoratorFunction<AngularFramework, TArgs>;
|
|
6
6
|
export declare const componentWrapperDecorator: <TArgs = any>(element: Type<unknown> | ((story: string) => string), props?: ICollection | ((storyContext: StoryContext<AngularFramework, TArgs>) => ICollection)) => DecoratorFunction<AngularFramework, TArgs>;
|
|
@@ -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
|
-
|
|
23
|
-
|
|
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 =
|
|
27
|
-
|
|
28
|
-
|
|
8
|
+
exports.moduleMetadata = (metadata) => (storyFn) => {
|
|
9
|
+
const story = storyFn();
|
|
10
|
+
const storyMetadata = story.moduleMetadata || {};
|
|
29
11
|
metadata = metadata || {};
|
|
30
|
-
return
|
|
31
|
-
declarations:
|
|
32
|
-
entryComponents:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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 =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
|
29
|
+
return Object.assign(Object.assign(Object.assign({}, story), { template }), (currentProps || story.props
|
|
45
30
|
? {
|
|
46
|
-
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
|
-
|
|
6
|
+
const global_1 = __importDefault(require("global"));
|
|
7
7
|
require("./angular-polyfills");
|
|
8
|
-
|
|
8
|
+
const { window: globalWindow } = global_1.default;
|
|
9
9
|
globalWindow.STORYBOOK_ENV = 'angular';
|