@storybook/angular 10.1.0-alpha.10 → 10.1.0-alpha.12
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/_browser-chunks/chunk-6CHBWP5J.js +711 -0
- package/dist/_browser-chunks/{chunk-CV6HSYTZ.js → chunk-T32Z4CGF.js} +13 -28
- package/dist/_node-chunks/chunk-6VHHYZRT.js +62 -0
- package/dist/_node-chunks/chunk-CI264AI2.js +43 -0
- package/dist/builders/build-storybook/index.js +81 -101
- package/dist/builders/start-storybook/index.js +102 -123
- package/dist/client/config.js +84 -179
- package/dist/client/docs/config.js +15 -33
- package/dist/client/index.js +2 -2
- package/dist/index.js +2 -2
- package/dist/node/index.js +6 -10
- package/dist/preset.js +19 -29
- package/dist/server/framework-preset-angular-cli.js +84 -155
- package/dist/server/framework-preset-angular-ivy.js +16 -25
- package/package.json +5 -5
- package/dist/_browser-chunks/chunk-L4GU2V72.js +0 -939
- package/dist/_node-chunks/chunk-4RJNAYZ2.js +0 -58
- package/dist/_node-chunks/chunk-CE4PZTEJ.js +0 -17
- package/dist/_node-chunks/chunk-QC5VOLQ4.js +0 -93
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_qv1b0zi7im from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_qv1b0zi7im from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_qv1b0zi7im from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_qv1b0zi7im.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_qv1b0zi7im.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_qv1b0zi7im.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -14,13 +14,10 @@ import {
|
|
|
14
14
|
printErrorDetails,
|
|
15
15
|
runCompodoc,
|
|
16
16
|
up as up2
|
|
17
|
-
} from "../../_node-chunks/chunk-
|
|
17
|
+
} from "../../_node-chunks/chunk-6VHHYZRT.js";
|
|
18
18
|
import {
|
|
19
19
|
up
|
|
20
|
-
} from "../../_node-chunks/chunk-
|
|
21
|
-
import {
|
|
22
|
-
__name
|
|
23
|
-
} from "../../_node-chunks/chunk-CE4PZTEJ.js";
|
|
20
|
+
} from "../../_node-chunks/chunk-CI264AI2.js";
|
|
24
21
|
|
|
25
22
|
// src/builders/start-storybook/index.ts
|
|
26
23
|
import { readFileSync } from "node:fs";
|
|
@@ -32,121 +29,104 @@ import { Observable, from, of } from "rxjs";
|
|
|
32
29
|
import { map, mapTo, switchMap } from "rxjs/operators";
|
|
33
30
|
import { VERSION } from "@angular/core";
|
|
34
31
|
addToGlobalContext("cliVersion", versions.storybook);
|
|
35
|
-
var commandBuilder =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
};
|
|
125
|
-
return standaloneOptions;
|
|
126
|
-
}),
|
|
127
|
-
switchMap((standaloneOptions) => runInstance(standaloneOptions)),
|
|
128
|
-
map((port) => {
|
|
129
|
-
return { success: true, info: { port } };
|
|
130
|
-
})
|
|
131
|
-
);
|
|
132
|
-
return builder;
|
|
133
|
-
}, "commandBuilder");
|
|
134
|
-
var start_storybook_default = createBuilder(commandBuilder);
|
|
32
|
+
var commandBuilder = (options, context) => from(setup(options, context)).pipe(
|
|
33
|
+
switchMap(({ tsConfig }) => {
|
|
34
|
+
let docTSConfig = up("tsconfig.doc.json", {
|
|
35
|
+
cwd: options.configDir,
|
|
36
|
+
last: getProjectRoot()
|
|
37
|
+
});
|
|
38
|
+
return (options.compodoc ? runCompodoc(
|
|
39
|
+
{
|
|
40
|
+
compodocArgs: [...options.compodocArgs, ...options.quiet ? ["--silent"] : []],
|
|
41
|
+
tsconfig: docTSConfig ?? tsConfig
|
|
42
|
+
},
|
|
43
|
+
context
|
|
44
|
+
).pipe(mapTo({ tsConfig })) : of({})).pipe(mapTo({ tsConfig }));
|
|
45
|
+
}),
|
|
46
|
+
map(({ tsConfig }) => {
|
|
47
|
+
getEnvConfig(options, {
|
|
48
|
+
port: "SBCONFIG_PORT",
|
|
49
|
+
host: "SBCONFIG_HOSTNAME",
|
|
50
|
+
staticDir: "SBCONFIG_STATIC_DIR",
|
|
51
|
+
configDir: "SBCONFIG_CONFIG_DIR",
|
|
52
|
+
ci: "CI"
|
|
53
|
+
}), options.port = parseInt(`${options.port}`, 10);
|
|
54
|
+
let {
|
|
55
|
+
browserTarget,
|
|
56
|
+
stylePreprocessorOptions,
|
|
57
|
+
styles,
|
|
58
|
+
ci,
|
|
59
|
+
configDir,
|
|
60
|
+
docs,
|
|
61
|
+
host,
|
|
62
|
+
https,
|
|
63
|
+
port,
|
|
64
|
+
quiet,
|
|
65
|
+
enableProdMode = !1,
|
|
66
|
+
smokeTest,
|
|
67
|
+
sslCa,
|
|
68
|
+
sslCert,
|
|
69
|
+
sslKey,
|
|
70
|
+
disableTelemetry,
|
|
71
|
+
assets,
|
|
72
|
+
initialPath,
|
|
73
|
+
open,
|
|
74
|
+
debugWebpack,
|
|
75
|
+
loglevel,
|
|
76
|
+
webpackStatsJson,
|
|
77
|
+
statsJson,
|
|
78
|
+
previewUrl,
|
|
79
|
+
sourceMap = !1,
|
|
80
|
+
preserveSymlinks = !1,
|
|
81
|
+
experimentalZoneless = !!(VERSION.major && Number(VERSION.major) >= 21)
|
|
82
|
+
} = options, packageJsonPath = up2({ cwd: __dirname });
|
|
83
|
+
return {
|
|
84
|
+
packageJson: packageJsonPath != null ? JSON.parse(readFileSync(packageJsonPath, "utf8")) : null,
|
|
85
|
+
ci,
|
|
86
|
+
configDir,
|
|
87
|
+
...docs ? { docs } : {},
|
|
88
|
+
host,
|
|
89
|
+
https,
|
|
90
|
+
port,
|
|
91
|
+
quiet,
|
|
92
|
+
enableProdMode,
|
|
93
|
+
smokeTest,
|
|
94
|
+
sslCa,
|
|
95
|
+
sslCert,
|
|
96
|
+
sslKey,
|
|
97
|
+
disableTelemetry,
|
|
98
|
+
angularBrowserTarget: browserTarget,
|
|
99
|
+
angularBuilderContext: context,
|
|
100
|
+
angularBuilderOptions: {
|
|
101
|
+
...stylePreprocessorOptions ? { stylePreprocessorOptions } : {},
|
|
102
|
+
...styles ? { styles } : {},
|
|
103
|
+
...assets ? { assets } : {},
|
|
104
|
+
preserveSymlinks,
|
|
105
|
+
sourceMap,
|
|
106
|
+
experimentalZoneless
|
|
107
|
+
},
|
|
108
|
+
tsConfig,
|
|
109
|
+
initialPath,
|
|
110
|
+
open,
|
|
111
|
+
debugWebpack,
|
|
112
|
+
webpackStatsJson,
|
|
113
|
+
statsJson,
|
|
114
|
+
loglevel,
|
|
115
|
+
previewUrl
|
|
116
|
+
};
|
|
117
|
+
}),
|
|
118
|
+
switchMap((standaloneOptions) => runInstance(standaloneOptions)),
|
|
119
|
+
map((port) => ({ success: !0, info: { port } }))
|
|
120
|
+
), start_storybook_default = createBuilder(commandBuilder);
|
|
135
121
|
async function setup(options, context) {
|
|
136
|
-
let browserOptions;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
await context.getTargetOptions(browserTarget),
|
|
142
|
-
await context.getBuilderNameForTarget(browserTarget)
|
|
143
|
-
);
|
|
144
|
-
}
|
|
145
|
-
return {
|
|
122
|
+
let browserOptions, browserTarget;
|
|
123
|
+
return options.browserTarget && (browserTarget = targetFromTargetString(options.browserTarget), browserOptions = await context.validateOptions(
|
|
124
|
+
await context.getTargetOptions(browserTarget),
|
|
125
|
+
await context.getBuilderNameForTarget(browserTarget)
|
|
126
|
+
)), {
|
|
146
127
|
tsConfig: options.tsConfig ?? up("tsconfig.json", { cwd: options.configDir }) ?? browserOptions.tsConfig
|
|
147
128
|
};
|
|
148
129
|
}
|
|
149
|
-
__name(setup, "setup");
|
|
150
130
|
function runInstance(options) {
|
|
151
131
|
return new Observable((observer) => {
|
|
152
132
|
withTelemetry(
|
|
@@ -162,7 +142,6 @@ function runInstance(options) {
|
|
|
162
142
|
});
|
|
163
143
|
});
|
|
164
144
|
}
|
|
165
|
-
__name(runInstance, "runInstance");
|
|
166
145
|
export {
|
|
167
146
|
start_storybook_default as default
|
|
168
147
|
};
|
package/dist/client/config.js
CHANGED
|
@@ -1,59 +1,40 @@
|
|
|
1
1
|
import "../_browser-chunks/chunk-DAHG2CDK.js";
|
|
2
2
|
import {
|
|
3
|
-
__name,
|
|
4
3
|
computesTemplateFromComponent,
|
|
5
4
|
render,
|
|
6
5
|
renderToCanvas
|
|
7
|
-
} from "../_browser-chunks/chunk-
|
|
6
|
+
} from "../_browser-chunks/chunk-6CHBWP5J.js";
|
|
8
7
|
|
|
9
8
|
// src/client/decorateStory.ts
|
|
10
9
|
import { sanitizeStoryContextUpdate } from "storybook/preview-api";
|
|
11
10
|
function decorateStory(mainStoryFn, decorators) {
|
|
12
|
-
|
|
13
|
-
(previousStoryFn, decorator) => (context) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
...sanitizeStoryContextUpdate(update)
|
|
18
|
-
});
|
|
19
|
-
}, context);
|
|
20
|
-
return decoratedStory;
|
|
21
|
-
},
|
|
11
|
+
return [cleanArgsDecorator, ...decorators].reduce(
|
|
12
|
+
(previousStoryFn, decorator) => (context) => decorator((update) => previousStoryFn({
|
|
13
|
+
...context,
|
|
14
|
+
...sanitizeStoryContextUpdate(update)
|
|
15
|
+
}), context),
|
|
22
16
|
(context) => prepareMain(mainStoryFn(context), context)
|
|
23
17
|
);
|
|
24
|
-
return returnDecorators;
|
|
25
18
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const { component } = context;
|
|
30
|
-
const userDefinedTemplate = !hasNoTemplate(template);
|
|
31
|
-
if (!userDefinedTemplate && component) {
|
|
32
|
-
template = computesTemplateFromComponent(component, story.props, "");
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
19
|
+
var prepareMain = (story, context) => {
|
|
20
|
+
let { template } = story, { component } = context, userDefinedTemplate = !hasNoTemplate(template);
|
|
21
|
+
return !userDefinedTemplate && component && (template = computesTemplateFromComponent(component, story.props, "")), {
|
|
35
22
|
...story,
|
|
36
23
|
...template ? { template, userDefinedTemplate } : {}
|
|
37
24
|
};
|
|
38
|
-
}
|
|
25
|
+
};
|
|
39
26
|
function hasNoTemplate(template) {
|
|
40
|
-
return template
|
|
27
|
+
return template == null;
|
|
41
28
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
if (!context.argTypes || !context.args) {
|
|
29
|
+
var cleanArgsDecorator = (storyFn, context) => {
|
|
30
|
+
if (!context.argTypes || !context.args)
|
|
45
31
|
return storyFn();
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
return obj;
|
|
54
|
-
}, {});
|
|
55
|
-
return storyFn();
|
|
56
|
-
}, "cleanArgsDecorator");
|
|
32
|
+
let argsToClean = context.args;
|
|
33
|
+
return context.args = Object.entries(argsToClean).reduce((obj, [key, arg]) => {
|
|
34
|
+
let argType = context.argTypes[key];
|
|
35
|
+
return argType?.action || argType?.control ? { ...obj, [key]: arg } : obj;
|
|
36
|
+
}, {}), storyFn();
|
|
37
|
+
};
|
|
57
38
|
|
|
58
39
|
// src/client/config.ts
|
|
59
40
|
import { enhanceArgTypes } from "storybook/internal/docs-tools";
|
|
@@ -61,38 +42,14 @@ import { enhanceArgTypes } from "storybook/internal/docs-tools";
|
|
|
61
42
|
// src/client/compodoc.ts
|
|
62
43
|
import { logger } from "storybook/internal/client-logger";
|
|
63
44
|
import { global } from "@storybook/global";
|
|
64
|
-
var { FEATURES } = global;
|
|
65
|
-
var
|
|
66
|
-
|
|
67
|
-
}, "isMethod");
|
|
68
|
-
var getCompodocJson = /* @__PURE__ */ __name(() => global.__STORYBOOK_COMPODOC_JSON__, "getCompodocJson");
|
|
69
|
-
var checkValidComponentOrDirective = /* @__PURE__ */ __name((component) => {
|
|
70
|
-
if (!component.name) {
|
|
45
|
+
var { FEATURES } = global, isMethod = (methodOrProp) => methodOrProp.args !== void 0;
|
|
46
|
+
var getCompodocJson = () => global.__STORYBOOK_COMPODOC_JSON__, checkValidComponentOrDirective = (component) => {
|
|
47
|
+
if (!component.name)
|
|
71
48
|
throw new Error(`Invalid component ${JSON.stringify(component)}`);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
var checkValidCompodocJson = /* @__PURE__ */ __name((compodocJson) => {
|
|
75
|
-
if (!compodocJson || !compodocJson.components) {
|
|
49
|
+
}, checkValidCompodocJson = (compodocJson) => {
|
|
50
|
+
if (!compodocJson || !compodocJson.components)
|
|
76
51
|
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) => {
|
|
52
|
+
}, 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) => {
|
|
96
53
|
switch (key) {
|
|
97
54
|
case "methods":
|
|
98
55
|
case "methodsClass":
|
|
@@ -103,59 +60,40 @@ var mapItemToSection = /* @__PURE__ */ __name((key, item) => {
|
|
|
103
60
|
return "outputs";
|
|
104
61
|
case "properties":
|
|
105
62
|
case "propertiesClass":
|
|
106
|
-
if (isMethod(item))
|
|
63
|
+
if (isMethod(item))
|
|
107
64
|
throw new Error("Cannot be of type Method if key === 'propertiesClass'");
|
|
108
|
-
}
|
|
109
65
|
return mapPropertyToSection(item);
|
|
110
66
|
default:
|
|
111
67
|
throw new Error(`Unknown key: ${key}`);
|
|
112
68
|
}
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
var getComponentData = /* @__PURE__ */ __name((component) => {
|
|
116
|
-
if (!component) {
|
|
69
|
+
}, 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) => {
|
|
70
|
+
if (!component)
|
|
117
71
|
return null;
|
|
118
|
-
}
|
|
119
72
|
checkValidComponentOrDirective(component);
|
|
120
|
-
|
|
121
|
-
if (!compodocJson)
|
|
73
|
+
let compodocJson = getCompodocJson();
|
|
74
|
+
if (!compodocJson)
|
|
122
75
|
return null;
|
|
123
|
-
}
|
|
124
76
|
checkValidCompodocJson(compodocJson);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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;
|
|
77
|
+
let { name } = component, metadata = findComponentByName(name, compodocJson);
|
|
78
|
+
return metadata || logger.warn(`Component not found in compodoc JSON: '${name}'`), metadata;
|
|
79
|
+
}, displaySignature = (item) => `(${item.args.map(
|
|
80
|
+
(arg) => `${arg.name}${arg.optional ? "?" : ""}: ${arg.type}`
|
|
81
|
+
).join(", ")}) => ${item.returnType}`, extractTypeFromValue = (defaultValue) => {
|
|
82
|
+
let valueType = typeof defaultValue;
|
|
140
83
|
return defaultValue || valueType === "number" || valueType === "boolean" || valueType === "string" ? valueType : null;
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
const enumType = compodocJson?.miscellaneous?.enumerations?.find((x) => x.name === compodocType);
|
|
145
|
-
if (enumType?.childs.every((x) => x.value)) {
|
|
84
|
+
}, extractEnumValues = (compodocType) => {
|
|
85
|
+
let enumType = getCompodocJson()?.miscellaneous?.enumerations?.find((x) => x.name === compodocType);
|
|
86
|
+
if (enumType?.childs.every((x) => x.value))
|
|
146
87
|
return enumType.childs.map((x) => x.value);
|
|
147
|
-
|
|
148
|
-
if (typeof compodocType !== "string" || compodocType.indexOf("|") === -1) {
|
|
88
|
+
if (typeof compodocType != "string" || compodocType.indexOf("|") === -1)
|
|
149
89
|
return null;
|
|
150
|
-
}
|
|
151
90
|
try {
|
|
152
91
|
return compodocType.split("|").map((value) => JSON.parse(value));
|
|
153
|
-
} catch
|
|
92
|
+
} catch {
|
|
154
93
|
return null;
|
|
155
94
|
}
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
const compodocType = property.type || extractTypeFromValue(defaultValue);
|
|
95
|
+
}, extractType = (property, defaultValue) => {
|
|
96
|
+
let compodocType = property.type || extractTypeFromValue(defaultValue);
|
|
159
97
|
switch (compodocType) {
|
|
160
98
|
case "string":
|
|
161
99
|
case "boolean":
|
|
@@ -165,80 +103,57 @@ var extractType = /* @__PURE__ */ __name((property, defaultValue) => {
|
|
|
165
103
|
case null:
|
|
166
104
|
return { name: "other", value: "void" };
|
|
167
105
|
default: {
|
|
168
|
-
|
|
169
|
-
const enumValues = extractEnumValues(resolvedType);
|
|
106
|
+
let resolvedType = resolveTypealias(compodocType), enumValues = extractEnumValues(resolvedType);
|
|
170
107
|
return enumValues ? { name: "enum", value: enumValues } : { name: "other", value: "empty-enum" };
|
|
171
108
|
}
|
|
172
109
|
}
|
|
173
|
-
},
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (["boolean", "number", "string", "EventEmitter"].includes(compodocType)) {
|
|
110
|
+
}, castDefaultValue = (property, defaultValue) => {
|
|
111
|
+
let compodocType = property.type;
|
|
112
|
+
if (["boolean", "number", "string", "EventEmitter"].includes(compodocType))
|
|
177
113
|
switch (compodocType) {
|
|
178
114
|
case "boolean":
|
|
179
115
|
return defaultValue === "true";
|
|
180
116
|
case "number":
|
|
181
117
|
return Number(defaultValue);
|
|
182
118
|
case "EventEmitter":
|
|
183
|
-
return
|
|
119
|
+
return;
|
|
184
120
|
default:
|
|
185
121
|
return defaultValue;
|
|
186
122
|
}
|
|
187
|
-
|
|
123
|
+
else
|
|
188
124
|
switch (defaultValue) {
|
|
189
125
|
case "true":
|
|
190
|
-
return
|
|
126
|
+
return !0;
|
|
191
127
|
case "false":
|
|
192
|
-
return
|
|
128
|
+
return !1;
|
|
193
129
|
case "null":
|
|
194
130
|
return null;
|
|
195
131
|
case "undefined":
|
|
196
|
-
return
|
|
132
|
+
return;
|
|
197
133
|
default:
|
|
198
134
|
return defaultValue;
|
|
199
135
|
}
|
|
200
|
-
|
|
201
|
-
}, "castDefaultValue");
|
|
202
|
-
var extractDefaultValueFromComments = /* @__PURE__ */ __name((property, value) => {
|
|
136
|
+
}, extractDefaultValueFromComments = (property, value) => {
|
|
203
137
|
let commentValue = value;
|
|
204
|
-
property.jsdoctags.forEach((tag) => {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
return commentValue;
|
|
211
|
-
}, "extractDefaultValueFromComments");
|
|
212
|
-
var extractDefaultValue = /* @__PURE__ */ __name((property) => {
|
|
138
|
+
return property.jsdoctags.forEach((tag) => {
|
|
139
|
+
["default", "defaultvalue"].includes(tag.tagName.escapedText) && (commentValue = new global.DOMParser().parseFromString(tag.comment, "text/html").body.textContent);
|
|
140
|
+
}), commentValue;
|
|
141
|
+
}, extractDefaultValue = (property) => {
|
|
213
142
|
try {
|
|
214
143
|
let value = property.defaultValue?.replace(/^'(.*)'$/, "$1");
|
|
215
|
-
value = castDefaultValue(property, value);
|
|
216
|
-
|
|
217
|
-
value = extractDefaultValueFromComments(property, value);
|
|
218
|
-
}
|
|
219
|
-
return value;
|
|
220
|
-
} catch (err) {
|
|
144
|
+
return value = castDefaultValue(property, value), value == null && property.jsdoctags?.length > 0 && (value = extractDefaultValueFromComments(property, value)), value;
|
|
145
|
+
} catch {
|
|
221
146
|
logger.debug(`Error extracting ${property.name}: ${property.defaultValue}`);
|
|
222
|
-
return
|
|
147
|
+
return;
|
|
223
148
|
}
|
|
224
|
-
},
|
|
225
|
-
|
|
226
|
-
const compodocJson = getCompodocJson();
|
|
227
|
-
const typeAlias = compodocJson?.miscellaneous?.typealiases?.find((x) => x.name === compodocType);
|
|
149
|
+
}, resolveTypealias = (compodocType) => {
|
|
150
|
+
let typeAlias = getCompodocJson()?.miscellaneous?.typealiases?.find((x) => x.name === compodocType);
|
|
228
151
|
return typeAlias ? resolveTypealias(typeAlias.rawtype) : compodocType;
|
|
229
|
-
},
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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 = {
|
|
152
|
+
}, extractArgTypesFromData = (componentData) => {
|
|
153
|
+
let sectionToItems = {}, componentClasses = FEATURES.angularFilterNonInputControls ? ["inputsClass"] : ["propertiesClass", "methodsClass", "inputsClass", "outputsClass"];
|
|
154
|
+
(["component", "directive"].includes(componentData.type) ? componentClasses : ["properties", "methods"]).forEach((key) => {
|
|
155
|
+
(componentData[key] || []).forEach((item) => {
|
|
156
|
+
let section = mapItemToSection(key, item), defaultValue = isMethod(item) ? void 0 : extractDefaultValue(item), type = isMethod(item) || section !== "inputs" && section !== "properties" ? { name: "other", value: "void" } : extractType(item, defaultValue), action = section === "outputs" ? { action: item.name } : {}, argType = {
|
|
242
157
|
name: item.name,
|
|
243
158
|
description: item.rawdescription || item.description,
|
|
244
159
|
type,
|
|
@@ -247,18 +162,15 @@ var extractArgTypesFromData = /* @__PURE__ */ __name((componentData) => {
|
|
|
247
162
|
category: section,
|
|
248
163
|
type: {
|
|
249
164
|
summary: isMethod(item) ? displaySignature(item) : item.type,
|
|
250
|
-
required: isMethod(item) ?
|
|
165
|
+
required: isMethod(item) ? !1 : !item.optional
|
|
251
166
|
},
|
|
252
167
|
defaultValue: { summary: defaultValue }
|
|
253
168
|
}
|
|
254
169
|
};
|
|
255
|
-
|
|
256
|
-
sectionToItems[section] = [];
|
|
257
|
-
}
|
|
258
|
-
sectionToItems[section].push(argType);
|
|
170
|
+
sectionToItems[section] || (sectionToItems[section] = []), sectionToItems[section].push(argType);
|
|
259
171
|
});
|
|
260
172
|
});
|
|
261
|
-
|
|
173
|
+
let SECTIONS = [
|
|
262
174
|
"properties",
|
|
263
175
|
"inputs",
|
|
264
176
|
"outputs",
|
|
@@ -267,37 +179,30 @@ var extractArgTypesFromData = /* @__PURE__ */ __name((componentData) => {
|
|
|
267
179
|
"view children",
|
|
268
180
|
"content child",
|
|
269
181
|
"content children"
|
|
270
|
-
];
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
});
|
|
280
|
-
return argTypes;
|
|
281
|
-
}, "extractArgTypesFromData");
|
|
282
|
-
var extractArgTypes = /* @__PURE__ */ __name((component) => {
|
|
283
|
-
const componentData = getComponentData(component);
|
|
182
|
+
], argTypes = {};
|
|
183
|
+
return SECTIONS.forEach((section) => {
|
|
184
|
+
let items = sectionToItems[section];
|
|
185
|
+
items && items.forEach((argType) => {
|
|
186
|
+
argTypes[argType.name] = argType;
|
|
187
|
+
});
|
|
188
|
+
}), argTypes;
|
|
189
|
+
}, extractArgTypes = (component) => {
|
|
190
|
+
let componentData = getComponentData(component);
|
|
284
191
|
return componentData && extractArgTypesFromData(componentData);
|
|
285
|
-
},
|
|
286
|
-
|
|
287
|
-
const componentData = getComponentData(component);
|
|
192
|
+
}, extractComponentDescription = (component) => {
|
|
193
|
+
let componentData = getComponentData(component);
|
|
288
194
|
return componentData && (componentData.rawdescription || componentData.description);
|
|
289
|
-
}
|
|
195
|
+
};
|
|
290
196
|
|
|
291
197
|
// src/client/config.ts
|
|
292
198
|
var parameters = {
|
|
293
199
|
renderer: "angular",
|
|
294
200
|
docs: {
|
|
295
|
-
story: { inline:
|
|
201
|
+
story: { inline: !0 },
|
|
296
202
|
extractArgTypes,
|
|
297
203
|
extractComponentDescription
|
|
298
204
|
}
|
|
299
|
-
};
|
|
300
|
-
var argTypesEnhancers = [enhanceArgTypes];
|
|
205
|
+
}, argTypesEnhancers = [enhanceArgTypes];
|
|
301
206
|
export {
|
|
302
207
|
decorateStory as applyDecorators,
|
|
303
208
|
argTypesEnhancers,
|