@storybook/angular 10.2.0-alpha.9 → 10.2.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_browser-chunks/{chunk-6CHBWP5J.js → chunk-34GOABUT.js} +1 -0
- package/dist/_browser-chunks/chunk-CT6JF2ND.js +47 -0
- package/dist/_browser-chunks/chunk-XA6C6Y3S.js +226 -0
- package/dist/_browser-chunks/{chunk-T32Z4CGF.js → chunk-XYAB765U.js} +17 -1
- package/dist/_node-chunks/{chunk-OHFIWQ3M.js → chunk-MGTEAORO.js} +6 -6
- package/dist/_node-chunks/{chunk-3PQ7NODI.js → chunk-VC4VWMPL.js} +7 -7
- package/dist/builders/build-storybook/index.js +8 -8
- package/dist/builders/start-storybook/index.js +8 -8
- package/dist/client/config.js +6 -202
- package/dist/client/docs/config.js +4 -34
- package/dist/client/index.js +6 -3
- package/dist/index.d.ts +516 -2
- package/dist/index.js +7 -3
- package/dist/node/index.js +6 -6
- package/dist/preset.js +6 -6
- package/dist/server/framework-preset-angular-cli.js +7 -7
- package/dist/server/framework-preset-angular-ivy.js +6 -6
- package/package.json +6 -6
- package/dist/_browser-chunks/chunk-DAHG2CDK.js +0 -3
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export,
|
|
3
|
+
computesTemplateSourceFromComponent
|
|
4
|
+
} from "./chunk-34GOABUT.js";
|
|
5
|
+
|
|
6
|
+
// src/client/docs/config.ts
|
|
7
|
+
var config_exports = {};
|
|
8
|
+
__export(config_exports, {
|
|
9
|
+
decorators: () => decorators,
|
|
10
|
+
parameters: () => parameters
|
|
11
|
+
});
|
|
12
|
+
import { SourceType as SourceType2 } from "storybook/internal/docs-tools";
|
|
13
|
+
|
|
14
|
+
// src/client/docs/sourceDecorator.ts
|
|
15
|
+
import { SourceType } from "storybook/internal/docs-tools";
|
|
16
|
+
import { useRef, emitTransformCode, useEffect } from "storybook/preview-api";
|
|
17
|
+
var skipSourceRender = (context) => {
|
|
18
|
+
let sourceParams = context?.parameters.docs?.source;
|
|
19
|
+
return sourceParams?.type === SourceType.DYNAMIC ? !1 : sourceParams?.code || sourceParams?.type === SourceType.CODE;
|
|
20
|
+
}, sourceDecorator = (storyFn, context) => {
|
|
21
|
+
let story = storyFn(), source = useRef(void 0);
|
|
22
|
+
return useEffect(() => {
|
|
23
|
+
if (skipSourceRender(context))
|
|
24
|
+
return;
|
|
25
|
+
let { props, userDefinedTemplate } = story, { component, argTypes, parameters: parameters2 } = context, template = parameters2.docs?.source?.excludeDecorators ? context.originalStoryFn(context.args, context).template : story.template;
|
|
26
|
+
if (component && !userDefinedTemplate) {
|
|
27
|
+
let newSource = computesTemplateSourceFromComponent(component, props, argTypes) || template;
|
|
28
|
+
newSource && newSource !== source.current && (emitTransformCode(newSource, context), source.current = newSource);
|
|
29
|
+
} else template && template !== source.current && (emitTransformCode(template, context), source.current = template);
|
|
30
|
+
}), story;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// src/client/docs/config.ts
|
|
34
|
+
var parameters = {
|
|
35
|
+
docs: {
|
|
36
|
+
source: {
|
|
37
|
+
type: SourceType2.DYNAMIC,
|
|
38
|
+
language: "html"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}, decorators = [sourceDecorator];
|
|
42
|
+
|
|
43
|
+
export {
|
|
44
|
+
parameters,
|
|
45
|
+
decorators,
|
|
46
|
+
config_exports
|
|
47
|
+
};
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__export,
|
|
3
|
+
computesTemplateFromComponent,
|
|
4
|
+
render,
|
|
5
|
+
renderToCanvas
|
|
6
|
+
} from "./chunk-34GOABUT.js";
|
|
7
|
+
|
|
8
|
+
// src/client/config.ts
|
|
9
|
+
var config_exports = {};
|
|
10
|
+
__export(config_exports, {
|
|
11
|
+
applyDecorators: () => decorateStory,
|
|
12
|
+
argTypesEnhancers: () => argTypesEnhancers,
|
|
13
|
+
parameters: () => parameters,
|
|
14
|
+
render: () => render,
|
|
15
|
+
renderToCanvas: () => renderToCanvas
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// src/client/globals.ts
|
|
19
|
+
import { global } from "@storybook/global";
|
|
20
|
+
global.STORYBOOK_ENV = "angular";
|
|
21
|
+
|
|
22
|
+
// src/client/decorateStory.ts
|
|
23
|
+
import { sanitizeStoryContextUpdate } from "storybook/preview-api";
|
|
24
|
+
function decorateStory(mainStoryFn, decorators) {
|
|
25
|
+
return [cleanArgsDecorator, ...decorators].reduce(
|
|
26
|
+
(previousStoryFn, decorator) => (context) => decorator((update) => previousStoryFn({
|
|
27
|
+
...context,
|
|
28
|
+
...sanitizeStoryContextUpdate(update)
|
|
29
|
+
}), context),
|
|
30
|
+
(context) => prepareMain(mainStoryFn(context), context)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
var prepareMain = (story, context) => {
|
|
34
|
+
let { template } = story, { component } = context, userDefinedTemplate = !hasNoTemplate(template);
|
|
35
|
+
return !userDefinedTemplate && component && (template = computesTemplateFromComponent(component, story.props, "")), {
|
|
36
|
+
...story,
|
|
37
|
+
...template ? { template, userDefinedTemplate } : {}
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
function hasNoTemplate(template) {
|
|
41
|
+
return template == null;
|
|
42
|
+
}
|
|
43
|
+
var cleanArgsDecorator = (storyFn, context) => {
|
|
44
|
+
if (!context.argTypes || !context.args)
|
|
45
|
+
return storyFn();
|
|
46
|
+
let argsToClean = context.args;
|
|
47
|
+
return context.args = Object.entries(argsToClean).reduce((obj, [key, arg]) => {
|
|
48
|
+
let argType = context.argTypes[key];
|
|
49
|
+
return argType?.action || argType?.control ? { ...obj, [key]: arg } : obj;
|
|
50
|
+
}, {}), storyFn();
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/client/config.ts
|
|
54
|
+
import { enhanceArgTypes } from "storybook/internal/docs-tools";
|
|
55
|
+
|
|
56
|
+
// src/client/compodoc.ts
|
|
57
|
+
import { logger } from "storybook/internal/client-logger";
|
|
58
|
+
import { global as global2 } from "@storybook/global";
|
|
59
|
+
var { FEATURES } = global2, isMethod = (methodOrProp) => methodOrProp.args !== void 0;
|
|
60
|
+
var getCompodocJson = () => global2.__STORYBOOK_COMPODOC_JSON__, checkValidComponentOrDirective = (component) => {
|
|
61
|
+
if (!component.name)
|
|
62
|
+
throw new Error(`Invalid component ${JSON.stringify(component)}`);
|
|
63
|
+
}, checkValidCompodocJson = (compodocJson) => {
|
|
64
|
+
if (!compodocJson || !compodocJson.components)
|
|
65
|
+
throw new Error("Invalid compodoc JSON");
|
|
66
|
+
}, 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) => {
|
|
67
|
+
switch (key) {
|
|
68
|
+
case "methods":
|
|
69
|
+
case "methodsClass":
|
|
70
|
+
return "methods";
|
|
71
|
+
case "inputsClass":
|
|
72
|
+
return "inputs";
|
|
73
|
+
case "outputsClass":
|
|
74
|
+
return "outputs";
|
|
75
|
+
case "properties":
|
|
76
|
+
case "propertiesClass":
|
|
77
|
+
if (isMethod(item))
|
|
78
|
+
throw new Error("Cannot be of type Method if key === 'propertiesClass'");
|
|
79
|
+
return mapPropertyToSection(item);
|
|
80
|
+
default:
|
|
81
|
+
throw new Error(`Unknown key: ${key}`);
|
|
82
|
+
}
|
|
83
|
+
}, 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) => {
|
|
84
|
+
if (!component)
|
|
85
|
+
return null;
|
|
86
|
+
checkValidComponentOrDirective(component);
|
|
87
|
+
let compodocJson = getCompodocJson();
|
|
88
|
+
if (!compodocJson)
|
|
89
|
+
return null;
|
|
90
|
+
checkValidCompodocJson(compodocJson);
|
|
91
|
+
let { name } = component, metadata = findComponentByName(name, compodocJson);
|
|
92
|
+
return metadata || logger.warn(`Component not found in compodoc JSON: '${name}'`), metadata;
|
|
93
|
+
}, displaySignature = (item) => `(${item.args.map(
|
|
94
|
+
(arg) => `${arg.name}${arg.optional ? "?" : ""}: ${arg.type}`
|
|
95
|
+
).join(", ")}) => ${item.returnType}`, extractTypeFromValue = (defaultValue) => {
|
|
96
|
+
let valueType = typeof defaultValue;
|
|
97
|
+
return defaultValue || valueType === "number" || valueType === "boolean" || valueType === "string" ? valueType : null;
|
|
98
|
+
}, extractEnumValues = (compodocType) => {
|
|
99
|
+
let enumType = getCompodocJson()?.miscellaneous?.enumerations?.find((x) => x.name === compodocType);
|
|
100
|
+
if (enumType?.childs.every((x) => x.value))
|
|
101
|
+
return enumType.childs.map((x) => x.value);
|
|
102
|
+
if (typeof compodocType != "string" || compodocType.indexOf("|") === -1)
|
|
103
|
+
return null;
|
|
104
|
+
try {
|
|
105
|
+
return compodocType.split("|").map((value) => JSON.parse(value));
|
|
106
|
+
} catch {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
}, extractType = (property, defaultValue) => {
|
|
110
|
+
let compodocType = property.type || extractTypeFromValue(defaultValue);
|
|
111
|
+
switch (compodocType) {
|
|
112
|
+
case "string":
|
|
113
|
+
case "boolean":
|
|
114
|
+
case "number":
|
|
115
|
+
return { name: compodocType };
|
|
116
|
+
case void 0:
|
|
117
|
+
case null:
|
|
118
|
+
return { name: "other", value: "void" };
|
|
119
|
+
default: {
|
|
120
|
+
let resolvedType = resolveTypealias(compodocType), enumValues = extractEnumValues(resolvedType);
|
|
121
|
+
return enumValues ? { name: "enum", value: enumValues } : { name: "other", value: "empty-enum" };
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}, castDefaultValue = (property, defaultValue) => {
|
|
125
|
+
let compodocType = property.type;
|
|
126
|
+
if (["boolean", "number", "string", "EventEmitter"].includes(compodocType))
|
|
127
|
+
switch (compodocType) {
|
|
128
|
+
case "boolean":
|
|
129
|
+
return defaultValue === "true";
|
|
130
|
+
case "number":
|
|
131
|
+
return Number(defaultValue);
|
|
132
|
+
case "EventEmitter":
|
|
133
|
+
return;
|
|
134
|
+
default:
|
|
135
|
+
return defaultValue;
|
|
136
|
+
}
|
|
137
|
+
else
|
|
138
|
+
switch (defaultValue) {
|
|
139
|
+
case "true":
|
|
140
|
+
return !0;
|
|
141
|
+
case "false":
|
|
142
|
+
return !1;
|
|
143
|
+
case "null":
|
|
144
|
+
return null;
|
|
145
|
+
case "undefined":
|
|
146
|
+
return;
|
|
147
|
+
default:
|
|
148
|
+
return defaultValue;
|
|
149
|
+
}
|
|
150
|
+
}, extractDefaultValueFromComments = (property, value) => {
|
|
151
|
+
let commentValue = value;
|
|
152
|
+
return property.jsdoctags.forEach((tag) => {
|
|
153
|
+
["default", "defaultvalue"].includes(tag.tagName.escapedText) && (commentValue = new global2.DOMParser().parseFromString(tag.comment, "text/html").body.textContent);
|
|
154
|
+
}), commentValue;
|
|
155
|
+
}, extractDefaultValue = (property) => {
|
|
156
|
+
try {
|
|
157
|
+
let value = property.defaultValue?.replace(/^'(.*)'$/, "$1");
|
|
158
|
+
return value = castDefaultValue(property, value), value == null && property.jsdoctags?.length > 0 && (value = extractDefaultValueFromComments(property, value)), value;
|
|
159
|
+
} catch {
|
|
160
|
+
logger.debug(`Error extracting ${property.name}: ${property.defaultValue}`);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
}, resolveTypealias = (compodocType) => {
|
|
164
|
+
let typeAlias = getCompodocJson()?.miscellaneous?.typealiases?.find((x) => x.name === compodocType);
|
|
165
|
+
return typeAlias ? resolveTypealias(typeAlias.rawtype) : compodocType;
|
|
166
|
+
}, extractArgTypesFromData = (componentData) => {
|
|
167
|
+
let sectionToItems = {}, componentClasses = FEATURES.angularFilterNonInputControls ? ["inputsClass"] : ["propertiesClass", "methodsClass", "inputsClass", "outputsClass"];
|
|
168
|
+
(["component", "directive"].includes(componentData.type) ? componentClasses : ["properties", "methods"]).forEach((key) => {
|
|
169
|
+
(componentData[key] || []).forEach((item) => {
|
|
170
|
+
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 = {
|
|
171
|
+
name: item.name,
|
|
172
|
+
description: item.rawdescription || item.description,
|
|
173
|
+
type,
|
|
174
|
+
...action,
|
|
175
|
+
table: {
|
|
176
|
+
category: section,
|
|
177
|
+
type: {
|
|
178
|
+
summary: isMethod(item) ? displaySignature(item) : item.type,
|
|
179
|
+
required: isMethod(item) ? !1 : !item.optional
|
|
180
|
+
},
|
|
181
|
+
defaultValue: { summary: defaultValue }
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
sectionToItems[section] || (sectionToItems[section] = []), sectionToItems[section].push(argType);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
let SECTIONS = [
|
|
188
|
+
"properties",
|
|
189
|
+
"inputs",
|
|
190
|
+
"outputs",
|
|
191
|
+
"methods",
|
|
192
|
+
"view child",
|
|
193
|
+
"view children",
|
|
194
|
+
"content child",
|
|
195
|
+
"content children"
|
|
196
|
+
], argTypes = {};
|
|
197
|
+
return SECTIONS.forEach((section) => {
|
|
198
|
+
let items = sectionToItems[section];
|
|
199
|
+
items && items.forEach((argType) => {
|
|
200
|
+
argTypes[argType.name] = argType;
|
|
201
|
+
});
|
|
202
|
+
}), argTypes;
|
|
203
|
+
}, extractArgTypes = (component) => {
|
|
204
|
+
let componentData = getComponentData(component);
|
|
205
|
+
return componentData && extractArgTypesFromData(componentData);
|
|
206
|
+
}, extractComponentDescription = (component) => {
|
|
207
|
+
let componentData = getComponentData(component);
|
|
208
|
+
return componentData && (componentData.rawdescription || componentData.description);
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
// src/client/config.ts
|
|
212
|
+
var parameters = {
|
|
213
|
+
renderer: "angular",
|
|
214
|
+
docs: {
|
|
215
|
+
story: { inline: !0 },
|
|
216
|
+
extractArgTypes,
|
|
217
|
+
extractComponentDescription
|
|
218
|
+
}
|
|
219
|
+
}, argTypesEnhancers = [enhanceArgTypes];
|
|
220
|
+
|
|
221
|
+
export {
|
|
222
|
+
decorateStory,
|
|
223
|
+
parameters,
|
|
224
|
+
argTypesEnhancers,
|
|
225
|
+
config_exports
|
|
226
|
+
};
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
config_exports
|
|
3
|
+
} from "./chunk-XA6C6Y3S.js";
|
|
4
|
+
import {
|
|
5
|
+
config_exports as config_exports2
|
|
6
|
+
} from "./chunk-CT6JF2ND.js";
|
|
1
7
|
import {
|
|
2
8
|
computesTemplateFromComponent,
|
|
3
9
|
formatPropInTemplate,
|
|
4
10
|
isComponent,
|
|
5
11
|
render_exports
|
|
6
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-34GOABUT.js";
|
|
7
13
|
|
|
8
14
|
// src/client/portable-stories.ts
|
|
9
15
|
import {
|
|
@@ -16,6 +22,15 @@ function setProjectAnnotations(projectAnnotations) {
|
|
|
16
22
|
);
|
|
17
23
|
}
|
|
18
24
|
|
|
25
|
+
// src/client/preview.ts
|
|
26
|
+
import { definePreview as definePreviewBase } from "storybook/internal/csf";
|
|
27
|
+
function __definePreview(input) {
|
|
28
|
+
return definePreviewBase({
|
|
29
|
+
...input,
|
|
30
|
+
addons: [config_exports, config_exports2, ...input.addons ?? []]
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
19
34
|
// src/client/decorators.ts
|
|
20
35
|
var moduleMetadata = (metadata) => (storyFn) => {
|
|
21
36
|
let story = storyFn(), storyMetadata = story.moduleMetadata || {};
|
|
@@ -70,6 +85,7 @@ function argsToTemplate(args, options = {}) {
|
|
|
70
85
|
|
|
71
86
|
export {
|
|
72
87
|
setProjectAnnotations,
|
|
88
|
+
__definePreview,
|
|
73
89
|
moduleMetadata,
|
|
74
90
|
applicationConfig,
|
|
75
91
|
componentWrapperDecorator,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_uphhvkl4339 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_uphhvkl4339 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_uphhvkl4339 from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_uphhvkl4339.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_uphhvkl4339.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_uphhvkl4339.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_uphhvkl4339 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_uphhvkl4339 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_uphhvkl4339 from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_uphhvkl4339.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_uphhvkl4339.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_uphhvkl4339.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
up
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-MGTEAORO.js";
|
|
15
15
|
|
|
16
16
|
// ../../../node_modules/empathic/package.mjs
|
|
17
17
|
function up2(options) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_uphhvkl4339 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_uphhvkl4339 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_uphhvkl4339 from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_uphhvkl4339.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_uphhvkl4339.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_uphhvkl4339.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -14,10 +14,10 @@ import {
|
|
|
14
14
|
printErrorDetails,
|
|
15
15
|
runCompodoc,
|
|
16
16
|
up as up2
|
|
17
|
-
} from "../../_node-chunks/chunk-
|
|
17
|
+
} from "../../_node-chunks/chunk-VC4VWMPL.js";
|
|
18
18
|
import {
|
|
19
19
|
up
|
|
20
|
-
} from "../../_node-chunks/chunk-
|
|
20
|
+
} from "../../_node-chunks/chunk-MGTEAORO.js";
|
|
21
21
|
|
|
22
22
|
// src/builders/build-storybook/index.ts
|
|
23
23
|
import { readFileSync } from "node:fs";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_uphhvkl4339 from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_uphhvkl4339 from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_uphhvkl4339 from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_uphhvkl4339.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_uphhvkl4339.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_uphhvkl4339.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -14,10 +14,10 @@ import {
|
|
|
14
14
|
printErrorDetails,
|
|
15
15
|
runCompodoc,
|
|
16
16
|
up as up2
|
|
17
|
-
} from "../../_node-chunks/chunk-
|
|
17
|
+
} from "../../_node-chunks/chunk-VC4VWMPL.js";
|
|
18
18
|
import {
|
|
19
19
|
up
|
|
20
|
-
} from "../../_node-chunks/chunk-
|
|
20
|
+
} from "../../_node-chunks/chunk-MGTEAORO.js";
|
|
21
21
|
|
|
22
22
|
// src/builders/start-storybook/index.ts
|
|
23
23
|
import { readFileSync } from "node:fs";
|
package/dist/client/config.js
CHANGED
|
@@ -1,208 +1,12 @@
|
|
|
1
|
-
import "../_browser-chunks/chunk-DAHG2CDK.js";
|
|
2
1
|
import {
|
|
3
|
-
|
|
2
|
+
argTypesEnhancers,
|
|
3
|
+
decorateStory,
|
|
4
|
+
parameters
|
|
5
|
+
} from "../_browser-chunks/chunk-XA6C6Y3S.js";
|
|
6
|
+
import {
|
|
4
7
|
render,
|
|
5
8
|
renderToCanvas
|
|
6
|
-
} from "../_browser-chunks/chunk-
|
|
7
|
-
|
|
8
|
-
// src/client/decorateStory.ts
|
|
9
|
-
import { sanitizeStoryContextUpdate } from "storybook/preview-api";
|
|
10
|
-
function decorateStory(mainStoryFn, decorators) {
|
|
11
|
-
return [cleanArgsDecorator, ...decorators].reduce(
|
|
12
|
-
(previousStoryFn, decorator) => (context) => decorator((update) => previousStoryFn({
|
|
13
|
-
...context,
|
|
14
|
-
...sanitizeStoryContextUpdate(update)
|
|
15
|
-
}), context),
|
|
16
|
-
(context) => prepareMain(mainStoryFn(context), context)
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
var prepareMain = (story, context) => {
|
|
20
|
-
let { template } = story, { component } = context, userDefinedTemplate = !hasNoTemplate(template);
|
|
21
|
-
return !userDefinedTemplate && component && (template = computesTemplateFromComponent(component, story.props, "")), {
|
|
22
|
-
...story,
|
|
23
|
-
...template ? { template, userDefinedTemplate } : {}
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
function hasNoTemplate(template) {
|
|
27
|
-
return template == null;
|
|
28
|
-
}
|
|
29
|
-
var cleanArgsDecorator = (storyFn, context) => {
|
|
30
|
-
if (!context.argTypes || !context.args)
|
|
31
|
-
return storyFn();
|
|
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
|
-
};
|
|
38
|
-
|
|
39
|
-
// src/client/config.ts
|
|
40
|
-
import { enhanceArgTypes } from "storybook/internal/docs-tools";
|
|
41
|
-
|
|
42
|
-
// src/client/compodoc.ts
|
|
43
|
-
import { logger } from "storybook/internal/client-logger";
|
|
44
|
-
import { global } from "@storybook/global";
|
|
45
|
-
var { FEATURES } = global, isMethod = (methodOrProp) => methodOrProp.args !== void 0;
|
|
46
|
-
var getCompodocJson = () => global.__STORYBOOK_COMPODOC_JSON__, checkValidComponentOrDirective = (component) => {
|
|
47
|
-
if (!component.name)
|
|
48
|
-
throw new Error(`Invalid component ${JSON.stringify(component)}`);
|
|
49
|
-
}, checkValidCompodocJson = (compodocJson) => {
|
|
50
|
-
if (!compodocJson || !compodocJson.components)
|
|
51
|
-
throw new Error("Invalid compodoc JSON");
|
|
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) => {
|
|
53
|
-
switch (key) {
|
|
54
|
-
case "methods":
|
|
55
|
-
case "methodsClass":
|
|
56
|
-
return "methods";
|
|
57
|
-
case "inputsClass":
|
|
58
|
-
return "inputs";
|
|
59
|
-
case "outputsClass":
|
|
60
|
-
return "outputs";
|
|
61
|
-
case "properties":
|
|
62
|
-
case "propertiesClass":
|
|
63
|
-
if (isMethod(item))
|
|
64
|
-
throw new Error("Cannot be of type Method if key === 'propertiesClass'");
|
|
65
|
-
return mapPropertyToSection(item);
|
|
66
|
-
default:
|
|
67
|
-
throw new Error(`Unknown key: ${key}`);
|
|
68
|
-
}
|
|
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)
|
|
71
|
-
return null;
|
|
72
|
-
checkValidComponentOrDirective(component);
|
|
73
|
-
let compodocJson = getCompodocJson();
|
|
74
|
-
if (!compodocJson)
|
|
75
|
-
return null;
|
|
76
|
-
checkValidCompodocJson(compodocJson);
|
|
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;
|
|
83
|
-
return defaultValue || valueType === "number" || valueType === "boolean" || valueType === "string" ? valueType : null;
|
|
84
|
-
}, extractEnumValues = (compodocType) => {
|
|
85
|
-
let enumType = getCompodocJson()?.miscellaneous?.enumerations?.find((x) => x.name === compodocType);
|
|
86
|
-
if (enumType?.childs.every((x) => x.value))
|
|
87
|
-
return enumType.childs.map((x) => x.value);
|
|
88
|
-
if (typeof compodocType != "string" || compodocType.indexOf("|") === -1)
|
|
89
|
-
return null;
|
|
90
|
-
try {
|
|
91
|
-
return compodocType.split("|").map((value) => JSON.parse(value));
|
|
92
|
-
} catch {
|
|
93
|
-
return null;
|
|
94
|
-
}
|
|
95
|
-
}, extractType = (property, defaultValue) => {
|
|
96
|
-
let compodocType = property.type || extractTypeFromValue(defaultValue);
|
|
97
|
-
switch (compodocType) {
|
|
98
|
-
case "string":
|
|
99
|
-
case "boolean":
|
|
100
|
-
case "number":
|
|
101
|
-
return { name: compodocType };
|
|
102
|
-
case void 0:
|
|
103
|
-
case null:
|
|
104
|
-
return { name: "other", value: "void" };
|
|
105
|
-
default: {
|
|
106
|
-
let resolvedType = resolveTypealias(compodocType), enumValues = extractEnumValues(resolvedType);
|
|
107
|
-
return enumValues ? { name: "enum", value: enumValues } : { name: "other", value: "empty-enum" };
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}, castDefaultValue = (property, defaultValue) => {
|
|
111
|
-
let compodocType = property.type;
|
|
112
|
-
if (["boolean", "number", "string", "EventEmitter"].includes(compodocType))
|
|
113
|
-
switch (compodocType) {
|
|
114
|
-
case "boolean":
|
|
115
|
-
return defaultValue === "true";
|
|
116
|
-
case "number":
|
|
117
|
-
return Number(defaultValue);
|
|
118
|
-
case "EventEmitter":
|
|
119
|
-
return;
|
|
120
|
-
default:
|
|
121
|
-
return defaultValue;
|
|
122
|
-
}
|
|
123
|
-
else
|
|
124
|
-
switch (defaultValue) {
|
|
125
|
-
case "true":
|
|
126
|
-
return !0;
|
|
127
|
-
case "false":
|
|
128
|
-
return !1;
|
|
129
|
-
case "null":
|
|
130
|
-
return null;
|
|
131
|
-
case "undefined":
|
|
132
|
-
return;
|
|
133
|
-
default:
|
|
134
|
-
return defaultValue;
|
|
135
|
-
}
|
|
136
|
-
}, extractDefaultValueFromComments = (property, value) => {
|
|
137
|
-
let commentValue = value;
|
|
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) => {
|
|
142
|
-
try {
|
|
143
|
-
let value = property.defaultValue?.replace(/^'(.*)'$/, "$1");
|
|
144
|
-
return value = castDefaultValue(property, value), value == null && property.jsdoctags?.length > 0 && (value = extractDefaultValueFromComments(property, value)), value;
|
|
145
|
-
} catch {
|
|
146
|
-
logger.debug(`Error extracting ${property.name}: ${property.defaultValue}`);
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
}, resolveTypealias = (compodocType) => {
|
|
150
|
-
let typeAlias = getCompodocJson()?.miscellaneous?.typealiases?.find((x) => x.name === compodocType);
|
|
151
|
-
return typeAlias ? resolveTypealias(typeAlias.rawtype) : compodocType;
|
|
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 = {
|
|
157
|
-
name: item.name,
|
|
158
|
-
description: item.rawdescription || item.description,
|
|
159
|
-
type,
|
|
160
|
-
...action,
|
|
161
|
-
table: {
|
|
162
|
-
category: section,
|
|
163
|
-
type: {
|
|
164
|
-
summary: isMethod(item) ? displaySignature(item) : item.type,
|
|
165
|
-
required: isMethod(item) ? !1 : !item.optional
|
|
166
|
-
},
|
|
167
|
-
defaultValue: { summary: defaultValue }
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
sectionToItems[section] || (sectionToItems[section] = []), sectionToItems[section].push(argType);
|
|
171
|
-
});
|
|
172
|
-
});
|
|
173
|
-
let SECTIONS = [
|
|
174
|
-
"properties",
|
|
175
|
-
"inputs",
|
|
176
|
-
"outputs",
|
|
177
|
-
"methods",
|
|
178
|
-
"view child",
|
|
179
|
-
"view children",
|
|
180
|
-
"content child",
|
|
181
|
-
"content children"
|
|
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);
|
|
191
|
-
return componentData && extractArgTypesFromData(componentData);
|
|
192
|
-
}, extractComponentDescription = (component) => {
|
|
193
|
-
let componentData = getComponentData(component);
|
|
194
|
-
return componentData && (componentData.rawdescription || componentData.description);
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
// src/client/config.ts
|
|
198
|
-
var parameters = {
|
|
199
|
-
renderer: "angular",
|
|
200
|
-
docs: {
|
|
201
|
-
story: { inline: !0 },
|
|
202
|
-
extractArgTypes,
|
|
203
|
-
extractComponentDescription
|
|
204
|
-
}
|
|
205
|
-
}, argTypesEnhancers = [enhanceArgTypes];
|
|
9
|
+
} from "../_browser-chunks/chunk-34GOABUT.js";
|
|
206
10
|
export {
|
|
207
11
|
decorateStory as applyDecorators,
|
|
208
12
|
argTypesEnhancers,
|