@storybook/angular-vite 10.6.0-alpha.5 → 10.6.0-alpha.6
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-THKACJYB.js → chunk-BUNW7ROM.js} +5 -5
- package/dist/_browser-chunks/{chunk-XXAOQLNU.js → chunk-CHMLOECK.js} +88 -39
- package/dist/_browser-chunks/{chunk-6DVGZIOB.js → chunk-ECGMCGUZ.js} +78 -89
- package/dist/_browser-chunks/{chunk-GVH2OCSY.js → chunk-HBLYOJ22.js} +3 -3
- package/dist/_node-chunks/chunk-5LXEVSHB.js +35 -0
- package/dist/_node-chunks/{chunk-35U7AODH.js → chunk-6P3TQP4W.js} +7 -7
- package/dist/_node-chunks/{chunk-RC6UIUJ4.js → chunk-ORVVXDOZ.js} +6 -6
- package/dist/builders/build-storybook/index.js +8 -8
- package/dist/builders/start-storybook/index.js +8 -8
- package/dist/client/config.js +2 -2
- package/dist/client/docs/config.js +2 -2
- package/dist/client/index.js +4 -4
- package/dist/docgen/docgen-worker.js +1039 -554
- package/dist/index.js +4 -4
- package/dist/node/index.js +6 -6
- package/dist/node/vitest.js +6 -6
- package/dist/preset.js +506 -27
- package/package.json +5 -4
- package/dist/_node-chunks/chunk-77BJXJPD.js +0 -195
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export,
|
|
3
3
|
computesTemplateSourceFromComponent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ECGMCGUZ.js";
|
|
5
5
|
|
|
6
6
|
// src/client/docs/config.ts
|
|
7
7
|
var config_exports = {};
|
|
@@ -22,20 +22,20 @@ var skipSourceRender = (context) => {
|
|
|
22
22
|
return useEffect(() => {
|
|
23
23
|
if (skipSourceRender(context))
|
|
24
24
|
return;
|
|
25
|
-
let { props, userDefinedTemplate } = story, { component,
|
|
25
|
+
let { props, userDefinedTemplate } = story, { component, parameters: parameters2 } = context, template = parameters2.docs?.source?.excludeDecorators ? context.originalStoryFn(context.args, context).template : story.template;
|
|
26
26
|
if (component && !userDefinedTemplate) {
|
|
27
|
-
let newSource = computesTemplateSourceFromComponent(component, props
|
|
27
|
+
let newSource = computesTemplateSourceFromComponent(component, props) || template;
|
|
28
28
|
newSource && newSource !== source.current && (emitTransformCode(newSource, context), source.current = newSource);
|
|
29
29
|
} else template && template !== source.current && (emitTransformCode(template, context), source.current = template);
|
|
30
30
|
}), story;
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
// src/client/docs/config.ts
|
|
34
|
-
var parameters = {
|
|
34
|
+
var language = globalThis.FEATURES?.experimentalDocgenServer ? "ts" : "html", parameters = {
|
|
35
35
|
docs: {
|
|
36
36
|
source: {
|
|
37
37
|
type: SourceType2.DYNAMIC,
|
|
38
|
-
language
|
|
38
|
+
language
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
}, decorators = [sourceDecorator];
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
getComponentInputsOutputs,
|
|
5
5
|
render,
|
|
6
6
|
renderToCanvas
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-ECGMCGUZ.js";
|
|
8
8
|
|
|
9
9
|
// src/client/config.ts
|
|
10
10
|
var config_exports = {};
|
|
@@ -422,13 +422,23 @@ var EncodingMode;
|
|
|
422
422
|
EncodingMode2[EncodingMode2.UTF8 = 0] = "UTF8", EncodingMode2[EncodingMode2.ASCII = 1] = "ASCII", EncodingMode2[EncodingMode2.Extensive = 2] = "Extensive", EncodingMode2[EncodingMode2.Attribute = 3] = "Attribute", EncodingMode2[EncodingMode2.Text = 4] = "Text";
|
|
423
423
|
})(EncodingMode || (EncodingMode = {}));
|
|
424
424
|
|
|
425
|
-
// ../../lib/angular-compodoc/dist/_browser-chunks/chunk-
|
|
425
|
+
// ../../lib/angular-compodoc/dist/_browser-chunks/chunk-Q5BEVNMG.js
|
|
426
426
|
var NOOP_LOGGER = {
|
|
427
427
|
warn: () => {
|
|
428
428
|
},
|
|
429
429
|
debug: () => {
|
|
430
430
|
}
|
|
431
|
-
}
|
|
431
|
+
};
|
|
432
|
+
var SECTION_ORDER = [
|
|
433
|
+
"properties",
|
|
434
|
+
"inputs",
|
|
435
|
+
"outputs",
|
|
436
|
+
"methods",
|
|
437
|
+
"view child",
|
|
438
|
+
"view children",
|
|
439
|
+
"content child",
|
|
440
|
+
"content children"
|
|
441
|
+
], isMethod = (methodOrProp) => methodOrProp.args !== void 0, isRequired = (item) => (item.required ?? !0) && !item.optional, checkValidComponentOrDirective = (component) => {
|
|
432
442
|
if (!component.name)
|
|
433
443
|
throw new Error(`Invalid component ${JSON.stringify(component)}`);
|
|
434
444
|
}, checkValidCompodocJson = (compodocJson) => {
|
|
@@ -462,17 +472,20 @@ var NOOP_LOGGER = {
|
|
|
462
472
|
).join(", ")}) => ${item.returnType}`, extractTypeFromValue = (defaultValue) => {
|
|
463
473
|
let valueType = typeof defaultValue;
|
|
464
474
|
return defaultValue || valueType === "number" || valueType === "boolean" || valueType === "string" ? valueType : null;
|
|
465
|
-
}, pickDeclaration = (candidates, componentFile) => candidates.length <= 1 ? candidates[0] : (componentFile ? candidates.find((candidate) => candidate.file === componentFile) : void 0) ?? [...candidates].sort((a, b) => (a.file ?? "").localeCompare(b.file ?? ""))[0], extractEnumValues = (compodocType, compodocJson, componentFile) => {
|
|
466
|
-
let
|
|
475
|
+
}, pickDeclaration = (candidates, componentFile) => candidates.length <= 1 ? candidates[0] : (componentFile ? candidates.find((candidate) => candidate.file === componentFile) : void 0) ?? [...candidates].sort((a, b) => (a.file ?? "").localeCompare(b.file ?? ""))[0], selectableUnionMembers = (type) => type.split("|").map((member) => member.trim()).filter((member) => member !== "undefined" && member !== "null"), hasEnumValue = (child) => !!child.value, extractEnumValues = (compodocType, compodocJson, componentFile, modern = !1) => {
|
|
476
|
+
let childs = pickDeclaration(
|
|
467
477
|
compodocJson?.miscellaneous?.enumerations?.filter((x) => x.name === compodocType) ?? [],
|
|
468
478
|
componentFile
|
|
469
|
-
);
|
|
470
|
-
if (Array.isArray(
|
|
471
|
-
return
|
|
479
|
+
)?.childs;
|
|
480
|
+
if (Array.isArray(childs) && childs.every(hasEnumValue))
|
|
481
|
+
return childs.map((child) => child.value);
|
|
472
482
|
if (typeof compodocType != "string" || compodocType.indexOf("|") === -1)
|
|
473
483
|
return null;
|
|
484
|
+
let selectable = modern ? selectableUnionMembers(compodocType) : compodocType.split("|").map((value) => value.trim());
|
|
485
|
+
if (selectable.length === 0)
|
|
486
|
+
return null;
|
|
474
487
|
try {
|
|
475
|
-
return
|
|
488
|
+
return selectable.map((value) => JSON.parse(value));
|
|
476
489
|
} catch {
|
|
477
490
|
return null;
|
|
478
491
|
}
|
|
@@ -484,7 +497,7 @@ var NOOP_LOGGER = {
|
|
|
484
497
|
componentFile
|
|
485
498
|
);
|
|
486
499
|
return typeAlias ? (seen.add(compodocType), resolveTypealias(typeAlias.rawtype, compodocJson, componentFile, seen)) : compodocType;
|
|
487
|
-
}, extractType = (property, defaultValue, compodocJson, componentFile) => {
|
|
500
|
+
}, isFunctionTypeString = (compodocType) => compodocType === "function" || /^\(.*\)\s*=>/.test(compodocType), extractType = (property, defaultValue, compodocJson, componentFile, modern = !1) => {
|
|
488
501
|
let compodocType = property.type || extractTypeFromValue(defaultValue);
|
|
489
502
|
switch (compodocType) {
|
|
490
503
|
case "string":
|
|
@@ -494,7 +507,15 @@ var NOOP_LOGGER = {
|
|
|
494
507
|
case null:
|
|
495
508
|
return { name: "other", value: "void" };
|
|
496
509
|
default: {
|
|
497
|
-
|
|
510
|
+
if (modern && typeof compodocType == "string" && isFunctionTypeString(compodocType))
|
|
511
|
+
return { name: "function" };
|
|
512
|
+
let resolvedType = resolveTypealias(compodocType, compodocJson, componentFile);
|
|
513
|
+
if (modern && typeof resolvedType == "string" && resolvedType.indexOf("|") !== -1) {
|
|
514
|
+
let members = [...new Set(selectableUnionMembers(resolvedType))];
|
|
515
|
+
if (members.length === 1 && ["string", "boolean", "number"].includes(members[0]))
|
|
516
|
+
return { name: members[0] };
|
|
517
|
+
}
|
|
518
|
+
let enumValues = extractEnumValues(resolvedType, compodocJson, componentFile, modern);
|
|
498
519
|
return enumValues ? { name: "enum", value: enumValues } : { name: "other", value: "empty-enum" };
|
|
499
520
|
}
|
|
500
521
|
}
|
|
@@ -524,44 +545,84 @@ var NOOP_LOGGER = {
|
|
|
524
545
|
default:
|
|
525
546
|
return defaultValue;
|
|
526
547
|
}
|
|
527
|
-
},
|
|
548
|
+
}, castDefaultValueModern = (property, defaultValue) => {
|
|
549
|
+
if (defaultValue !== void 0)
|
|
550
|
+
switch (property.type) {
|
|
551
|
+
case "boolean":
|
|
552
|
+
return defaultValue === "true" || defaultValue === "false" ? defaultValue === "true" : defaultValue;
|
|
553
|
+
case "number": {
|
|
554
|
+
let parsed = Number(defaultValue);
|
|
555
|
+
return Number.isNaN(parsed) && defaultValue !== "NaN" ? defaultValue : parsed;
|
|
556
|
+
}
|
|
557
|
+
case "EventEmitter":
|
|
558
|
+
return;
|
|
559
|
+
case "string":
|
|
560
|
+
return defaultValue;
|
|
561
|
+
default:
|
|
562
|
+
return castDefaultValue(property, defaultValue);
|
|
563
|
+
}
|
|
564
|
+
}, extractDefaultValueFromComments = (property, value, unwrapHtml2, modern) => {
|
|
528
565
|
let commentValue = value;
|
|
529
566
|
return property.jsdoctags.forEach((tag) => {
|
|
530
567
|
let tagName = tag.tagName.escapedText;
|
|
531
|
-
(tagName === "default" || tagName === "defaultvalue")
|
|
568
|
+
if (tagName === "default" || tagName === "defaultvalue") {
|
|
569
|
+
if (modern) {
|
|
570
|
+
tag.comment !== void 0 && (commentValue = unquote(unwrapHtml2(tag.comment).trim()));
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
commentValue = unwrapHtml2(tag.comment);
|
|
574
|
+
}
|
|
532
575
|
}), commentValue;
|
|
533
|
-
}, extractDefaultValue = (property, logger2, unwrapHtml2) => {
|
|
576
|
+
}, unquote = (value) => value.replace(/^'(.*)'$/, "$1").replace(/^"(.*)"$/, "$1"), extractDefaultValue = (property, logger2, unwrapHtml2, modern) => {
|
|
534
577
|
try {
|
|
535
578
|
let value = property.defaultValue?.replace(/^'(.*)'$/, "$1");
|
|
536
|
-
return value = castDefaultValue(property, value), value == null && (property.jsdoctags?.length ?? 0) > 0 && (value = extractDefaultValueFromComments(property, value, unwrapHtml2)), value;
|
|
579
|
+
return value = modern ? castDefaultValueModern(property, value) : castDefaultValue(property, value), value == null && (property.jsdoctags?.length ?? 0) > 0 && (value = extractDefaultValueFromComments(property, value, unwrapHtml2, modern)), value;
|
|
537
580
|
} catch {
|
|
538
581
|
logger2.debug(`Error extracting ${property.name}: ${property.defaultValue}`);
|
|
539
582
|
return;
|
|
540
583
|
}
|
|
541
|
-
},
|
|
542
|
-
let
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
584
|
+
}, extractMemberJsDocTags = (member, unwrapHtml2) => {
|
|
585
|
+
let deprecated, returns;
|
|
586
|
+
for (let tag of member.jsdoctags ?? []) {
|
|
587
|
+
let tagName = tag.tagName?.escapedText;
|
|
588
|
+
tagName === "deprecated" ? deprecated = tag.comment === void 0 ? "" : unwrapHtml2(tag.comment).trim() : (tagName === "returns" || tagName === "return") && tag.comment !== void 0 && (returns = { description: unwrapHtml2(tag.comment).trim() });
|
|
589
|
+
}
|
|
590
|
+
if (!(deprecated === void 0 && returns === void 0))
|
|
591
|
+
return {
|
|
592
|
+
...deprecated !== void 0 ? { deprecated } : {},
|
|
593
|
+
...returns !== void 0 ? { returns } : {}
|
|
594
|
+
};
|
|
595
|
+
}, readMembers = (componentData, key) => componentData[key] || [], isDirectiveEntry = (componentData) => componentData.type === "component" || componentData.type === "directive", getModelProperties = (componentData) => {
|
|
596
|
+
if (!isDirectiveEntry(componentData))
|
|
597
|
+
return [];
|
|
598
|
+
let inputsByName = new Map(componentData.inputsClass.map((item) => [item.name, item]));
|
|
599
|
+
return componentData.outputsClass.filter((item) => {
|
|
546
600
|
let input = inputsByName.get(item.name);
|
|
547
601
|
return input?.line !== void 0 && input.line === item.line;
|
|
548
602
|
});
|
|
549
|
-
}, extractArgTypesFromData = (componentData, {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
603
|
+
}, extractArgTypesFromData = (componentData, {
|
|
604
|
+
compodocJson,
|
|
605
|
+
filterNonInputControls,
|
|
606
|
+
logger: logger2 = NOOP_LOGGER,
|
|
607
|
+
unwrapHtml: unwrapHtml2,
|
|
608
|
+
modern = !1
|
|
609
|
+
}) => {
|
|
610
|
+
let sectionToItems = {}, componentClasses = filterNonInputControls ? ["inputsClass"] : ["propertiesClass", "methodsClass", "inputsClass", "outputsClass"], compodocClasses = isDirectiveEntry(componentData) ? componentClasses : ["properties", "methods"], modelProperties = getModelProperties(componentData), modelPropertyNames = new Set(modelProperties.map((item) => item.name));
|
|
553
611
|
compodocClasses.forEach((key) => {
|
|
554
612
|
readMembers(componentData, key).forEach((item) => {
|
|
613
|
+
if (modern && item.name.startsWith("#"))
|
|
614
|
+
return;
|
|
555
615
|
let section = mapItemToSection(key, item);
|
|
556
616
|
if (key === "outputsClass" && !isMethod(item) && modelPropertyNames.has(item.name))
|
|
557
617
|
return;
|
|
558
|
-
let defaultValue = isMethod(item) ? void 0 : extractDefaultValue(item, logger2, unwrapHtml2), type = isMethod(item) || section !== "inputs" && section !== "properties" ? { name: "other", value: "void" } : extractType(item, defaultValue, compodocJson, componentData.file), action = section === "outputs" ? { action: item.name } : {}, argType = {
|
|
618
|
+
let defaultValue = isMethod(item) ? void 0 : extractDefaultValue(item, logger2, unwrapHtml2, modern), type = isMethod(item) || section !== "inputs" && section !== "properties" ? { name: "other", value: "void" } : extractType(item, defaultValue, compodocJson, componentData.file, modern), action = section === "outputs" ? { action: item.name } : {}, jsDocTags = modern ? extractMemberJsDocTags(item, unwrapHtml2) : void 0, argType = {
|
|
559
619
|
name: item.name,
|
|
560
620
|
description: item.rawdescription || item.description,
|
|
561
621
|
type,
|
|
562
622
|
...action,
|
|
563
623
|
table: {
|
|
564
624
|
category: section,
|
|
625
|
+
...jsDocTags !== void 0 ? { jsDocTags } : {},
|
|
565
626
|
type: {
|
|
566
627
|
summary: isMethod(item) ? displaySignature(item) : item.type,
|
|
567
628
|
required: isMethod(item) ? !1 : isRequired(item)
|
|
@@ -581,26 +642,14 @@ var NOOP_LOGGER = {
|
|
|
581
642
|
category: "outputs",
|
|
582
643
|
type: {
|
|
583
644
|
summary: `(e: ${item.type}) => void`,
|
|
584
|
-
// An output is never required to bind, and a real output says so via Compodoc's own
|
|
585
|
-
// flag. This one is synthesized, so it has to say so itself rather than inheriting the
|
|
586
|
-
// requiredness of the model input it derives from.
|
|
587
645
|
required: !1
|
|
588
646
|
}
|
|
589
647
|
}
|
|
590
648
|
};
|
|
591
649
|
sectionToItems.outputs || (sectionToItems.outputs = []), sectionToItems.outputs.push(argType);
|
|
592
650
|
});
|
|
593
|
-
let
|
|
594
|
-
|
|
595
|
-
"inputs",
|
|
596
|
-
"outputs",
|
|
597
|
-
"methods",
|
|
598
|
-
"view child",
|
|
599
|
-
"view children",
|
|
600
|
-
"content child",
|
|
601
|
-
"content children"
|
|
602
|
-
], argTypes = {};
|
|
603
|
-
return SECTIONS.forEach((section) => {
|
|
651
|
+
let argTypes = {};
|
|
652
|
+
return SECTION_ORDER.forEach((section) => {
|
|
604
653
|
let items = sectionToItems[section];
|
|
605
654
|
items && items.forEach((argType) => {
|
|
606
655
|
argTypes[argType.name] = argType;
|
|
@@ -25,6 +25,67 @@ import { bootstrapApplication } from "@angular/platform-browser";
|
|
|
25
25
|
import { BehaviorSubject } from "rxjs";
|
|
26
26
|
import { stringify } from "telejson";
|
|
27
27
|
|
|
28
|
+
// src/template-grammar.ts
|
|
29
|
+
var isValidIdentifier = (name) => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name), formatPropInTemplate = (propertyName) => isValidIdentifier(propertyName) ? propertyName : `this['${propertyName}']`, stringifyCircular = (obj) => {
|
|
30
|
+
let seen = /* @__PURE__ */ new Set();
|
|
31
|
+
return JSON.stringify(obj, (key, value) => {
|
|
32
|
+
if (typeof value == "object" && value !== null) {
|
|
33
|
+
if (seen.has(value))
|
|
34
|
+
return "[Circular]";
|
|
35
|
+
seen.add(value);
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
});
|
|
39
|
+
}, singleQuoted = (text) => `'${JSON.stringify(text).slice(1, -1).replace(/\\"/g, '"').replace(/'/g, "\\'").replace(/"/g, """)}'`, formatJsonValue = (value) => typeof value == "string" ? singleQuoted(value) : Array.isArray(value) ? `[${value.map(formatJsonValue).join(", ")}]` : value !== null && typeof value == "object" ? `{${Object.entries(value).map(
|
|
40
|
+
([key, item]) => `${isValidIdentifier(key) ? key : singleQuoted(key)}: ${formatJsonValue(item)}`
|
|
41
|
+
).join(", ")}}` : String(value), formatInputValue = (value) => {
|
|
42
|
+
switch (typeof value) {
|
|
43
|
+
case "string":
|
|
44
|
+
return singleQuoted(value);
|
|
45
|
+
case "object":
|
|
46
|
+
return formatJsonValue(JSON.parse(stringifyCircular(value)));
|
|
47
|
+
default:
|
|
48
|
+
return `${value}`;
|
|
49
|
+
}
|
|
50
|
+
}, VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
51
|
+
"area",
|
|
52
|
+
"base",
|
|
53
|
+
"br",
|
|
54
|
+
"col",
|
|
55
|
+
"command",
|
|
56
|
+
"embed",
|
|
57
|
+
"hr",
|
|
58
|
+
"img",
|
|
59
|
+
"input",
|
|
60
|
+
"keygen",
|
|
61
|
+
"link",
|
|
62
|
+
"meta",
|
|
63
|
+
"param",
|
|
64
|
+
"source",
|
|
65
|
+
"track",
|
|
66
|
+
"wbr"
|
|
67
|
+
]), LEADING_CLASS = /^\..+/, LEADING_ATTRIBUTE = /^\[.+?]/, ID = /#([\w-]+)/, CLASS_RUN = /(\.[\w-]+)+/, ATTRIBUTE = /\[(.+?)]/g, ELEMENT_AND_ATTRIBUTES = /(\S+)(.*)/, MAX_SINGLE_LINE = 80, buildTemplate = (selector, { inputs, outputs, innerTemplate = "" }) => {
|
|
68
|
+
let bindings = [
|
|
69
|
+
...inputs.map(({ name, expression }) => `[${name}]="${expression}"`),
|
|
70
|
+
...outputs.map((name) => `(${name})="${formatPropInTemplate(name)}($event)"`)
|
|
71
|
+
], firstSelector = selector.split(",")[0];
|
|
72
|
+
return (LEADING_CLASS.test(firstSelector) || LEADING_ATTRIBUTE.test(firstSelector) ? `div${firstSelector}` : firstSelector).replace(ID, ' id="$1"').replace(CLASS_RUN, (classes) => ` class="${classes.split(".").join(" ").trim()}"`).replace(ATTRIBUTE, " $1").replace(ELEMENT_AND_ATTRIBUTES, (_, element, attributes) => {
|
|
73
|
+
let inlineTag = `<${element}${attributes}${bindings.map((binding) => ` ${binding}`).join("")}`, inline = VOID_ELEMENTS.has(element) ? `${inlineTag} />` : `${inlineTag}>${innerTemplate}</${element}>`;
|
|
74
|
+
if (inline.length <= MAX_SINGLE_LINE || bindings.length === 0)
|
|
75
|
+
return inline;
|
|
76
|
+
let brokenTag = `<${element}${attributes}
|
|
77
|
+
${bindings.map((binding) => ` ${binding}`).join(`
|
|
78
|
+
`)}`;
|
|
79
|
+
if (VOID_ELEMENTS.has(element))
|
|
80
|
+
return `${brokenTag} />`;
|
|
81
|
+
let content = innerTemplate === "" ? `
|
|
82
|
+
` : `
|
|
83
|
+
${innerTemplate}
|
|
84
|
+
`;
|
|
85
|
+
return `${brokenTag}>${content}</${element}>`;
|
|
86
|
+
});
|
|
87
|
+
}, buildComponentOutletTemplate = (componentName) => `<ng-container *ngComponentOutlet="${componentName}"></ng-container>`;
|
|
88
|
+
|
|
28
89
|
// src/client/renderer/utils/NgComponentAnalyzer.ts
|
|
29
90
|
import {
|
|
30
91
|
Component,
|
|
@@ -103,108 +164,36 @@ var isComponent = (component) => component ? (reflectionCapabilities.annotations
|
|
|
103
164
|
var getComponentPropsDecoratorMetadata = (component) => reflectionCapabilities.propMetadata(component), getComponentDecoratorMetadata = (component) => reflectionCapabilities.annotations(component).reverse().find((d) => d instanceof Component);
|
|
104
165
|
|
|
105
166
|
// src/client/renderer/ComputesTemplateFromComponent.ts
|
|
106
|
-
var
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
outputs,
|
|
111
|
-
otherProps: Object.keys(props).filter((k) => ![...inputs, ...outputs].includes(k))
|
|
112
|
-
};
|
|
113
|
-
}, computesTemplateFromComponent = (component, initialProps, innerTemplate = "") => {
|
|
167
|
+
var separateInputsOutputsAttributes = (ngComponentInputsOutputs, props = {}) => ({
|
|
168
|
+
inputs: ngComponentInputsOutputs.inputs.filter((i) => i.templateName in props).map((i) => i.templateName),
|
|
169
|
+
outputs: ngComponentInputsOutputs.outputs.filter((o) => o.templateName in props).map((o) => o.templateName)
|
|
170
|
+
}), computesTemplateFromComponent = (component, initialProps, innerTemplate = "") => {
|
|
114
171
|
let ngComponentMetadata = getComponentDecoratorMetadata(component), ngComponentInputsOutputs = getComponentInputsOutputs(component);
|
|
115
172
|
if (!ngComponentMetadata.selector)
|
|
116
173
|
return '<ng-container *ngComponentOutlet="storyComponent"></ng-container>';
|
|
117
|
-
let { inputs
|
|
174
|
+
let { inputs, outputs } = separateInputsOutputsAttributes(
|
|
118
175
|
ngComponentInputsOutputs,
|
|
119
176
|
initialProps
|
|
120
|
-
), templateInputs = initialInputs.length > 0 ? ` ${initialInputs.map((i) => `[${i}]="${formatPropInTemplate(i)}"`).join(" ")}` : "", templateOutputs = initialOutputs.length > 0 ? ` ${initialOutputs.map((i) => `(${i})="${formatPropInTemplate(i)}($event)"`).join(" ")}` : "";
|
|
121
|
-
return buildTemplate(
|
|
122
|
-
ngComponentMetadata.selector,
|
|
123
|
-
innerTemplate,
|
|
124
|
-
templateInputs,
|
|
125
|
-
templateOutputs
|
|
126
177
|
);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (typeof value == "object" && value !== null) {
|
|
132
|
-
if (seen.has(value))
|
|
133
|
-
return "[Circular]";
|
|
134
|
-
seen.add(value);
|
|
135
|
-
}
|
|
136
|
-
return value;
|
|
178
|
+
return buildTemplate(ngComponentMetadata.selector, {
|
|
179
|
+
inputs: inputs.map((name) => ({ name, expression: formatPropInTemplate(name) })),
|
|
180
|
+
outputs,
|
|
181
|
+
innerTemplate
|
|
137
182
|
});
|
|
138
|
-
}
|
|
139
|
-
var createAngularInputProperty = ({
|
|
140
|
-
propertyName,
|
|
141
|
-
value,
|
|
142
|
-
argType
|
|
143
|
-
}) => {
|
|
144
|
-
let templateValue;
|
|
145
|
-
switch (typeof value) {
|
|
146
|
-
case "string":
|
|
147
|
-
templateValue = `'${value}'`;
|
|
148
|
-
break;
|
|
149
|
-
case "object":
|
|
150
|
-
templateValue = stringifyCircular(value).replace(/'/g, "\u2019").replace(/\\"/g, "\u201D").replace(/"([^-"]+)":/g, "$1: ").replace(/"/g, "'").replace(/\u2019/g, "\\'").replace(/\u201D/g, "\\'").split(",").join(", ");
|
|
151
|
-
break;
|
|
152
|
-
default:
|
|
153
|
-
templateValue = value;
|
|
154
|
-
}
|
|
155
|
-
return `[${propertyName}]="${templateValue}"`;
|
|
156
|
-
}, computesTemplateSourceFromComponent = (component, initialProps, argTypes) => {
|
|
183
|
+
}, computesTemplateSourceFromComponent = (component, initialProps) => {
|
|
157
184
|
let ngComponentMetadata = getComponentDecoratorMetadata(component);
|
|
158
185
|
if (!ngComponentMetadata)
|
|
159
186
|
return null;
|
|
160
187
|
if (!ngComponentMetadata.selector)
|
|
161
|
-
return
|
|
162
|
-
let ngComponentInputsOutputs = getComponentInputsOutputs(component), { inputs
|
|
188
|
+
return buildComponentOutletTemplate(component.name);
|
|
189
|
+
let ngComponentInputsOutputs = getComponentInputsOutputs(component), { inputs, outputs } = separateInputsOutputsAttributes(
|
|
163
190
|
ngComponentInputsOutputs,
|
|
164
191
|
initialProps
|
|
165
|
-
), templateInputs = initialInputs.length > 0 ? ` ${initialInputs.map(
|
|
166
|
-
(propertyName) => createAngularInputProperty({
|
|
167
|
-
propertyName,
|
|
168
|
-
value: initialProps[propertyName],
|
|
169
|
-
argType: argTypes?.[propertyName]
|
|
170
|
-
})
|
|
171
|
-
).join(" ")}` : "", templateOutputs = initialOutputs.length > 0 ? ` ${initialOutputs.map((i) => `(${i})="${formatPropInTemplate(i)}($event)"`).join(" ")}` : "";
|
|
172
|
-
return buildTemplate(ngComponentMetadata.selector, "", templateInputs, templateOutputs);
|
|
173
|
-
}, buildTemplate = (selector, innerTemplate, inputs, outputs) => {
|
|
174
|
-
let voidElements = [
|
|
175
|
-
"area",
|
|
176
|
-
"base",
|
|
177
|
-
"br",
|
|
178
|
-
"col",
|
|
179
|
-
"command",
|
|
180
|
-
"embed",
|
|
181
|
-
"hr",
|
|
182
|
-
"img",
|
|
183
|
-
"input",
|
|
184
|
-
"keygen",
|
|
185
|
-
"link",
|
|
186
|
-
"meta",
|
|
187
|
-
"param",
|
|
188
|
-
"source",
|
|
189
|
-
"track",
|
|
190
|
-
"wbr"
|
|
191
|
-
], firstSelector = selector.split(",")[0];
|
|
192
|
-
return [
|
|
193
|
-
[/(^.*?)(?=[,])/, "$1"],
|
|
194
|
-
[/(^\..+)/, "div$1"],
|
|
195
|
-
[/(^\[.+?])/, "div$1"],
|
|
196
|
-
[/([\w[\]]+)(\s*,[\w\s-[\],]+)+/, "$1"],
|
|
197
|
-
[/#([\w-]+)/, ' id="$1"'],
|
|
198
|
-
[/((\.[\w-]+)+)/, (_, c) => ` class="${c.split`.`.join` `.trim()}"`],
|
|
199
|
-
[/(\[.+?])/g, (_, a) => ` ${a.slice(1, -1)}`],
|
|
200
|
-
[
|
|
201
|
-
/([\S]+)(.*)/,
|
|
202
|
-
(template, elementSelector) => voidElements.some((element) => elementSelector === element) ? template.replace(/([\S]+)(.*)/, `<$1$2${inputs}${outputs} />`) : template.replace(/([\S]+)(.*)/, `<$1$2${inputs}${outputs}>${innerTemplate}</$1>`)
|
|
203
|
-
]
|
|
204
|
-
].reduce(
|
|
205
|
-
(prevSelector, [searchValue, replacer]) => prevSelector.replace(searchValue, replacer),
|
|
206
|
-
firstSelector
|
|
207
192
|
);
|
|
193
|
+
return buildTemplate(ngComponentMetadata.selector, {
|
|
194
|
+
inputs: inputs.map((name) => ({ name, expression: formatInputValue(initialProps?.[name]) })),
|
|
195
|
+
outputs
|
|
196
|
+
});
|
|
208
197
|
};
|
|
209
198
|
|
|
210
199
|
// src/client/renderer/StorybookWrapperComponent.ts
|
|
@@ -713,9 +702,9 @@ async function renderToCanvas({
|
|
|
713
702
|
|
|
714
703
|
export {
|
|
715
704
|
__export,
|
|
705
|
+
formatPropInTemplate,
|
|
716
706
|
getComponentInputsOutputs,
|
|
717
707
|
isComponent,
|
|
718
|
-
formatPropInTemplate,
|
|
719
708
|
computesTemplateFromComponent,
|
|
720
709
|
computesTemplateSourceFromComponent,
|
|
721
710
|
render,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-CHMLOECK.js";
|
|
4
4
|
import {
|
|
5
5
|
config_exports as config_exports2
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BUNW7ROM.js";
|
|
7
7
|
import {
|
|
8
8
|
computesTemplateFromComponent,
|
|
9
9
|
formatPropInTemplate,
|
|
10
10
|
isComponent,
|
|
11
11
|
render_exports
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-ECGMCGUZ.js";
|
|
13
13
|
|
|
14
14
|
// src/client/portable-stories.ts
|
|
15
15
|
import {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ze1vib595n from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ze1vib595n from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ze1vib595n from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ze1vib595n.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ze1vib595n.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ze1vib595n.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
|
|
13
|
+
// src/docgen/resolve-component.ts
|
|
14
|
+
import { createMetaComponentResolver } from "storybook/internal/common";
|
|
15
|
+
import { loadCsf } from "storybook/internal/csf-tools";
|
|
16
|
+
import { readFileSync } from "node:fs";
|
|
17
|
+
var resolveMetaComponent = createMetaComponentResolver();
|
|
18
|
+
function parseStoryFile(storyFilePath, title) {
|
|
19
|
+
try {
|
|
20
|
+
let source = readFileSync(storyFilePath, "utf8").replace(/\r\n/g, `
|
|
21
|
+
`);
|
|
22
|
+
return { source, csf: loadCsf(source, { makeTitle: () => title }).parse() };
|
|
23
|
+
} catch {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function resolveStoryComponent(storyFilePath, title = "Docgen") {
|
|
28
|
+
let parsed = parseStoryFile(storyFilePath, title);
|
|
29
|
+
return parsed ? resolveMetaComponent(parsed.csf, storyFilePath) : { reason: "no-meta-component" };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
parseStoryFile,
|
|
34
|
+
resolveStoryComponent
|
|
35
|
+
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ze1vib595n from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ze1vib595n from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ze1vib595n from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ze1vib595n.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ze1vib595n.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ze1vib595n.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-ORVVXDOZ.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_ze1vib595n from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ze1vib595n from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ze1vib595n from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ze1vib595n.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ze1vib595n.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ze1vib595n.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ze1vib595n from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ze1vib595n from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ze1vib595n from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ze1vib595n.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ze1vib595n.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ze1vib595n.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
errorSummary,
|
|
14
14
|
printErrorDetails,
|
|
15
15
|
up
|
|
16
|
-
} from "../../_node-chunks/chunk-
|
|
16
|
+
} from "../../_node-chunks/chunk-6P3TQP4W.js";
|
|
17
17
|
import {
|
|
18
18
|
findTsconfigUp
|
|
19
|
-
} from "../../_node-chunks/chunk-
|
|
19
|
+
} from "../../_node-chunks/chunk-ORVVXDOZ.js";
|
|
20
20
|
|
|
21
21
|
// src/builders/build-storybook/index.ts
|
|
22
22
|
import { readFileSync } from "node:fs";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_ze1vib595n from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_ze1vib595n from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_ze1vib595n from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_ze1vib595n.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_ze1vib595n.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_ze1vib595n.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
errorSummary,
|
|
14
14
|
printErrorDetails,
|
|
15
15
|
up
|
|
16
|
-
} from "../../_node-chunks/chunk-
|
|
16
|
+
} from "../../_node-chunks/chunk-6P3TQP4W.js";
|
|
17
17
|
import {
|
|
18
18
|
findTsconfigUp
|
|
19
|
-
} from "../../_node-chunks/chunk-
|
|
19
|
+
} from "../../_node-chunks/chunk-ORVVXDOZ.js";
|
|
20
20
|
|
|
21
21
|
// src/builders/start-storybook/index.ts
|
|
22
22
|
import { readFileSync } from "node:fs";
|
package/dist/client/config.js
CHANGED
|
@@ -2,11 +2,11 @@ import {
|
|
|
2
2
|
argTypesEnhancers,
|
|
3
3
|
decorateStory,
|
|
4
4
|
parameters
|
|
5
|
-
} from "../_browser-chunks/chunk-
|
|
5
|
+
} from "../_browser-chunks/chunk-CHMLOECK.js";
|
|
6
6
|
import {
|
|
7
7
|
render,
|
|
8
8
|
renderToCanvas
|
|
9
|
-
} from "../_browser-chunks/chunk-
|
|
9
|
+
} from "../_browser-chunks/chunk-ECGMCGUZ.js";
|
|
10
10
|
export {
|
|
11
11
|
decorateStory as applyDecorators,
|
|
12
12
|
argTypesEnhancers,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
decorators,
|
|
3
3
|
parameters
|
|
4
|
-
} from "../../_browser-chunks/chunk-
|
|
5
|
-
import "../../_browser-chunks/chunk-
|
|
4
|
+
} from "../../_browser-chunks/chunk-BUNW7ROM.js";
|
|
5
|
+
import "../../_browser-chunks/chunk-ECGMCGUZ.js";
|
|
6
6
|
export {
|
|
7
7
|
decorators,
|
|
8
8
|
parameters
|