@storybook/angular 8.3.0-alpha.6 → 8.3.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/angular-beta/AbstractRenderer.d.ts +16 -15
- package/dist/client/angular-beta/AbstractRenderer.js +16 -15
- package/dist/client/angular-beta/ComputesTemplateFromComponent.d.ts +4 -2
- package/dist/client/angular-beta/ComputesTemplateFromComponent.js +7 -8
- package/dist/client/angular-beta/DocsRenderer.js +6 -9
- package/dist/client/angular-beta/StorybookModule.js +1 -3
- package/dist/client/angular-beta/StorybookModule.test.js +6 -6
- package/dist/client/angular-beta/StorybookWrapperComponent.d.ts +1 -3
- package/dist/client/angular-beta/StorybookWrapperComponent.js +1 -3
- package/dist/client/angular-beta/utils/BootstrapQueue.d.ts +5 -7
- package/dist/client/angular-beta/utils/BootstrapQueue.js +8 -13
- package/dist/client/angular-beta/utils/BootstrapQueue.test.js +2 -1
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.d.ts +3 -10
- package/dist/client/angular-beta/utils/NgComponentAnalyzer.js +3 -10
- package/dist/client/angular-beta/utils/PropertyExtractor.d.ts +0 -2
- package/dist/client/angular-beta/utils/PropertyExtractor.js +0 -2
- package/dist/client/angular-beta/utils/StoryUID.d.ts +8 -9
- package/dist/client/angular-beta/utils/StoryUID.js +9 -12
- package/dist/client/argsToTemplate.d.ts +13 -12
- package/dist/client/argsToTemplate.js +8 -6
- package/dist/client/decorators.d.ts +3 -4
- package/dist/client/decorators.js +3 -4
- package/dist/client/docs/__testfixtures__/doc-button/input.d.ts +7 -8
- package/dist/client/docs/__testfixtures__/doc-button/input.js +7 -8
- package/dist/client/docs/sourceDecorator.d.ts +2 -1
- package/dist/client/docs/sourceDecorator.js +2 -1
- package/dist/client/globals.d.ts +9 -11
- package/dist/client/globals.js +14 -20
- package/dist/client/types.d.ts +6 -6
- package/dist/server/angular-cli-webpack.js +6 -10
- package/dist/server/framework-preset-angular-cli.js +6 -15
- package/dist/server/framework-preset-angular-ivy.d.ts +2 -2
- package/dist/server/framework-preset-angular-ivy.js +10 -10
- package/dist/server/plugins/storybook-normalize-angular-entry-plugin.d.ts +4 -3
- package/dist/server/plugins/storybook-normalize-angular-entry-plugin.js +4 -3
- package/dist/types.d.ts +1 -3
- package/package.json +8 -8
- package/scripts/postbuild.js +5 -4
- package/template/cli/button.component.ts +11 -19
- package/template/cli/header.component.ts +47 -50
- package/template/cli/page.component.ts +54 -54
- package/.eslintrc.js +0 -16
|
@@ -7,14 +7,12 @@ type StoryRenderInfo = {
|
|
|
7
7
|
/**
|
|
8
8
|
* Attribute name for the story UID that may be written to the targetDOMNode.
|
|
9
9
|
*
|
|
10
|
-
* If a target DOM node has a story UID attribute, it will be used as part of
|
|
11
|
-
*
|
|
10
|
+
* If a target DOM node has a story UID attribute, it will be used as part of the selector for the
|
|
11
|
+
* Angular component.
|
|
12
12
|
*/
|
|
13
13
|
export declare const STORY_UID_ATTRIBUTE = "data-sb-story-uid";
|
|
14
14
|
export declare abstract class AbstractRenderer {
|
|
15
|
-
/**
|
|
16
|
-
* Wait and destroy the platform
|
|
17
|
-
*/
|
|
15
|
+
/** Wait and destroy the platform */
|
|
18
16
|
static resetApplications(domNode?: HTMLElement): void;
|
|
19
17
|
protected previousStoryRenderInfo: Map<HTMLElement, StoryRenderInfo>;
|
|
20
18
|
protected storyProps$: Subject<ICollection | undefined>;
|
|
@@ -24,8 +22,12 @@ export declare abstract class AbstractRenderer {
|
|
|
24
22
|
*
|
|
25
23
|
* @param storyFnAngular {StoryFnAngularReturnType}
|
|
26
24
|
* @param forced {boolean} If :
|
|
27
|
-
*
|
|
28
|
-
*
|
|
25
|
+
*
|
|
26
|
+
* - True render will only use the StoryFn `props' in storyProps observable that will update sotry's
|
|
27
|
+
* component/template properties. Improves performance without reloading the whole
|
|
28
|
+
* module&component if props changes
|
|
29
|
+
* - False fully recharges or initializes angular module & component
|
|
30
|
+
*
|
|
29
31
|
* @param component {Component}
|
|
30
32
|
*/
|
|
31
33
|
render({ storyFnAngular, forced, component, targetDOMNode, }: {
|
|
@@ -35,21 +37,20 @@ export declare abstract class AbstractRenderer {
|
|
|
35
37
|
targetDOMNode: HTMLElement;
|
|
36
38
|
}): Promise<void>;
|
|
37
39
|
/**
|
|
38
|
-
* Only ASCII alphanumerics can be used as HTML tag name.
|
|
39
|
-
* https://html.spec.whatwg.org/#elements-2
|
|
40
|
+
* Only ASCII alphanumerics can be used as HTML tag name. https://html.spec.whatwg.org/#elements-2
|
|
40
41
|
*
|
|
41
42
|
* Therefore, stories break when non-ASCII alphanumerics are included in target selector.
|
|
42
43
|
* https://github.com/storybookjs/storybook/issues/15147
|
|
43
44
|
*
|
|
44
|
-
* This method returns storyId when it doesn't contain any non-ASCII alphanumerics.
|
|
45
|
-
*
|
|
46
|
-
*
|
|
45
|
+
* This method returns storyId when it doesn't contain any non-ASCII alphanumerics. Otherwise, it
|
|
46
|
+
* generates a valid HTML tag name from storyId by removing non-ASCII alphanumerics from storyId,
|
|
47
|
+
* prefixing "sb-", and suffixing "-component"
|
|
48
|
+
*
|
|
47
49
|
* @memberof AbstractRenderer
|
|
50
|
+
* @protected
|
|
48
51
|
*/
|
|
49
52
|
protected generateTargetSelectorFromStoryId(id: string): string;
|
|
50
|
-
/**
|
|
51
|
-
* Adds DOM element that angular will use as bootstrap component.
|
|
52
|
-
*/
|
|
53
|
+
/** Adds DOM element that angular will use as bootstrap component. */
|
|
53
54
|
protected initAngularRootElement(targetDOMNode: HTMLElement, targetSelector: string): void;
|
|
54
55
|
private fullRendererRequired;
|
|
55
56
|
}
|
|
@@ -12,17 +12,15 @@ const applicationRefs = new Map();
|
|
|
12
12
|
/**
|
|
13
13
|
* Attribute name for the story UID that may be written to the targetDOMNode.
|
|
14
14
|
*
|
|
15
|
-
* If a target DOM node has a story UID attribute, it will be used as part of
|
|
16
|
-
*
|
|
15
|
+
* If a target DOM node has a story UID attribute, it will be used as part of the selector for the
|
|
16
|
+
* Angular component.
|
|
17
17
|
*/
|
|
18
18
|
exports.STORY_UID_ATTRIBUTE = 'data-sb-story-uid';
|
|
19
19
|
class AbstractRenderer {
|
|
20
20
|
constructor() {
|
|
21
21
|
this.previousStoryRenderInfo = new Map();
|
|
22
22
|
}
|
|
23
|
-
/**
|
|
24
|
-
* Wait and destroy the platform
|
|
25
|
-
*/
|
|
23
|
+
/** Wait and destroy the platform */
|
|
26
24
|
static resetApplications(domNode) {
|
|
27
25
|
applicationRefs.forEach((appRef, appDOMNode) => {
|
|
28
26
|
if (!appRef.destroyed && (!domNode || appDOMNode === domNode)) {
|
|
@@ -35,8 +33,12 @@ class AbstractRenderer {
|
|
|
35
33
|
*
|
|
36
34
|
* @param storyFnAngular {StoryFnAngularReturnType}
|
|
37
35
|
* @param forced {boolean} If :
|
|
38
|
-
*
|
|
39
|
-
*
|
|
36
|
+
*
|
|
37
|
+
* - True render will only use the StoryFn `props' in storyProps observable that will update sotry's
|
|
38
|
+
* component/template properties. Improves performance without reloading the whole
|
|
39
|
+
* module&component if props changes
|
|
40
|
+
* - False fully recharges or initializes angular module & component
|
|
41
|
+
*
|
|
40
42
|
* @param component {Component}
|
|
41
43
|
*/
|
|
42
44
|
async render({ storyFnAngular, forced, component, targetDOMNode, }) {
|
|
@@ -86,25 +88,24 @@ class AbstractRenderer {
|
|
|
86
88
|
applicationRefs.set(targetDOMNode, applicationRef);
|
|
87
89
|
}
|
|
88
90
|
/**
|
|
89
|
-
* Only ASCII alphanumerics can be used as HTML tag name.
|
|
90
|
-
* https://html.spec.whatwg.org/#elements-2
|
|
91
|
+
* Only ASCII alphanumerics can be used as HTML tag name. https://html.spec.whatwg.org/#elements-2
|
|
91
92
|
*
|
|
92
93
|
* Therefore, stories break when non-ASCII alphanumerics are included in target selector.
|
|
93
94
|
* https://github.com/storybookjs/storybook/issues/15147
|
|
94
95
|
*
|
|
95
|
-
* This method returns storyId when it doesn't contain any non-ASCII alphanumerics.
|
|
96
|
-
*
|
|
97
|
-
*
|
|
96
|
+
* This method returns storyId when it doesn't contain any non-ASCII alphanumerics. Otherwise, it
|
|
97
|
+
* generates a valid HTML tag name from storyId by removing non-ASCII alphanumerics from storyId,
|
|
98
|
+
* prefixing "sb-", and suffixing "-component"
|
|
99
|
+
*
|
|
98
100
|
* @memberof AbstractRenderer
|
|
101
|
+
* @protected
|
|
99
102
|
*/
|
|
100
103
|
generateTargetSelectorFromStoryId(id) {
|
|
101
104
|
const invalidHtmlTag = /[^A-Za-z0-9-]/g;
|
|
102
105
|
const storyIdIsInvalidHtmlTagName = invalidHtmlTag.test(id);
|
|
103
106
|
return storyIdIsInvalidHtmlTagName ? `sb-${id.replace(invalidHtmlTag, '')}-component` : id;
|
|
104
107
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Adds DOM element that angular will use as bootstrap component.
|
|
107
|
-
*/
|
|
108
|
+
/** Adds DOM element that angular will use as bootstrap component. */
|
|
108
109
|
initAngularRootElement(targetDOMNode, targetSelector) {
|
|
109
110
|
targetDOMNode.innerHTML = '';
|
|
110
111
|
targetDOMNode.appendChild(document.createElement(targetSelector));
|
|
@@ -2,12 +2,13 @@ import { ArgTypes } from 'storybook/internal/types';
|
|
|
2
2
|
import { Type } from '@angular/core';
|
|
3
3
|
import { ICollection } from '../types';
|
|
4
4
|
/**
|
|
5
|
-
* Returns the property name, if it can be accessed with dot notation. If not,
|
|
6
|
-
*
|
|
5
|
+
* Returns the property name, if it can be accessed with dot notation. If not, it returns
|
|
6
|
+
* `this['propertyName']`.
|
|
7
7
|
*/
|
|
8
8
|
export declare const formatPropInTemplate: (propertyName: string) => string;
|
|
9
9
|
/**
|
|
10
10
|
* Converts a component into a template with inputs/outputs present in initial props
|
|
11
|
+
*
|
|
11
12
|
* @param component
|
|
12
13
|
* @param initialProps
|
|
13
14
|
* @param innerTemplate
|
|
@@ -15,6 +16,7 @@ export declare const formatPropInTemplate: (propertyName: string) => string;
|
|
|
15
16
|
export declare const computesTemplateFromComponent: (component: Type<unknown>, initialProps?: ICollection, innerTemplate?: string) => string;
|
|
16
17
|
/**
|
|
17
18
|
* Converts a component into a template with inputs/outputs present in initial props
|
|
19
|
+
*
|
|
18
20
|
* @param component
|
|
19
21
|
* @param initialProps
|
|
20
22
|
* @param innerTemplate
|
|
@@ -3,14 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.computesTemplateSourceFromComponent = exports.computesTemplateFromComponent = exports.formatPropInTemplate = void 0;
|
|
4
4
|
const NgComponentAnalyzer_1 = require("./utils/NgComponentAnalyzer");
|
|
5
5
|
/**
|
|
6
|
-
* Check if the name matches the criteria for a valid identifier.
|
|
7
|
-
*
|
|
8
|
-
* It cannot start with a digit.
|
|
6
|
+
* Check if the name matches the criteria for a valid identifier. A valid identifier can only
|
|
7
|
+
* contain letters, digits, underscores, or dollar signs. It cannot start with a digit.
|
|
9
8
|
*/
|
|
10
9
|
const isValidIdentifier = (name) => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name);
|
|
11
10
|
/**
|
|
12
|
-
* Returns the property name, if it can be accessed with dot notation. If not,
|
|
13
|
-
*
|
|
11
|
+
* Returns the property name, if it can be accessed with dot notation. If not, it returns
|
|
12
|
+
* `this['propertyName']`.
|
|
14
13
|
*/
|
|
15
14
|
const formatPropInTemplate = (propertyName) => isValidIdentifier(propertyName) ? propertyName : `this['${propertyName}']`;
|
|
16
15
|
exports.formatPropInTemplate = formatPropInTemplate;
|
|
@@ -29,6 +28,7 @@ const separateInputsOutputsAttributes = (ngComponentInputsOutputs, props = {}) =
|
|
|
29
28
|
};
|
|
30
29
|
/**
|
|
31
30
|
* Converts a component into a template with inputs/outputs present in initial props
|
|
31
|
+
*
|
|
32
32
|
* @param component
|
|
33
33
|
* @param initialProps
|
|
34
34
|
* @param innerTemplate
|
|
@@ -50,9 +50,7 @@ const computesTemplateFromComponent = (component, initialProps, innerTemplate =
|
|
|
50
50
|
return buildTemplate(ngComponentMetadata.selector, innerTemplate, templateInputs, templateOutputs);
|
|
51
51
|
};
|
|
52
52
|
exports.computesTemplateFromComponent = computesTemplateFromComponent;
|
|
53
|
-
/**
|
|
54
|
-
* Stringify an object with a placholder in the circular references.
|
|
55
|
-
*/
|
|
53
|
+
/** Stringify an object with a placholder in the circular references. */
|
|
56
54
|
function stringifyCircular(obj) {
|
|
57
55
|
const seen = new Set();
|
|
58
56
|
return JSON.stringify(obj, (key, value) => {
|
|
@@ -89,6 +87,7 @@ const createAngularInputProperty = ({ propertyName, value, argType, }) => {
|
|
|
89
87
|
};
|
|
90
88
|
/**
|
|
91
89
|
* Converts a component into a template with inputs/outputs present in initial props
|
|
90
|
+
*
|
|
92
91
|
* @param component
|
|
93
92
|
* @param initialProps
|
|
94
93
|
* @param innerTemplate
|
|
@@ -9,22 +9,19 @@ class DocsRenderer extends AbstractRenderer_1.AbstractRenderer {
|
|
|
9
9
|
async render(options) {
|
|
10
10
|
const channel = preview_api_1.addons.getChannel();
|
|
11
11
|
/**
|
|
12
|
-
* Destroy and recreate the PlatformBrowserDynamic of angular
|
|
13
|
-
*
|
|
14
|
-
* not destroy angular between each rendering but do it when the
|
|
12
|
+
* Destroy and recreate the PlatformBrowserDynamic of angular For several stories to be rendered
|
|
13
|
+
* in the same docs we should not destroy angular between each rendering but do it when the
|
|
15
14
|
* rendered stories are not needed anymore.
|
|
16
15
|
*
|
|
17
|
-
* Note for improvement: currently there is one event per story
|
|
18
|
-
*
|
|
19
|
-
*
|
|
16
|
+
* Note for improvement: currently there is one event per story rendered in the doc. But one
|
|
17
|
+
* event could be enough for the whole docs
|
|
20
18
|
*/
|
|
21
19
|
channel.once(core_events_1.STORY_CHANGED, async () => {
|
|
22
20
|
await DocsRenderer.resetApplications();
|
|
23
21
|
});
|
|
24
22
|
/**
|
|
25
|
-
* Destroy and recreate the PlatformBrowserDynamic of angular
|
|
26
|
-
*
|
|
27
|
-
* for previous component
|
|
23
|
+
* Destroy and recreate the PlatformBrowserDynamic of angular when doc re render. Allows to call
|
|
24
|
+
* ngOnDestroy of angular for previous component
|
|
28
25
|
*/
|
|
29
26
|
channel.once(core_events_1.DOCS_RENDERED, async () => {
|
|
30
27
|
await DocsRenderer.resetApplications();
|
|
@@ -10,9 +10,7 @@ const getApplication = ({ storyFnAngular, component, targetSelector, analyzedMet
|
|
|
10
10
|
if (!hasTemplate && component) {
|
|
11
11
|
template = (0, ComputesTemplateFromComponent_1.computesTemplateFromComponent)(component, props, '');
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
14
|
-
* Create a component that wraps generated template and gives it props
|
|
15
|
-
*/
|
|
13
|
+
/** Create a component that wraps generated template and gives it props */
|
|
16
14
|
return (0, StorybookWrapperComponent_1.createStorybookWrapperComponent)({
|
|
17
15
|
moduleMetadata,
|
|
18
16
|
selector: targetSelector,
|
|
@@ -57,12 +57,12 @@ const PropertyExtractor_1 = require("./utils/PropertyExtractor");
|
|
|
57
57
|
selector: 'foo',
|
|
58
58
|
template: `
|
|
59
59
|
<p id="input">{{ input }}</p>
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
60
|
+
<p id="inputBindingPropertyName">{{ localPropertyName }}</p>
|
|
61
|
+
<p id="setterCallNb">{{ setterCallNb }}</p>
|
|
62
|
+
<p id="localProperty">{{ localProperty }}</p>
|
|
63
|
+
<p id="localFunction">{{ localFunction() }}</p>
|
|
64
|
+
<p id="output" (click)="output.emit('outputEmitted')"></p>
|
|
65
|
+
<p id="outputBindingPropertyName" (click)="localOutput.emit('outputEmitted')"></p>
|
|
66
66
|
`,
|
|
67
67
|
})
|
|
68
68
|
], FooComponent);
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Type } from '@angular/core';
|
|
2
2
|
import { ICollection, NgModuleMetadata } from '../types';
|
|
3
3
|
import { PropertyExtractor } from './utils/PropertyExtractor';
|
|
4
|
-
/**
|
|
5
|
-
* Wraps the story template into a component
|
|
6
|
-
*/
|
|
4
|
+
/** Wraps the story template into a component */
|
|
7
5
|
export declare const createStorybookWrapperComponent: ({ selector, template, storyComponent, styles, moduleMetadata, initialProps, analyzedMetadata, }: {
|
|
8
6
|
selector: string;
|
|
9
7
|
template: string;
|
|
@@ -28,9 +28,7 @@ const getNonInputsOutputsProps = (ngComponentInputsOutputs, props = {}) => {
|
|
|
28
28
|
.map((o) => o.templateName);
|
|
29
29
|
return Object.keys(props).filter((k) => ![...inputs, ...outputs].includes(k));
|
|
30
30
|
};
|
|
31
|
-
/**
|
|
32
|
-
* Wraps the story template into a component
|
|
33
|
-
*/
|
|
31
|
+
/** Wraps the story template into a component */
|
|
34
32
|
const createStorybookWrapperComponent = ({ selector, template, storyComponent, styles, moduleMetadata, initialProps, analyzedMetadata, }) => {
|
|
35
33
|
// In ivy, a '' selector is not allowed, therefore we need to just set it to anything if
|
|
36
34
|
// storyComponent was not provided.
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { ApplicationRef } from '@angular/core';
|
|
2
2
|
/**
|
|
3
|
-
* Queue bootstrapping, so that only one application can be bootstrapped at a
|
|
4
|
-
* time.
|
|
3
|
+
* Queue bootstrapping, so that only one application can be bootstrapped at a time.
|
|
5
4
|
*
|
|
6
|
-
* Bootstrapping multiple applications at once can cause Angular to throw an
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* application at a time.
|
|
5
|
+
* Bootstrapping multiple applications at once can cause Angular to throw an error that a component
|
|
6
|
+
* is declared in multiple modules. This avoids two stories confusing the Angular compiler, by
|
|
7
|
+
* bootstrapping more that one application at a time.
|
|
10
8
|
*
|
|
11
|
-
* @param fn
|
|
9
|
+
* @param fn Callback that should complete the bootstrap process
|
|
12
10
|
* @returns ApplicationRef from the completed bootstrap process
|
|
13
11
|
*/
|
|
14
12
|
export declare const queueBootstrapping: (fn: () => Promise<ApplicationRef>) => Promise<ApplicationRef>;
|
|
@@ -27,8 +27,8 @@ exports.queueBootstrapping = void 0;
|
|
|
27
27
|
const queue = [];
|
|
28
28
|
let isProcessing = false;
|
|
29
29
|
/**
|
|
30
|
-
* Reset compiled components because we often want to compile the same component with
|
|
31
|
-
*
|
|
30
|
+
* Reset compiled components because we often want to compile the same component with more than one
|
|
31
|
+
* NgModule.
|
|
32
32
|
*/
|
|
33
33
|
const resetCompiledComponents = async () => {
|
|
34
34
|
try {
|
|
@@ -41,22 +41,17 @@ const resetCompiledComponents = async () => {
|
|
|
41
41
|
ɵresetCompiledComponents();
|
|
42
42
|
}
|
|
43
43
|
catch (e) {
|
|
44
|
-
/**
|
|
45
|
-
* noop catch
|
|
46
|
-
* This means angular removed or modified ɵresetCompiledComponents
|
|
47
|
-
*/
|
|
44
|
+
/** Noop catch This means angular removed or modified ɵresetCompiledComponents */
|
|
48
45
|
}
|
|
49
46
|
};
|
|
50
47
|
/**
|
|
51
|
-
* Queue bootstrapping, so that only one application can be bootstrapped at a
|
|
52
|
-
* time.
|
|
48
|
+
* Queue bootstrapping, so that only one application can be bootstrapped at a time.
|
|
53
49
|
*
|
|
54
|
-
* Bootstrapping multiple applications at once can cause Angular to throw an
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* application at a time.
|
|
50
|
+
* Bootstrapping multiple applications at once can cause Angular to throw an error that a component
|
|
51
|
+
* is declared in multiple modules. This avoids two stories confusing the Angular compiler, by
|
|
52
|
+
* bootstrapping more that one application at a time.
|
|
58
53
|
*
|
|
59
|
-
* @param fn
|
|
54
|
+
* @param fn Callback that should complete the bootstrap process
|
|
60
55
|
* @returns ApplicationRef from the completed bootstrap process
|
|
61
56
|
*/
|
|
62
57
|
const queueBootstrapping = (fn) => {
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
// @vitest-environment happy-dom
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
4
|
const vitest_1 = require("vitest");
|
|
5
|
+
const rxjs_1 = require("rxjs");
|
|
6
6
|
const BootstrapQueue_1 = require("./BootstrapQueue");
|
|
7
7
|
const instantWaitFor = (fn) => {
|
|
8
8
|
return vitest_1.vi.waitFor(fn, {
|
|
9
9
|
interval: 0,
|
|
10
|
+
timeout: 10000,
|
|
10
11
|
});
|
|
11
12
|
};
|
|
12
13
|
(0, vitest_1.describe)('BootstrapQueue', () => {
|
|
@@ -9,21 +9,14 @@ export type ComponentInputsOutputs = {
|
|
|
9
9
|
templateName: string;
|
|
10
10
|
}[];
|
|
11
11
|
};
|
|
12
|
-
/**
|
|
13
|
-
* Returns component Inputs / Outputs by browsing these properties and decorator
|
|
14
|
-
*/
|
|
12
|
+
/** Returns component Inputs / Outputs by browsing these properties and decorator */
|
|
15
13
|
export declare const getComponentInputsOutputs: (component: any) => ComponentInputsOutputs;
|
|
16
14
|
export declare const isDeclarable: (component: any) => boolean;
|
|
17
15
|
export declare const isComponent: (component: any) => component is Type<unknown>;
|
|
18
16
|
export declare const isStandaloneComponent: (component: any) => component is Type<unknown>;
|
|
19
|
-
/**
|
|
20
|
-
* Returns all component decorator properties
|
|
21
|
-
* is used to get all `@Input` and `@Output` Decorator
|
|
22
|
-
*/
|
|
17
|
+
/** Returns all component decorator properties is used to get all `@Input` and `@Output` Decorator */
|
|
23
18
|
export declare const getComponentPropsDecoratorMetadata: (component: any) => {
|
|
24
19
|
[key: string]: any[];
|
|
25
20
|
};
|
|
26
|
-
/**
|
|
27
|
-
* Returns component decorator `@Component`
|
|
28
|
-
*/
|
|
21
|
+
/** Returns component decorator `@Component` */
|
|
29
22
|
export declare const getComponentDecoratorMetadata: (component: any) => Component | undefined;
|
|
@@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getComponentDecoratorMetadata = exports.getComponentPropsDecoratorMetadata = exports.isStandaloneComponent = exports.isComponent = exports.isDeclarable = exports.getComponentInputsOutputs = void 0;
|
|
4
4
|
const core_1 = require("@angular/core");
|
|
5
5
|
const reflectionCapabilities = new core_1.ɵReflectionCapabilities();
|
|
6
|
-
/**
|
|
7
|
-
* Returns component Inputs / Outputs by browsing these properties and decorator
|
|
8
|
-
*/
|
|
6
|
+
/** Returns component Inputs / Outputs by browsing these properties and decorator */
|
|
9
7
|
const getComponentInputsOutputs = (component) => {
|
|
10
8
|
const componentMetadata = (0, exports.getComponentDecoratorMetadata)(component);
|
|
11
9
|
const componentPropsMetadata = (0, exports.getComponentPropsDecoratorMetadata)(component);
|
|
@@ -82,17 +80,12 @@ const isStandaloneComponent = (component) => {
|
|
|
82
80
|
return (decorators || []).some((d) => (d instanceof core_1.Component || d instanceof core_1.Directive || d instanceof core_1.Pipe) && d.standalone);
|
|
83
81
|
};
|
|
84
82
|
exports.isStandaloneComponent = isStandaloneComponent;
|
|
85
|
-
/**
|
|
86
|
-
* Returns all component decorator properties
|
|
87
|
-
* is used to get all `@Input` and `@Output` Decorator
|
|
88
|
-
*/
|
|
83
|
+
/** Returns all component decorator properties is used to get all `@Input` and `@Output` Decorator */
|
|
89
84
|
const getComponentPropsDecoratorMetadata = (component) => {
|
|
90
85
|
return reflectionCapabilities.propMetadata(component);
|
|
91
86
|
};
|
|
92
87
|
exports.getComponentPropsDecoratorMetadata = getComponentPropsDecoratorMetadata;
|
|
93
|
-
/**
|
|
94
|
-
* Returns component decorator `@Component`
|
|
95
|
-
*/
|
|
88
|
+
/** Returns component decorator `@Component` */
|
|
96
89
|
const getComponentDecoratorMetadata = (component) => {
|
|
97
90
|
const decorators = reflectionCapabilities.annotations(component);
|
|
98
91
|
return decorators.reverse().find((d) => d instanceof core_1.Component);
|
|
@@ -19,8 +19,6 @@ export declare class PropertyExtractor implements NgModuleMetadata {
|
|
|
19
19
|
* - Removes Restricted Imports
|
|
20
20
|
* - Extracts providers from ModuleWithProviders
|
|
21
21
|
* - Returns a new NgModuleMetadata object
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
22
|
*/
|
|
25
23
|
private analyzeMetadata;
|
|
26
24
|
static analyzeRestricted: (ngModule: NgModule) => [boolean] | [boolean, Provider];
|
|
@@ -30,8 +30,6 @@ class PropertyExtractor {
|
|
|
30
30
|
* - Removes Restricted Imports
|
|
31
31
|
* - Extracts providers from ModuleWithProviders
|
|
32
32
|
* - Returns a new NgModuleMetadata object
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
33
|
*/
|
|
36
34
|
this.analyzeMetadata = (metadata) => {
|
|
37
35
|
const declarations = [...(metadata?.declarations || [])];
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Increments the count for a storyId and returns the next UID.
|
|
3
3
|
*
|
|
4
|
-
* When a story is bootstrapped, the storyId is used as the element tag. That
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* it unique.
|
|
4
|
+
* When a story is bootstrapped, the storyId is used as the element tag. That becomes an issue when
|
|
5
|
+
* a story is rendered multiple times in the same docs page. This function returns a UID that is
|
|
6
|
+
* appended to the storyId to make it unique.
|
|
8
7
|
*
|
|
9
|
-
* @param storyId
|
|
10
|
-
* @returns
|
|
8
|
+
* @param storyId Id of a story
|
|
9
|
+
* @returns Uid of a story
|
|
11
10
|
*/
|
|
12
11
|
export declare const getNextStoryUID: (storyId: string) => string;
|
|
13
12
|
/**
|
|
14
13
|
* Clears the storyId counts.
|
|
15
14
|
*
|
|
16
|
-
* Can be useful for testing, where you need predictable increments, without
|
|
17
|
-
*
|
|
15
|
+
* Can be useful for testing, where you need predictable increments, without reloading the global
|
|
16
|
+
* state.
|
|
18
17
|
*
|
|
19
18
|
* If onlyStoryId is provided, only that storyId is cleared.
|
|
20
19
|
*
|
|
21
|
-
* @param onlyStoryId
|
|
20
|
+
* @param onlyStoryId Id of a story
|
|
22
21
|
*/
|
|
23
22
|
export declare const clearStoryUIDs: (onlyStoryId?: string) => void;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.clearStoryUIDs = exports.getNextStoryUID = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* Count of stories for each storyId.
|
|
6
|
-
*/
|
|
4
|
+
/** Count of stories for each storyId. */
|
|
7
5
|
const storyCounts = new Map();
|
|
8
6
|
/**
|
|
9
7
|
* Increments the count for a storyId and returns the next UID.
|
|
10
8
|
*
|
|
11
|
-
* When a story is bootstrapped, the storyId is used as the element tag. That
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* it unique.
|
|
9
|
+
* When a story is bootstrapped, the storyId is used as the element tag. That becomes an issue when
|
|
10
|
+
* a story is rendered multiple times in the same docs page. This function returns a UID that is
|
|
11
|
+
* appended to the storyId to make it unique.
|
|
15
12
|
*
|
|
16
|
-
* @param storyId
|
|
17
|
-
* @returns
|
|
13
|
+
* @param storyId Id of a story
|
|
14
|
+
* @returns Uid of a story
|
|
18
15
|
*/
|
|
19
16
|
const getNextStoryUID = (storyId) => {
|
|
20
17
|
if (!storyCounts.has(storyId)) {
|
|
@@ -28,12 +25,12 @@ exports.getNextStoryUID = getNextStoryUID;
|
|
|
28
25
|
/**
|
|
29
26
|
* Clears the storyId counts.
|
|
30
27
|
*
|
|
31
|
-
* Can be useful for testing, where you need predictable increments, without
|
|
32
|
-
*
|
|
28
|
+
* Can be useful for testing, where you need predictable increments, without reloading the global
|
|
29
|
+
* state.
|
|
33
30
|
*
|
|
34
31
|
* If onlyStoryId is provided, only that storyId is cleared.
|
|
35
32
|
*
|
|
36
|
-
* @param onlyStoryId
|
|
33
|
+
* @param onlyStoryId Id of a story
|
|
37
34
|
*/
|
|
38
35
|
const clearStoryUIDs = (onlyStoryId) => {
|
|
39
36
|
if (onlyStoryId !== undefined && onlyStoryId !== null) {
|
|
@@ -5,27 +5,28 @@
|
|
|
5
5
|
*/
|
|
6
6
|
export interface ArgsToTemplateOptions<T> {
|
|
7
7
|
/**
|
|
8
|
-
* An array of keys to specifically include in the output.
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* An array of keys to specifically include in the output. If provided, only the keys from this
|
|
9
|
+
* array will be included in the output, irrespective of the `exclude` option. Undefined values
|
|
10
|
+
* will still be excluded from the output.
|
|
11
11
|
*/
|
|
12
12
|
include?: Array<T>;
|
|
13
13
|
/**
|
|
14
|
-
* An array of keys to specifically exclude from the output.
|
|
15
|
-
*
|
|
16
|
-
* ignored if the `include` option is also provided
|
|
14
|
+
* An array of keys to specifically exclude from the output. If provided, these keys will be
|
|
15
|
+
* omitted from the output. This option is ignored if the `include` option is also provided
|
|
17
16
|
*/
|
|
18
17
|
exclude?: Array<T>;
|
|
19
18
|
}
|
|
20
19
|
/**
|
|
21
|
-
* Converts an object of arguments to a string of property and event bindings and excludes undefined
|
|
22
|
-
* Why? Because Angular treats undefined values in property bindings as an actual value
|
|
23
|
-
*
|
|
24
|
-
*
|
|
20
|
+
* Converts an object of arguments to a string of property and event bindings and excludes undefined
|
|
21
|
+
* values. Why? Because Angular treats undefined values in property bindings as an actual value and
|
|
22
|
+
* does not apply the default value of the property as soon as the binding is set. This feels
|
|
23
|
+
* counter-intuitive and is a common source of bugs in stories.
|
|
24
|
+
*
|
|
25
25
|
* @example
|
|
26
|
+
*
|
|
26
27
|
* ```ts
|
|
27
28
|
* // component.ts
|
|
28
|
-
|
|
29
|
+
* ㅤ@Component({ selector: 'example' })
|
|
29
30
|
* export class ExampleComponent {
|
|
30
31
|
* ㅤ@Input() input1: string = 'Default Input1';
|
|
31
32
|
* ㅤ@Input() input2: string = 'Default Input2';
|
|
@@ -49,7 +50,7 @@ export interface ArgsToTemplateOptions<T> {
|
|
|
49
50
|
* input1: 'Input 1',
|
|
50
51
|
* click: { action: 'clicked' },
|
|
51
52
|
* },
|
|
52
|
-
*};
|
|
53
|
+
* };
|
|
53
54
|
* ```
|
|
54
55
|
*/
|
|
55
56
|
export declare function argsToTemplate<A extends Record<string, any>>(args: A, options?: ArgsToTemplateOptions<keyof A>): string;
|
|
@@ -3,14 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.argsToTemplate = void 0;
|
|
4
4
|
const ComputesTemplateFromComponent_1 = require("./angular-beta/ComputesTemplateFromComponent");
|
|
5
5
|
/**
|
|
6
|
-
* Converts an object of arguments to a string of property and event bindings and excludes undefined
|
|
7
|
-
* Why? Because Angular treats undefined values in property bindings as an actual value
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* Converts an object of arguments to a string of property and event bindings and excludes undefined
|
|
7
|
+
* values. Why? Because Angular treats undefined values in property bindings as an actual value and
|
|
8
|
+
* does not apply the default value of the property as soon as the binding is set. This feels
|
|
9
|
+
* counter-intuitive and is a common source of bugs in stories.
|
|
10
|
+
*
|
|
10
11
|
* @example
|
|
12
|
+
*
|
|
11
13
|
* ```ts
|
|
12
14
|
* // component.ts
|
|
13
|
-
|
|
15
|
+
* ㅤ@Component({ selector: 'example' })
|
|
14
16
|
* export class ExampleComponent {
|
|
15
17
|
* ㅤ@Input() input1: string = 'Default Input1';
|
|
16
18
|
* ㅤ@Input() input2: string = 'Default Input2';
|
|
@@ -34,7 +36,7 @@ const ComputesTemplateFromComponent_1 = require("./angular-beta/ComputesTemplate
|
|
|
34
36
|
* input1: 'Input 1',
|
|
35
37
|
* click: { action: 'clicked' },
|
|
36
38
|
* },
|
|
37
|
-
*};
|
|
39
|
+
* };
|
|
38
40
|
* ```
|
|
39
41
|
*/
|
|
40
42
|
function argsToTemplate(args, options = {}) {
|
|
@@ -4,11 +4,10 @@ import { ApplicationConfig } from '@angular/platform-browser';
|
|
|
4
4
|
import { AngularRenderer, ICollection, NgModuleMetadata } from './types';
|
|
5
5
|
export declare const moduleMetadata: <TArgs = any>(metadata: Partial<NgModuleMetadata>) => DecoratorFunction<AngularRenderer, TArgs>;
|
|
6
6
|
/**
|
|
7
|
-
* Decorator to set the config options which are available during the application bootstrap
|
|
7
|
+
* Decorator to set the config options which are available during the application bootstrap
|
|
8
|
+
* operation
|
|
8
9
|
*/
|
|
9
10
|
export declare function applicationConfig<TArgs = any>(
|
|
10
|
-
/**
|
|
11
|
-
* Set of config options available during the application bootstrap operation.
|
|
12
|
-
*/
|
|
11
|
+
/** Set of config options available during the application bootstrap operation. */
|
|
13
12
|
config: ApplicationConfig): DecoratorFunction<AngularRenderer, TArgs>;
|
|
14
13
|
export declare const componentWrapperDecorator: <TArgs = any>(element: Type<unknown> | ((story: string) => string), props?: ICollection | ((storyContext: StoryContext<AngularRenderer, TArgs>) => ICollection)) => DecoratorFunction<AngularRenderer, TArgs>;
|
|
@@ -25,12 +25,11 @@ const moduleMetadata = (metadata) => (storyFn) => {
|
|
|
25
25
|
};
|
|
26
26
|
exports.moduleMetadata = moduleMetadata;
|
|
27
27
|
/**
|
|
28
|
-
* Decorator to set the config options which are available during the application bootstrap
|
|
28
|
+
* Decorator to set the config options which are available during the application bootstrap
|
|
29
|
+
* operation
|
|
29
30
|
*/
|
|
30
31
|
function applicationConfig(
|
|
31
|
-
/**
|
|
32
|
-
* Set of config options available during the application bootstrap operation.
|
|
33
|
-
*/
|
|
32
|
+
/** Set of config options available during the application bootstrap operation. */
|
|
34
33
|
config) {
|
|
35
34
|
return (storyFn) => {
|
|
36
35
|
const story = storyFn();
|