@storybook/angular 9.2.0-alpha.3 → 10.0.0-beta.0
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 +3 -1
- package/dist/_browser-chunks/chunk-CV6HSYTZ.js +92 -0
- package/dist/_browser-chunks/chunk-DAHG2CDK.js +3 -0
- package/dist/_browser-chunks/chunk-L4GU2V72.js +939 -0
- package/dist/_node-chunks/chunk-76OGQITJ.js +330 -0
- package/dist/_node-chunks/chunk-JXWXEIYP.js +17 -0
- package/dist/_node-chunks/chunk-YXFPXXZP.js +135 -0
- package/dist/builders/build-storybook/index.js +137 -28
- package/dist/builders/start-storybook/index.js +161 -28
- package/dist/client/config.js +304 -46
- package/dist/client/docs/config.js +54 -15
- package/dist/client/index.js +16 -47
- package/dist/client/preview-prod.js +3 -5
- package/dist/index.d.ts +177 -6
- package/dist/index.js +16 -47
- package/dist/node/index.d.ts +56 -0
- package/dist/node/index.js +23 -0
- package/dist/preset.js +54 -7
- package/dist/server/framework-preset-angular-cli.js +309 -18
- package/dist/server/framework-preset-angular-ivy.js +57 -5
- package/package.json +24 -70
- package/preset.js +1 -1
- package/dist/chunk-CUDJAP6K.mjs +0 -3
- package/dist/chunk-KMSSK3DZ.mjs +0 -6
- package/dist/chunk-LXSTVAFF.mjs +0 -40
- package/dist/client/config.d.ts +0 -20
- package/dist/client/config.mjs +0 -11
- package/dist/client/docs/config.d.ts +0 -6
- package/dist/client/docs/config.mjs +0 -7
- package/dist/client/index.d.ts +0 -144
- package/dist/client/index.mjs +0 -3
- package/dist/client/preview-prod.d.ts +0 -2
- package/dist/client/preview-prod.mjs +0 -3
- package/dist/index.mjs +0 -3
- package/dist/types-3b0b7107.d.ts +0 -42
- package/renderer.d.ts +0 -1
- package/renderer.js +0 -1
|
@@ -1,31 +1,164 @@
|
|
|
1
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_bs5nei9dti8 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_bs5nei9dti8 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_bs5nei9dti8 from "node:module";
|
|
2
4
|
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var architect = require('@angular-devkit/architect');
|
|
7
|
-
var path2 = require('path');
|
|
8
|
-
require('fs/promises');
|
|
9
|
-
var fs = require('fs');
|
|
10
|
-
var process = require('process');
|
|
11
|
-
var url = require('url');
|
|
12
|
-
var rxjs = require('rxjs');
|
|
13
|
-
var operators = require('rxjs/operators');
|
|
14
|
-
var nodeLogger = require('storybook/internal/node-logger');
|
|
15
|
-
var tsDedent = require('ts-dedent');
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_bs5nei9dti8.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_bs5nei9dti8.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_bs5nei9dti8.createRequire(import.meta.url);
|
|
16
8
|
|
|
17
|
-
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
errorSummary,
|
|
14
|
+
findPackageSync,
|
|
15
|
+
printErrorDetails,
|
|
16
|
+
runCompodoc
|
|
17
|
+
} from "../../_node-chunks/chunk-YXFPXXZP.js";
|
|
18
|
+
import {
|
|
19
|
+
findUpSync
|
|
20
|
+
} from "../../_node-chunks/chunk-76OGQITJ.js";
|
|
21
|
+
import {
|
|
22
|
+
__name
|
|
23
|
+
} from "../../_node-chunks/chunk-JXWXEIYP.js";
|
|
18
24
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
25
|
+
// src/builders/start-storybook/index.ts
|
|
26
|
+
import { getEnvConfig, getProjectRoot, versions } from "storybook/internal/common";
|
|
27
|
+
import { buildDevStandalone, withTelemetry } from "storybook/internal/core-server";
|
|
28
|
+
import { addToGlobalContext } from "storybook/internal/telemetry";
|
|
29
|
+
import { createBuilder, targetFromTargetString } from "@angular-devkit/architect";
|
|
30
|
+
import { Observable, from, of } from "rxjs";
|
|
31
|
+
import { map, mapTo, switchMap } from "rxjs/operators";
|
|
32
|
+
addToGlobalContext("cliVersion", versions.storybook);
|
|
33
|
+
var commandBuilder = /* @__PURE__ */ __name((options, context) => {
|
|
34
|
+
const builder = from(setup(options, context)).pipe(
|
|
35
|
+
switchMap(({ tsConfig }) => {
|
|
36
|
+
const docTSConfig = findUpSync("tsconfig.doc.json", {
|
|
37
|
+
cwd: options.configDir,
|
|
38
|
+
stopAt: getProjectRoot()
|
|
39
|
+
});
|
|
40
|
+
const runCompodoc$ = options.compodoc ? runCompodoc(
|
|
41
|
+
{
|
|
42
|
+
compodocArgs: [...options.compodocArgs, ...options.quiet ? ["--silent"] : []],
|
|
43
|
+
tsconfig: docTSConfig ?? tsConfig
|
|
44
|
+
},
|
|
45
|
+
context
|
|
46
|
+
).pipe(mapTo({ tsConfig })) : of({});
|
|
47
|
+
return runCompodoc$.pipe(mapTo({ tsConfig }));
|
|
48
|
+
}),
|
|
49
|
+
map(({ tsConfig }) => {
|
|
50
|
+
getEnvConfig(options, {
|
|
51
|
+
port: "SBCONFIG_PORT",
|
|
52
|
+
host: "SBCONFIG_HOSTNAME",
|
|
53
|
+
staticDir: "SBCONFIG_STATIC_DIR",
|
|
54
|
+
configDir: "SBCONFIG_CONFIG_DIR",
|
|
55
|
+
ci: "CI"
|
|
56
|
+
});
|
|
57
|
+
options.port = parseInt(`${options.port}`, 10);
|
|
58
|
+
const {
|
|
59
|
+
browserTarget,
|
|
60
|
+
stylePreprocessorOptions,
|
|
61
|
+
styles,
|
|
62
|
+
ci,
|
|
63
|
+
configDir,
|
|
64
|
+
docs,
|
|
65
|
+
host,
|
|
66
|
+
https,
|
|
67
|
+
port,
|
|
68
|
+
quiet,
|
|
69
|
+
enableProdMode = false,
|
|
70
|
+
smokeTest,
|
|
71
|
+
sslCa,
|
|
72
|
+
sslCert,
|
|
73
|
+
sslKey,
|
|
74
|
+
disableTelemetry,
|
|
75
|
+
assets,
|
|
76
|
+
initialPath,
|
|
77
|
+
open,
|
|
78
|
+
debugWebpack,
|
|
79
|
+
loglevel,
|
|
80
|
+
webpackStatsJson,
|
|
81
|
+
statsJson,
|
|
82
|
+
previewUrl,
|
|
83
|
+
sourceMap = false,
|
|
84
|
+
preserveSymlinks = false,
|
|
85
|
+
experimentalZoneless = false
|
|
86
|
+
} = options;
|
|
87
|
+
const standaloneOptions = {
|
|
88
|
+
packageJson: findPackageSync(__dirname),
|
|
89
|
+
ci,
|
|
90
|
+
configDir,
|
|
91
|
+
...docs ? { docs } : {},
|
|
92
|
+
host,
|
|
93
|
+
https,
|
|
94
|
+
port,
|
|
95
|
+
quiet,
|
|
96
|
+
enableProdMode,
|
|
97
|
+
smokeTest,
|
|
98
|
+
sslCa,
|
|
99
|
+
sslCert,
|
|
100
|
+
sslKey,
|
|
101
|
+
disableTelemetry,
|
|
102
|
+
angularBrowserTarget: browserTarget,
|
|
103
|
+
angularBuilderContext: context,
|
|
104
|
+
angularBuilderOptions: {
|
|
105
|
+
...stylePreprocessorOptions ? { stylePreprocessorOptions } : {},
|
|
106
|
+
...styles ? { styles } : {},
|
|
107
|
+
...assets ? { assets } : {},
|
|
108
|
+
preserveSymlinks,
|
|
109
|
+
sourceMap,
|
|
110
|
+
experimentalZoneless
|
|
111
|
+
},
|
|
112
|
+
tsConfig,
|
|
113
|
+
initialPath,
|
|
114
|
+
open,
|
|
115
|
+
debugWebpack,
|
|
116
|
+
webpackStatsJson,
|
|
117
|
+
statsJson,
|
|
118
|
+
loglevel,
|
|
119
|
+
previewUrl
|
|
120
|
+
};
|
|
121
|
+
return standaloneOptions;
|
|
122
|
+
}),
|
|
123
|
+
switchMap((standaloneOptions) => runInstance(standaloneOptions)),
|
|
124
|
+
map((port) => {
|
|
125
|
+
return { success: true, info: { port } };
|
|
126
|
+
})
|
|
127
|
+
);
|
|
128
|
+
return builder;
|
|
129
|
+
}, "commandBuilder");
|
|
130
|
+
var start_storybook_default = createBuilder(commandBuilder);
|
|
131
|
+
async function setup(options, context) {
|
|
132
|
+
let browserOptions;
|
|
133
|
+
let browserTarget;
|
|
134
|
+
if (options.browserTarget) {
|
|
135
|
+
browserTarget = targetFromTargetString(options.browserTarget);
|
|
136
|
+
browserOptions = await context.validateOptions(
|
|
137
|
+
await context.getTargetOptions(browserTarget),
|
|
138
|
+
await context.getBuilderNameForTarget(browserTarget)
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
return {
|
|
142
|
+
tsConfig: options.tsConfig ?? findUpSync("tsconfig.json", { cwd: options.configDir }) ?? browserOptions.tsConfig
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
__name(setup, "setup");
|
|
146
|
+
function runInstance(options) {
|
|
147
|
+
return new Observable((observer) => {
|
|
148
|
+
withTelemetry(
|
|
149
|
+
"dev",
|
|
150
|
+
{
|
|
151
|
+
cliOptions: options,
|
|
152
|
+
presetOptions: { ...options, corePresets: [], overridePresets: [] },
|
|
153
|
+
printError: printErrorDetails
|
|
154
|
+
},
|
|
155
|
+
() => buildDevStandalone(options)
|
|
156
|
+
).then(({ port }) => observer.next(port)).catch((error) => {
|
|
157
|
+
observer.error(errorSummary(error));
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
__name(runInstance, "runInstance");
|
|
162
|
+
export {
|
|
163
|
+
start_storybook_default as default
|
|
164
|
+
};
|
package/dist/client/config.js
CHANGED
|
@@ -1,49 +1,307 @@
|
|
|
1
|
-
|
|
1
|
+
import "../_browser-chunks/chunk-DAHG2CDK.js";
|
|
2
|
+
import {
|
|
3
|
+
__name,
|
|
4
|
+
computesTemplateFromComponent,
|
|
5
|
+
render,
|
|
6
|
+
renderToCanvas
|
|
7
|
+
} from "../_browser-chunks/chunk-L4GU2V72.js";
|
|
2
8
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
// src/client/decorateStory.ts
|
|
10
|
+
import { sanitizeStoryContextUpdate } from "storybook/preview-api";
|
|
11
|
+
function decorateStory(mainStoryFn, decorators) {
|
|
12
|
+
const returnDecorators = [cleanArgsDecorator, ...decorators].reduce(
|
|
13
|
+
(previousStoryFn, decorator) => (context) => {
|
|
14
|
+
const decoratedStory = decorator((update) => {
|
|
15
|
+
return previousStoryFn({
|
|
16
|
+
...context,
|
|
17
|
+
...sanitizeStoryContextUpdate(update)
|
|
18
|
+
});
|
|
19
|
+
}, context);
|
|
20
|
+
return decoratedStory;
|
|
21
|
+
},
|
|
22
|
+
(context) => prepareMain(mainStoryFn(context), context)
|
|
23
|
+
);
|
|
24
|
+
return returnDecorators;
|
|
25
|
+
}
|
|
26
|
+
__name(decorateStory, "decorateStory");
|
|
27
|
+
var prepareMain = /* @__PURE__ */ __name((story, context) => {
|
|
28
|
+
let { template } = story;
|
|
29
|
+
const { component } = context;
|
|
30
|
+
const userDefinedTemplate = !hasNoTemplate(template);
|
|
31
|
+
if (!userDefinedTemplate && component) {
|
|
32
|
+
template = computesTemplateFromComponent(component, story.props, "");
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
...story,
|
|
36
|
+
...template ? { template, userDefinedTemplate } : {}
|
|
37
|
+
};
|
|
38
|
+
}, "prepareMain");
|
|
39
|
+
function hasNoTemplate(template) {
|
|
40
|
+
return template === null || template === void 0;
|
|
41
|
+
}
|
|
42
|
+
__name(hasNoTemplate, "hasNoTemplate");
|
|
43
|
+
var cleanArgsDecorator = /* @__PURE__ */ __name((storyFn, context) => {
|
|
44
|
+
if (!context.argTypes || !context.args) {
|
|
45
|
+
return storyFn();
|
|
46
|
+
}
|
|
47
|
+
const argsToClean = context.args;
|
|
48
|
+
context.args = Object.entries(argsToClean).reduce((obj, [key, arg]) => {
|
|
49
|
+
const argType = context.argTypes[key];
|
|
50
|
+
if (argType?.action || argType?.control) {
|
|
51
|
+
return { ...obj, [key]: arg };
|
|
52
|
+
}
|
|
53
|
+
return obj;
|
|
54
|
+
}, {});
|
|
55
|
+
return storyFn();
|
|
56
|
+
}, "cleanArgsDecorator");
|
|
16
57
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
moduleMetadata property 'imports' contains one or more ModuleWithProviders, likely the result of a 'Module.forRoot()'-style call.
|
|
20
|
-
In Storybook 7.0 we use Angular's new 'bootstrapApplication' API to mount the component to the DOM, which accepts a list of providers to set up application-wide providers.
|
|
21
|
-
Use the 'applicationConfig' decorator from '@storybook/angular' to pass your ModuleWithProviders to the 'providers' property in combination with the importProvidersFrom helper function from '@angular/core' to extract all the necessary providers.
|
|
22
|
-
Visit https://angular.io/guide/standalone-components#configuring-dependency-injection for more information
|
|
23
|
-
`));}async init(){let analyzed=await this.analyzeMetadata(this.metadata);if(this.imports=uniqueArray([common.CommonModule,analyzed.imports]),this.providers=uniqueArray(analyzed.providers),this.applicationProviders=uniqueArray(analyzed.applicationProviders),this.declarations=uniqueArray(analyzed.declarations),this.component){let{isDeclarable,isStandalone}=_PropertyExtractor.analyzeDecorators(this.component),isDeclared=isComponentAlreadyDeclared(this.component,analyzed.declarations,this.imports);isStandalone?this.imports.push(this.component):isDeclarable&&!isDeclared&&this.declarations.push(this.component);}}};_PropertyExtractor.analyzeRestricted=async ngModule=>{if(ngModule===platformBrowser.BrowserModule)return console.warn(tsDedent.dedent`
|
|
24
|
-
Storybook Warning:
|
|
25
|
-
You have imported the "BrowserModule", which is not necessary anymore.
|
|
26
|
-
In Storybook v7.0 we are using Angular's new bootstrapApplication API to mount an Angular application to the DOM.
|
|
27
|
-
Note that the BrowserModule providers are automatically included when starting an application with bootstrapApplication()
|
|
28
|
-
Please remove the "BrowserModule" from the list of imports in your moduleMetadata definition to remove this warning.
|
|
29
|
-
`),[!0];try{let animations=await import('@angular/platform-browser/animations');if(ngModule===animations.BrowserAnimationsModule)return console.warn(tsDedent.dedent`
|
|
30
|
-
Storybook Warning:
|
|
31
|
-
You have added the "BrowserAnimationsModule" to the list of "imports" in your moduleMetadata definition of your Story.
|
|
32
|
-
In Storybook 7.0 we use Angular's new 'bootstrapApplication' API to mount the component to the DOM, which accepts a list of providers to set up application-wide providers.
|
|
33
|
-
Use the 'applicationConfig' decorator from '@storybook/angular' and add the "provideAnimations" function to the list of "providers".
|
|
34
|
-
If your Angular version does not support "provide-like" functions, use the helper function importProvidersFrom instead to set up animations. For this case, please add "importProvidersFrom(BrowserAnimationsModule)" to the list of providers of your applicationConfig definition.
|
|
35
|
-
Please visit https://angular.io/guide/standalone-components#configuring-dependency-injection for more information.
|
|
36
|
-
`),[!0,animations.provideAnimations()];if(ngModule===animations.NoopAnimationsModule)return console.warn(tsDedent.dedent`
|
|
37
|
-
Storybook Warning:
|
|
38
|
-
You have added the "NoopAnimationsModule" to the list of "imports" in your moduleMetadata definition of your Story.
|
|
39
|
-
In Storybook v7.0 we are using Angular's new bootstrapApplication API to mount an Angular application to the DOM, which accepts a list of providers to set up application-wide providers.
|
|
40
|
-
Use the 'applicationConfig' decorator from '@storybook/angular' and add the "provideNoopAnimations" function to the list of "providers".
|
|
41
|
-
If your Angular version does not support "provide-like" functions, use the helper function importProvidersFrom instead to set up noop animations and to extract all necessary providers from NoopAnimationsModule. For this case, please add "importProvidersFrom(NoopAnimationsModule)" to the list of providers of your applicationConfig definition.
|
|
42
|
-
Please visit https://angular.io/guide/standalone-components#configuring-dependency-injection for more information.
|
|
43
|
-
`),[!0,animations.provideNoopAnimations()]}catch{return [!1]}return [!1]},_PropertyExtractor.analyzeDecorators=component=>{let decorators=reflectionCapabilities3.annotations(component),isComponent=decorators.some(d=>_PropertyExtractor.isDecoratorInstanceOf(d,"Component")),isDirective=decorators.some(d=>_PropertyExtractor.isDecoratorInstanceOf(d,"Directive")),isPipe=decorators.some(d=>_PropertyExtractor.isDecoratorInstanceOf(d,"Pipe")),isDeclarable=isComponent||isDirective||isPipe,isStandalone=(isComponent||isDirective)&&[...decorators].reverse().find(d=>_PropertyExtractor.isDecoratorInstanceOf(d,"Component")||_PropertyExtractor.isDecoratorInstanceOf(d,"Directive"))?.standalone;return isStandalone===void 0&&(isStandalone=!!(core.VERSION.major&&Number(core.VERSION.major)>=19)),{isDeclarable,isStandalone}},_PropertyExtractor.isDecoratorInstanceOf=(decorator,name)=>{let factory;switch(name){case"Component":factory=core.Component;break;case"Directive":factory=core.Directive;break;case"Pipe":factory=core.Pipe;break;case"Injectable":factory=core.Injectable;break;case"Input":factory=core.Input;break;case"Output":factory=core.Output;break;default:throw new Error(`Unknown decorator type: ${name}`)}return decorator instanceof factory||decorator.ngMetadataName===name};var PropertyExtractor=_PropertyExtractor;var getNonInputsOutputsProps=(ngComponentInputsOutputs,props={})=>{let inputs=ngComponentInputsOutputs.inputs.filter(i=>i.templateName in props).map(i=>i.templateName),outputs=ngComponentInputsOutputs.outputs.filter(o=>o.templateName in props).map(o=>o.templateName);return Object.keys(props).filter(k=>![...inputs,...outputs].includes(k))},createStorybookWrapperComponent=({selector,template,storyComponent,styles,moduleMetadata,initialProps,analyzedMetadata})=>{let viewChildSelector=storyComponent??"__storybook-noop",{imports,declarations,providers}=analyzedMetadata,StorybookComponentModule=class{};StorybookComponentModule=__decorateClass([core.NgModule({declarations,imports,exports:[...declarations,...imports]})],StorybookComponentModule),PropertyExtractor.warnImportsModuleWithProviders(analyzedMetadata);let StorybookWrapperComponent=class{constructor(storyProps$,changeDetectorRef){this.storyProps$=storyProps$;this.changeDetectorRef=changeDetectorRef;this.storyComponent=storyComponent??"";}ngOnInit(){this.storyWrapperPropsSubscription=this.storyProps$.subscribe((storyProps={})=>{Object.assign(this,storyProps),this.changeDetectorRef.detectChanges(),this.changeDetectorRef.markForCheck();});}ngAfterViewInit(){if(this.storyComponentElementRef){let ngComponentInputsOutputs=getComponentInputsOutputs(storyComponent);getNonInputsOutputsProps(ngComponentInputsOutputs,initialProps).forEach(p=>{this.storyComponentElementRef[p]=initialProps[p];}),this.storyComponentViewContainerRef.injector.get(core.ChangeDetectorRef).markForCheck(),this.changeDetectorRef.detectChanges(),this.storyComponentPropsSubscription=this.storyProps$.pipe(operators.skip(1),operators.map(props=>getNonInputsOutputsProps(ngComponentInputsOutputs,props).reduce((acc,p)=>({...acc,[p]:props[p]}),{}))).subscribe(props=>{Object.assign(this.storyComponentElementRef,props),this.storyComponentViewContainerRef.injector.get(core.ChangeDetectorRef).markForCheck(),this.changeDetectorRef.detectChanges();});}}ngOnDestroy(){this.storyComponentPropsSubscription!=null&&this.storyComponentPropsSubscription.unsubscribe(),this.storyWrapperPropsSubscription!=null&&this.storyWrapperPropsSubscription.unsubscribe();}};return __decorateClass([core.ViewChild(viewChildSelector,{static:!0})],StorybookWrapperComponent.prototype,"storyComponentElementRef",2),__decorateClass([core.ViewChild(viewChildSelector,{read:core.ViewContainerRef,static:!0})],StorybookWrapperComponent.prototype,"storyComponentViewContainerRef",2),StorybookWrapperComponent=__decorateClass([core.Component({selector,template,standalone:!0,imports:[StorybookComponentModule],providers,styles,schemas:moduleMetadata.schemas}),__decorateParam(0,core.Inject(STORY_PROPS)),__decorateParam(1,core.Inject(core.ChangeDetectorRef))],StorybookWrapperComponent),StorybookWrapperComponent};var getApplication=({storyFnAngular,component,targetSelector,analyzedMetadata})=>{let{props,styles,moduleMetadata={}}=storyFnAngular,{template}=storyFnAngular;return !!hasNoTemplate(template)&&component&&(template=computesTemplateFromComponent(component,props,"")),createStorybookWrapperComponent({moduleMetadata,selector:targetSelector,template,storyComponent:component,styles,initialProps:props,analyzedMetadata})};function hasNoTemplate(template){return template==null}var queue=[],isProcessing=!1,resetCompiledComponents=async()=>{try{let{\u0275resetCompiledComponents}=await import('@angular/core');\u0275resetCompiledComponents();}catch{}},queueBootstrapping=fn=>new Promise((resolve,reject)=>{queue.push(()=>fn().then(resolve).catch(reject)),isProcessing||processQueue();}),processQueue=async()=>{for(isProcessing=!0;queue.length>0;){let bootstrappingFn=queue.shift();bootstrappingFn&&(await bootstrappingFn(),await resetCompiledComponents());}isProcessing=!1;};var getProvideZonelessChangeDetectionFn=async()=>{let angularCore=await import('@angular/core');return "provideExperimentalZonelessChangeDetection"in angularCore?angularCore.provideExperimentalZonelessChangeDetection:"provideZonelessChangeDetection"in angularCore?angularCore.provideZonelessChangeDetection:null};var applicationRefs=new Map,STORY_UID_ATTRIBUTE="data-sb-story-uid",AbstractRenderer=class{constructor(){this.previousStoryRenderInfo=new Map;}static resetApplications(domNode){applicationRefs.forEach((appRef,appDOMNode)=>{!appRef.destroyed&&(!domNode||appDOMNode===domNode)&&appRef.destroy();});}async render({storyFnAngular,forced,component,targetDOMNode}){let targetSelector=this.generateTargetSelectorFromStoryId(targetDOMNode.id),newStoryProps$=new rxjs.BehaviorSubject(storyFnAngular.props);if(!this.fullRendererRequired({targetDOMNode,storyFnAngular,moduleMetadata:{...storyFnAngular.moduleMetadata},forced})){this.storyProps$.next(storyFnAngular.props);return}await this.beforeFullRender(targetDOMNode),this.storyProps$&&this.storyProps$.complete(),this.storyProps$=newStoryProps$,this.initAngularRootElement(targetDOMNode,targetSelector);let analyzedMetadata=new PropertyExtractor(storyFnAngular.moduleMetadata,component);await analyzedMetadata.init();let storyUid=this.generateStoryUIdFromRawStoryUid(targetDOMNode.getAttribute(STORY_UID_ATTRIBUTE)),componentSelector=storyUid!==null?`${targetSelector}[${storyUid}]`:targetSelector;storyUid!==null&&targetDOMNode.querySelector(targetSelector).toggleAttribute(storyUid,!0);let application=getApplication({storyFnAngular,component,targetSelector:componentSelector,analyzedMetadata}),providers=[storyPropsProvider(newStoryProps$),...analyzedMetadata.applicationProviders,...storyFnAngular.applicationConfig?.providers??[]];if(STORYBOOK_ANGULAR_OPTIONS?.experimentalZoneless){let provideZonelessChangeDetectionFn=await getProvideZonelessChangeDetectionFn();if(provideZonelessChangeDetectionFn)providers.unshift(provideZonelessChangeDetectionFn());else throw new Error("Zoneless change detection requires Angular 18 or higher")}let applicationRef=await queueBootstrapping(()=>platformBrowser.bootstrapApplication(application,{...storyFnAngular.applicationConfig,providers}));applicationRefs.set(targetDOMNode,applicationRef);}generateTargetSelectorFromStoryId(id){let invalidHtmlTag=/[^A-Za-z0-9-]/g;return invalidHtmlTag.test(id)?`sb-${id.replace(invalidHtmlTag,"")}-component`:id}generateStoryUIdFromRawStoryUid(rawStoryUid){if(rawStoryUid===null)return rawStoryUid;let accentCharacters=/[\u0300-\u036f]/g;return rawStoryUid.normalize("NFD").replace(accentCharacters,"")}initAngularRootElement(targetDOMNode,targetSelector){targetDOMNode.innerHTML="",targetDOMNode.appendChild(document.createElement(targetSelector));}fullRendererRequired({targetDOMNode,storyFnAngular,moduleMetadata,forced}){let previousStoryRenderInfo=this.previousStoryRenderInfo.get(targetDOMNode),currentStoryRender={storyFnAngular,moduleMetadataSnapshot:telejson.stringify(moduleMetadata,{maxDepth:50})};return this.previousStoryRenderInfo.set(targetDOMNode,currentStoryRender),!forced||!this.storyProps$||!!storyFnAngular?.template&&previousStoryRenderInfo?.storyFnAngular?.template!==storyFnAngular.template?!0:currentStoryRender.moduleMetadataSnapshot!==previousStoryRenderInfo?.moduleMetadataSnapshot}};var CanvasRenderer=class _CanvasRenderer extends AbstractRenderer{async render(options){await super.render(options);}async beforeFullRender(){_CanvasRenderer.resetApplications();}};var storyCounts=new Map,getNextStoryUID=storyId=>{storyCounts.has(storyId)||storyCounts.set(storyId,-1);let count=storyCounts.get(storyId)+1;return storyCounts.set(storyId,count),`${storyId}-${count}`};var DocsRenderer=class _DocsRenderer extends AbstractRenderer{async render(options){let channel=previewApi.addons.getChannel();channel.once(coreEvents.STORY_CHANGED,async()=>{await _DocsRenderer.resetApplications();}),channel.once(coreEvents.DOCS_RENDERED,async()=>{await _DocsRenderer.resetApplications();}),await super.render({...options,forced:!1});}async beforeFullRender(domNode){_DocsRenderer.resetApplications(domNode);}initAngularRootElement(targetDOMNode,targetSelector){super.initAngularRootElement(targetDOMNode,targetSelector),targetDOMNode.setAttribute(STORY_UID_ATTRIBUTE,getNextStoryUID(targetDOMNode.id));}};var RendererFactory=class{constructor(){this.rendererMap=new Map;}async getRendererInstance(targetDOMNode){let targetId=targetDOMNode.id;if(targetDOMNode===null)return null;let renderType=getRenderType(targetDOMNode);return this.lastRenderType&&this.lastRenderType!==renderType&&(await AbstractRenderer.resetApplications(),clearRootHTMLElement(renderType),this.rendererMap.clear()),this.rendererMap.has(targetId)||this.rendererMap.set(targetId,this.buildRenderer(renderType)),this.lastRenderType=renderType,this.rendererMap.get(targetId)}buildRenderer(renderType){return renderType==="docs"?new DocsRenderer:new CanvasRenderer}},getRenderType=targetDOMNode=>targetDOMNode.id==="storybook-root"?"canvas":"docs";function clearRootHTMLElement(renderType){switch(renderType){case"canvas":global.document.getElementById("storybook-docs").innerHTML="";break;case"docs":global.document.getElementById("storybook-root").innerHTML="";break;}}var rendererFactory=new RendererFactory,render=props=>({props});async function renderToCanvas({storyFn,showMain,forceRemount,storyContext:{component}},element){showMain(),await(await rendererFactory.getRendererInstance(element)).render({storyFnAngular:storyFn(),component,forced:!forceRemount,targetDOMNode:element});}function decorateStory(mainStoryFn,decorators){return [cleanArgsDecorator,...decorators].reduce((previousStoryFn,decorator)=>context=>decorator(update=>previousStoryFn({...context,...previewApi.sanitizeStoryContextUpdate(update)}),context),context=>prepareMain(mainStoryFn(context),context))}var prepareMain=(story,context)=>{let{template}=story,{component}=context,userDefinedTemplate=!hasNoTemplate2(template);return !userDefinedTemplate&&component&&(template=computesTemplateFromComponent(component,story.props,"")),{...story,...template?{template,userDefinedTemplate}:{}}};function hasNoTemplate2(template){return template==null}var cleanArgsDecorator=(storyFn,context)=>{if(!context.argTypes||!context.args)return storyFn();let argsToClean=context.args;return context.args=Object.entries(argsToClean).reduce((obj,[key,arg])=>{let argType=context.argTypes[key];return argType?.action||argType?.control?{...obj,[key]:arg}:obj},{}),storyFn()};var{FEATURES}=global$1.global,isMethod=methodOrProp=>methodOrProp.args!==void 0;var getCompodocJson=()=>global$1.global.__STORYBOOK_COMPODOC_JSON__,checkValidComponentOrDirective=component=>{if(!component.name)throw new Error(`Invalid component ${JSON.stringify(component)}`)},checkValidCompodocJson=compodocJson=>{if(!compodocJson||!compodocJson.components)throw new Error("Invalid compodoc JSON")},hasDecorator=(item,decoratorName)=>item.decorators&&item.decorators.find(x=>x.name===decoratorName),mapPropertyToSection=item=>hasDecorator(item,"ViewChild")?"view child":hasDecorator(item,"ViewChildren")?"view children":hasDecorator(item,"ContentChild")?"content child":hasDecorator(item,"ContentChildren")?"content children":"properties",mapItemToSection=(key,item)=>{switch(key){case"methods":case"methodsClass":return "methods";case"inputsClass":return "inputs";case"outputsClass":return "outputs";case"properties":case"propertiesClass":if(isMethod(item))throw new Error("Cannot be of type Method if key === 'propertiesClass'");return mapPropertyToSection(item);default:throw new Error(`Unknown key: ${key}`)}},findComponentByName=(name,compodocJson)=>compodocJson.components.find(c=>c.name===name)||compodocJson.directives.find(c=>c.name===name)||compodocJson.pipes.find(c=>c.name===name)||compodocJson.injectables.find(c=>c.name===name)||compodocJson.classes.find(c=>c.name===name),getComponentData=component=>{if(!component)return null;checkValidComponentOrDirective(component);let compodocJson=getCompodocJson();if(!compodocJson)return null;checkValidCompodocJson(compodocJson);let{name}=component,metadata=findComponentByName(name,compodocJson);return metadata||clientLogger.logger.warn(`Component not found in compodoc JSON: '${name}'`),metadata},displaySignature=item=>`(${item.args.map(arg=>`${arg.name}${arg.optional?"?":""}: ${arg.type}`).join(", ")}) => ${item.returnType}`,extractTypeFromValue=defaultValue=>{let valueType=typeof defaultValue;return defaultValue||valueType==="number"||valueType==="boolean"||valueType==="string"?valueType:null},extractEnumValues=compodocType=>{let enumType=getCompodocJson()?.miscellaneous?.enumerations?.find(x=>x.name===compodocType);if(enumType?.childs.every(x=>x.value))return enumType.childs.map(x=>x.value);if(typeof compodocType!="string"||compodocType.indexOf("|")===-1)return null;try{return compodocType.split("|").map(value=>JSON.parse(value))}catch{return null}},extractType=(property,defaultValue)=>{let compodocType=property.type||extractTypeFromValue(defaultValue);switch(compodocType){case"string":case"boolean":case"number":return {name:compodocType};case void 0:case null:return {name:"other",value:"void"};default:{let resolvedType=resolveTypealias(compodocType),enumValues=extractEnumValues(resolvedType);return enumValues?{name:"enum",value:enumValues}:{name:"other",value:"empty-enum"}}}},castDefaultValue=(property,defaultValue)=>{let compodocType=property.type;if(["boolean","number","string","EventEmitter"].includes(compodocType))switch(compodocType){case"boolean":return defaultValue==="true";case"number":return Number(defaultValue);case"EventEmitter":return;default:return defaultValue}else switch(defaultValue){case"true":return !0;case"false":return !1;case"null":return null;case"undefined":return;default:return defaultValue}},extractDefaultValueFromComments=(property,value)=>{let commentValue=value;return property.jsdoctags.forEach(tag=>{["default","defaultvalue"].includes(tag.tagName.escapedText)&&(commentValue=new global$1.global.DOMParser().parseFromString(tag.comment,"text/html").body.textContent);}),commentValue},extractDefaultValue=property=>{try{let value=property.defaultValue?.replace(/^'(.*)'$/,"$1");return value=castDefaultValue(property,value),value==null&&property.jsdoctags?.length>0&&(value=extractDefaultValueFromComments(property,value)),value}catch{clientLogger.logger.debug(`Error extracting ${property.name}: ${property.defaultValue}`);return}},resolveTypealias=compodocType=>{let typeAlias=getCompodocJson()?.miscellaneous?.typealiases?.find(x=>x.name===compodocType);return typeAlias?resolveTypealias(typeAlias.rawtype):compodocType},extractArgTypesFromData=componentData=>{let sectionToItems={},componentClasses=FEATURES.angularFilterNonInputControls?["inputsClass"]:["propertiesClass","methodsClass","inputsClass","outputsClass"];(["component","directive"].includes(componentData.type)?componentClasses:["properties","methods"]).forEach(key=>{(componentData[key]||[]).forEach(item=>{let section=mapItemToSection(key,item),defaultValue=isMethod(item)?void 0:extractDefaultValue(item),type=isMethod(item)||section!=="inputs"&§ion!=="properties"?{name:"other",value:"void"}:extractType(item,defaultValue),action=section==="outputs"?{action:item.name}:{},argType={name:item.name,description:item.rawdescription||item.description,type,...action,table:{category:section,type:{summary:isMethod(item)?displaySignature(item):item.type,required:isMethod(item)?!1:!item.optional},defaultValue:{summary:defaultValue}}};sectionToItems[section]||(sectionToItems[section]=[]),sectionToItems[section].push(argType);});});let SECTIONS=["properties","inputs","outputs","methods","view child","view children","content child","content children"],argTypes={};return SECTIONS.forEach(section=>{let items=sectionToItems[section];items&&items.forEach(argType=>{argTypes[argType.name]=argType;});}),argTypes},extractArgTypes=component=>{let componentData=getComponentData(component);return componentData&&extractArgTypesFromData(componentData)},extractComponentDescription=component=>{let componentData=getComponentData(component);return componentData&&(componentData.rawdescription||componentData.description)};var parameters={renderer:"angular",docs:{story:{inline:!0},extractArgTypes,extractComponentDescription}},argTypesEnhancers=[docsTools.enhanceArgTypes];
|
|
58
|
+
// src/client/config.ts
|
|
59
|
+
import { enhanceArgTypes } from "storybook/internal/docs-tools";
|
|
44
60
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
61
|
+
// src/client/compodoc.ts
|
|
62
|
+
import { logger } from "storybook/internal/client-logger";
|
|
63
|
+
import { global } from "@storybook/global";
|
|
64
|
+
var { FEATURES } = global;
|
|
65
|
+
var isMethod = /* @__PURE__ */ __name((methodOrProp) => {
|
|
66
|
+
return methodOrProp.args !== void 0;
|
|
67
|
+
}, "isMethod");
|
|
68
|
+
var getCompodocJson = /* @__PURE__ */ __name(() => global.__STORYBOOK_COMPODOC_JSON__, "getCompodocJson");
|
|
69
|
+
var checkValidComponentOrDirective = /* @__PURE__ */ __name((component) => {
|
|
70
|
+
if (!component.name) {
|
|
71
|
+
throw new Error(`Invalid component ${JSON.stringify(component)}`);
|
|
72
|
+
}
|
|
73
|
+
}, "checkValidComponentOrDirective");
|
|
74
|
+
var checkValidCompodocJson = /* @__PURE__ */ __name((compodocJson) => {
|
|
75
|
+
if (!compodocJson || !compodocJson.components) {
|
|
76
|
+
throw new Error("Invalid compodoc JSON");
|
|
77
|
+
}
|
|
78
|
+
}, "checkValidCompodocJson");
|
|
79
|
+
var hasDecorator = /* @__PURE__ */ __name((item, decoratorName) => item.decorators && item.decorators.find((x) => x.name === decoratorName), "hasDecorator");
|
|
80
|
+
var mapPropertyToSection = /* @__PURE__ */ __name((item) => {
|
|
81
|
+
if (hasDecorator(item, "ViewChild")) {
|
|
82
|
+
return "view child";
|
|
83
|
+
}
|
|
84
|
+
if (hasDecorator(item, "ViewChildren")) {
|
|
85
|
+
return "view children";
|
|
86
|
+
}
|
|
87
|
+
if (hasDecorator(item, "ContentChild")) {
|
|
88
|
+
return "content child";
|
|
89
|
+
}
|
|
90
|
+
if (hasDecorator(item, "ContentChildren")) {
|
|
91
|
+
return "content children";
|
|
92
|
+
}
|
|
93
|
+
return "properties";
|
|
94
|
+
}, "mapPropertyToSection");
|
|
95
|
+
var mapItemToSection = /* @__PURE__ */ __name((key, item) => {
|
|
96
|
+
switch (key) {
|
|
97
|
+
case "methods":
|
|
98
|
+
case "methodsClass":
|
|
99
|
+
return "methods";
|
|
100
|
+
case "inputsClass":
|
|
101
|
+
return "inputs";
|
|
102
|
+
case "outputsClass":
|
|
103
|
+
return "outputs";
|
|
104
|
+
case "properties":
|
|
105
|
+
case "propertiesClass":
|
|
106
|
+
if (isMethod(item)) {
|
|
107
|
+
throw new Error("Cannot be of type Method if key === 'propertiesClass'");
|
|
108
|
+
}
|
|
109
|
+
return mapPropertyToSection(item);
|
|
110
|
+
default:
|
|
111
|
+
throw new Error(`Unknown key: ${key}`);
|
|
112
|
+
}
|
|
113
|
+
}, "mapItemToSection");
|
|
114
|
+
var findComponentByName = /* @__PURE__ */ __name((name, compodocJson) => compodocJson.components.find((c) => c.name === name) || compodocJson.directives.find((c) => c.name === name) || compodocJson.pipes.find((c) => c.name === name) || compodocJson.injectables.find((c) => c.name === name) || compodocJson.classes.find((c) => c.name === name), "findComponentByName");
|
|
115
|
+
var getComponentData = /* @__PURE__ */ __name((component) => {
|
|
116
|
+
if (!component) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
checkValidComponentOrDirective(component);
|
|
120
|
+
const compodocJson = getCompodocJson();
|
|
121
|
+
if (!compodocJson) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
checkValidCompodocJson(compodocJson);
|
|
125
|
+
const { name } = component;
|
|
126
|
+
const metadata = findComponentByName(name, compodocJson);
|
|
127
|
+
if (!metadata) {
|
|
128
|
+
logger.warn(`Component not found in compodoc JSON: '${name}'`);
|
|
129
|
+
}
|
|
130
|
+
return metadata;
|
|
131
|
+
}, "getComponentData");
|
|
132
|
+
var displaySignature = /* @__PURE__ */ __name((item) => {
|
|
133
|
+
const args = item.args.map(
|
|
134
|
+
(arg) => `${arg.name}${arg.optional ? "?" : ""}: ${arg.type}`
|
|
135
|
+
);
|
|
136
|
+
return `(${args.join(", ")}) => ${item.returnType}`;
|
|
137
|
+
}, "displaySignature");
|
|
138
|
+
var extractTypeFromValue = /* @__PURE__ */ __name((defaultValue) => {
|
|
139
|
+
const valueType = typeof defaultValue;
|
|
140
|
+
return defaultValue || valueType === "number" || valueType === "boolean" || valueType === "string" ? valueType : null;
|
|
141
|
+
}, "extractTypeFromValue");
|
|
142
|
+
var extractEnumValues = /* @__PURE__ */ __name((compodocType) => {
|
|
143
|
+
const compodocJson = getCompodocJson();
|
|
144
|
+
const enumType = compodocJson?.miscellaneous?.enumerations?.find((x) => x.name === compodocType);
|
|
145
|
+
if (enumType?.childs.every((x) => x.value)) {
|
|
146
|
+
return enumType.childs.map((x) => x.value);
|
|
147
|
+
}
|
|
148
|
+
if (typeof compodocType !== "string" || compodocType.indexOf("|") === -1) {
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
try {
|
|
152
|
+
return compodocType.split("|").map((value) => JSON.parse(value));
|
|
153
|
+
} catch (e) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
}, "extractEnumValues");
|
|
157
|
+
var extractType = /* @__PURE__ */ __name((property, defaultValue) => {
|
|
158
|
+
const compodocType = property.type || extractTypeFromValue(defaultValue);
|
|
159
|
+
switch (compodocType) {
|
|
160
|
+
case "string":
|
|
161
|
+
case "boolean":
|
|
162
|
+
case "number":
|
|
163
|
+
return { name: compodocType };
|
|
164
|
+
case void 0:
|
|
165
|
+
case null:
|
|
166
|
+
return { name: "other", value: "void" };
|
|
167
|
+
default: {
|
|
168
|
+
const resolvedType = resolveTypealias(compodocType);
|
|
169
|
+
const enumValues = extractEnumValues(resolvedType);
|
|
170
|
+
return enumValues ? { name: "enum", value: enumValues } : { name: "other", value: "empty-enum" };
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}, "extractType");
|
|
174
|
+
var castDefaultValue = /* @__PURE__ */ __name((property, defaultValue) => {
|
|
175
|
+
const compodocType = property.type;
|
|
176
|
+
if (["boolean", "number", "string", "EventEmitter"].includes(compodocType)) {
|
|
177
|
+
switch (compodocType) {
|
|
178
|
+
case "boolean":
|
|
179
|
+
return defaultValue === "true";
|
|
180
|
+
case "number":
|
|
181
|
+
return Number(defaultValue);
|
|
182
|
+
case "EventEmitter":
|
|
183
|
+
return void 0;
|
|
184
|
+
default:
|
|
185
|
+
return defaultValue;
|
|
186
|
+
}
|
|
187
|
+
} else {
|
|
188
|
+
switch (defaultValue) {
|
|
189
|
+
case "true":
|
|
190
|
+
return true;
|
|
191
|
+
case "false":
|
|
192
|
+
return false;
|
|
193
|
+
case "null":
|
|
194
|
+
return null;
|
|
195
|
+
case "undefined":
|
|
196
|
+
return void 0;
|
|
197
|
+
default:
|
|
198
|
+
return defaultValue;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}, "castDefaultValue");
|
|
202
|
+
var extractDefaultValueFromComments = /* @__PURE__ */ __name((property, value) => {
|
|
203
|
+
let commentValue = value;
|
|
204
|
+
property.jsdoctags.forEach((tag) => {
|
|
205
|
+
if (["default", "defaultvalue"].includes(tag.tagName.escapedText)) {
|
|
206
|
+
const dom = new global.DOMParser().parseFromString(tag.comment, "text/html");
|
|
207
|
+
commentValue = dom.body.textContent;
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
return commentValue;
|
|
211
|
+
}, "extractDefaultValueFromComments");
|
|
212
|
+
var extractDefaultValue = /* @__PURE__ */ __name((property) => {
|
|
213
|
+
try {
|
|
214
|
+
let value = property.defaultValue?.replace(/^'(.*)'$/, "$1");
|
|
215
|
+
value = castDefaultValue(property, value);
|
|
216
|
+
if (value == null && property.jsdoctags?.length > 0) {
|
|
217
|
+
value = extractDefaultValueFromComments(property, value);
|
|
218
|
+
}
|
|
219
|
+
return value;
|
|
220
|
+
} catch (err) {
|
|
221
|
+
logger.debug(`Error extracting ${property.name}: ${property.defaultValue}`);
|
|
222
|
+
return void 0;
|
|
223
|
+
}
|
|
224
|
+
}, "extractDefaultValue");
|
|
225
|
+
var resolveTypealias = /* @__PURE__ */ __name((compodocType) => {
|
|
226
|
+
const compodocJson = getCompodocJson();
|
|
227
|
+
const typeAlias = compodocJson?.miscellaneous?.typealiases?.find((x) => x.name === compodocType);
|
|
228
|
+
return typeAlias ? resolveTypealias(typeAlias.rawtype) : compodocType;
|
|
229
|
+
}, "resolveTypealias");
|
|
230
|
+
var extractArgTypesFromData = /* @__PURE__ */ __name((componentData) => {
|
|
231
|
+
const sectionToItems = {};
|
|
232
|
+
const componentClasses = FEATURES.angularFilterNonInputControls ? ["inputsClass"] : ["propertiesClass", "methodsClass", "inputsClass", "outputsClass"];
|
|
233
|
+
const compodocClasses = ["component", "directive"].includes(componentData.type) ? componentClasses : ["properties", "methods"];
|
|
234
|
+
compodocClasses.forEach((key) => {
|
|
235
|
+
const data = componentData[key] || [];
|
|
236
|
+
data.forEach((item) => {
|
|
237
|
+
const section = mapItemToSection(key, item);
|
|
238
|
+
const defaultValue = isMethod(item) ? void 0 : extractDefaultValue(item);
|
|
239
|
+
const type = isMethod(item) || section !== "inputs" && section !== "properties" ? { name: "other", value: "void" } : extractType(item, defaultValue);
|
|
240
|
+
const action = section === "outputs" ? { action: item.name } : {};
|
|
241
|
+
const argType = {
|
|
242
|
+
name: item.name,
|
|
243
|
+
description: item.rawdescription || item.description,
|
|
244
|
+
type,
|
|
245
|
+
...action,
|
|
246
|
+
table: {
|
|
247
|
+
category: section,
|
|
248
|
+
type: {
|
|
249
|
+
summary: isMethod(item) ? displaySignature(item) : item.type,
|
|
250
|
+
required: isMethod(item) ? false : !item.optional
|
|
251
|
+
},
|
|
252
|
+
defaultValue: { summary: defaultValue }
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
if (!sectionToItems[section]) {
|
|
256
|
+
sectionToItems[section] = [];
|
|
257
|
+
}
|
|
258
|
+
sectionToItems[section].push(argType);
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
const SECTIONS = [
|
|
262
|
+
"properties",
|
|
263
|
+
"inputs",
|
|
264
|
+
"outputs",
|
|
265
|
+
"methods",
|
|
266
|
+
"view child",
|
|
267
|
+
"view children",
|
|
268
|
+
"content child",
|
|
269
|
+
"content children"
|
|
270
|
+
];
|
|
271
|
+
const argTypes = {};
|
|
272
|
+
SECTIONS.forEach((section) => {
|
|
273
|
+
const items = sectionToItems[section];
|
|
274
|
+
if (items) {
|
|
275
|
+
items.forEach((argType) => {
|
|
276
|
+
argTypes[argType.name] = argType;
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
return argTypes;
|
|
281
|
+
}, "extractArgTypesFromData");
|
|
282
|
+
var extractArgTypes = /* @__PURE__ */ __name((component) => {
|
|
283
|
+
const componentData = getComponentData(component);
|
|
284
|
+
return componentData && extractArgTypesFromData(componentData);
|
|
285
|
+
}, "extractArgTypes");
|
|
286
|
+
var extractComponentDescription = /* @__PURE__ */ __name((component) => {
|
|
287
|
+
const componentData = getComponentData(component);
|
|
288
|
+
return componentData && (componentData.rawdescription || componentData.description);
|
|
289
|
+
}, "extractComponentDescription");
|
|
290
|
+
|
|
291
|
+
// src/client/config.ts
|
|
292
|
+
var parameters = {
|
|
293
|
+
renderer: "angular",
|
|
294
|
+
docs: {
|
|
295
|
+
story: { inline: true },
|
|
296
|
+
extractArgTypes,
|
|
297
|
+
extractComponentDescription
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
var argTypesEnhancers = [enhanceArgTypes];
|
|
301
|
+
export {
|
|
302
|
+
decorateStory as applyDecorators,
|
|
303
|
+
argTypesEnhancers,
|
|
304
|
+
parameters,
|
|
305
|
+
render,
|
|
306
|
+
renderToCanvas
|
|
307
|
+
};
|