@storybook/angular-vite 10.6.0-alpha.5 → 10.6.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-schema.json +33 -5
- package/dist/_browser-chunks/{chunk-XXAOQLNU.js → chunk-AL7GEPYM.js} +98 -60
- package/dist/_browser-chunks/{chunk-GVH2OCSY.js → chunk-THQDNKQS.js} +3 -3
- package/dist/_browser-chunks/{chunk-6DVGZIOB.js → chunk-UJ3I56EP.js} +79 -90
- package/dist/_browser-chunks/{chunk-THKACJYB.js → chunk-VP3W5GY3.js} +6 -6
- package/dist/_node-chunks/chunk-GWJVWZ3H.js +42 -0
- package/dist/_node-chunks/{chunk-RC6UIUJ4.js → chunk-QNPJ2GGJ.js} +6 -6
- package/dist/_node-chunks/{chunk-35U7AODH.js → chunk-V7GJH7LA.js} +7 -7
- package/dist/_node-chunks/story-docs-template-analysis-6YH7XNRB.js +163 -0
- package/dist/builders/build-storybook/index.js +8 -8
- package/dist/builders/start-storybook/index.js +8 -8
- package/dist/chunk-Bv2XDHY-.d.ts +64 -0
- 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 +1526 -565
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -4
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.js +6 -6
- package/dist/node/vitest.js +6 -6
- package/dist/preset.js +1078 -46
- package/package.json +6 -5
- package/start-schema.json +33 -5
- package/dist/_node-chunks/chunk-77BJXJPD.js +0 -195
- package/dist/chunk-D8_SR6hI.d.ts +0 -31
package/build-schema.json
CHANGED
|
@@ -60,16 +60,16 @@
|
|
|
60
60
|
},
|
|
61
61
|
"compodoc": {
|
|
62
62
|
"type": "boolean",
|
|
63
|
-
"description": "
|
|
64
|
-
"
|
|
63
|
+
"description": "Deprecated. Compodoc no longer runs.",
|
|
64
|
+
"x-deprecated": "Compodoc no longer runs. @storybook/angular-vite extracts Angular metadata in-process, so this option does nothing. Remove it from angular.json."
|
|
65
65
|
},
|
|
66
66
|
"compodocArgs": {
|
|
67
67
|
"type": "array",
|
|
68
|
-
"description": "
|
|
69
|
-
"default": ["-e", "json"],
|
|
68
|
+
"description": "Deprecated. Compodoc no longer runs.",
|
|
70
69
|
"items": {
|
|
71
70
|
"type": "string"
|
|
72
|
-
}
|
|
71
|
+
},
|
|
72
|
+
"x-deprecated": "Compodoc no longer runs. @storybook/angular-vite extracts Angular metadata in-process, so this option does nothing. Remove it from angular.json."
|
|
73
73
|
},
|
|
74
74
|
"statsJson": {
|
|
75
75
|
"type": ["boolean", "string"],
|
|
@@ -104,6 +104,34 @@
|
|
|
104
104
|
"items": {
|
|
105
105
|
"type": "string"
|
|
106
106
|
}
|
|
107
|
+
},
|
|
108
|
+
"sass": {
|
|
109
|
+
"description": "Options to pass to the sass preprocessor.",
|
|
110
|
+
"type": "object",
|
|
111
|
+
"properties": {
|
|
112
|
+
"fatalDeprecations": {
|
|
113
|
+
"description": "A set of deprecations to treat as fatal. If a deprecation warning of any provided type is encountered during compilation, the compiler will error instead. If a Version is provided, then all deprecations that were active in that compiler version will be treated as fatal.",
|
|
114
|
+
"type": "array",
|
|
115
|
+
"items": {
|
|
116
|
+
"type": "string"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"silenceDeprecations": {
|
|
120
|
+
"description": "A set of active deprecations to ignore. If a deprecation warning of any provided type is encountered during compilation, the compiler will ignore it instead.",
|
|
121
|
+
"type": "array",
|
|
122
|
+
"items": {
|
|
123
|
+
"type": "string"
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
"futureDeprecations": {
|
|
127
|
+
"description": "A set of future deprecations to opt into early. Future deprecations passed here will be treated as active by the compiler, emitting warnings as necessary.",
|
|
128
|
+
"type": "array",
|
|
129
|
+
"items": {
|
|
130
|
+
"type": "string"
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
"additionalProperties": false
|
|
107
135
|
}
|
|
108
136
|
},
|
|
109
137
|
"additionalProperties": false
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export,
|
|
3
3
|
computesTemplateFromComponent,
|
|
4
|
-
getComponentInputsOutputs,
|
|
5
4
|
render,
|
|
6
5
|
renderToCanvas
|
|
7
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-UJ3I56EP.js";
|
|
8
7
|
|
|
9
8
|
// src/client/config.ts
|
|
10
9
|
var config_exports = {};
|
|
@@ -23,7 +22,7 @@ global.STORYBOOK_ENV = "angular";
|
|
|
23
22
|
// src/client/decorateStory.ts
|
|
24
23
|
import { sanitizeStoryContextUpdate } from "storybook/preview-api";
|
|
25
24
|
function decorateStory(mainStoryFn, decorators) {
|
|
26
|
-
return
|
|
25
|
+
return decorators.reduce(
|
|
27
26
|
(previousStoryFn, decorator) => (context) => decorator((update) => previousStoryFn({
|
|
28
27
|
...context,
|
|
29
28
|
...sanitizeStoryContextUpdate(update)
|
|
@@ -41,21 +40,10 @@ var prepareMain = (story, context) => {
|
|
|
41
40
|
function hasNoTemplate(template) {
|
|
42
41
|
return template == null;
|
|
43
42
|
}
|
|
44
|
-
var cleanArgsDecorator = (storyFn, context) => {
|
|
45
|
-
if (!context.argTypes || !context.args || Object.keys(context.argTypes).length === 0)
|
|
46
|
-
return storyFn();
|
|
47
|
-
let componentIO = context.component ? getComponentInputsOutputs(context.component) : { inputs: [], outputs: [] }, componentBindings = /* @__PURE__ */ new Set([
|
|
48
|
-
...componentIO.inputs.map((i) => i.templateName),
|
|
49
|
-
...componentIO.outputs.map((o) => o.templateName)
|
|
50
|
-
]), argsToClean = context.args;
|
|
51
|
-
return context.args = Object.entries(argsToClean).reduce((obj, [key, arg]) => {
|
|
52
|
-
let argType = context.argTypes[key];
|
|
53
|
-
return argType?.action || argType?.control || componentBindings.has(key) ? { ...obj, [key]: arg } : obj;
|
|
54
|
-
}, {}), storyFn();
|
|
55
|
-
};
|
|
56
43
|
|
|
57
44
|
// src/client/config.ts
|
|
58
45
|
import { enhanceArgTypes } from "storybook/internal/docs-tools";
|
|
46
|
+
import { global as global3 } from "@storybook/global";
|
|
59
47
|
|
|
60
48
|
// ../../../node_modules/entities/lib/esm/generated/decode-data-html.js
|
|
61
49
|
var decode_data_html_default = new Uint16Array(
|
|
@@ -422,13 +410,23 @@ var EncodingMode;
|
|
|
422
410
|
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
411
|
})(EncodingMode || (EncodingMode = {}));
|
|
424
412
|
|
|
425
|
-
// ../../lib/angular-compodoc/dist/_browser-chunks/chunk-
|
|
413
|
+
// ../../lib/angular-compodoc/dist/_browser-chunks/chunk-FMGKBLGO.js
|
|
426
414
|
var NOOP_LOGGER = {
|
|
427
415
|
warn: () => {
|
|
428
416
|
},
|
|
429
417
|
debug: () => {
|
|
430
418
|
}
|
|
431
|
-
}
|
|
419
|
+
};
|
|
420
|
+
var SECTION_ORDER = [
|
|
421
|
+
"properties",
|
|
422
|
+
"inputs",
|
|
423
|
+
"outputs",
|
|
424
|
+
"methods",
|
|
425
|
+
"view child",
|
|
426
|
+
"view children",
|
|
427
|
+
"content child",
|
|
428
|
+
"content children"
|
|
429
|
+
], isMethod = (methodOrProp) => methodOrProp.args !== void 0, isRequired = (item) => (item.required ?? !0) && !item.optional, checkValidComponentOrDirective = (component) => {
|
|
432
430
|
if (!component.name)
|
|
433
431
|
throw new Error(`Invalid component ${JSON.stringify(component)}`);
|
|
434
432
|
}, checkValidCompodocJson = (compodocJson) => {
|
|
@@ -462,17 +460,20 @@ var NOOP_LOGGER = {
|
|
|
462
460
|
).join(", ")}) => ${item.returnType}`, extractTypeFromValue = (defaultValue) => {
|
|
463
461
|
let valueType = typeof defaultValue;
|
|
464
462
|
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
|
|
463
|
+
}, 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) => {
|
|
464
|
+
let childs = pickDeclaration(
|
|
467
465
|
compodocJson?.miscellaneous?.enumerations?.filter((x) => x.name === compodocType) ?? [],
|
|
468
466
|
componentFile
|
|
469
|
-
);
|
|
470
|
-
if (Array.isArray(
|
|
471
|
-
return
|
|
467
|
+
)?.childs;
|
|
468
|
+
if (Array.isArray(childs) && childs.every(hasEnumValue))
|
|
469
|
+
return childs.map((child) => child.value);
|
|
472
470
|
if (typeof compodocType != "string" || compodocType.indexOf("|") === -1)
|
|
473
471
|
return null;
|
|
472
|
+
let selectable = modern ? selectableUnionMembers(compodocType) : compodocType.split("|").map((value) => value.trim());
|
|
473
|
+
if (selectable.length === 0)
|
|
474
|
+
return null;
|
|
474
475
|
try {
|
|
475
|
-
return
|
|
476
|
+
return selectable.map((value) => JSON.parse(value));
|
|
476
477
|
} catch {
|
|
477
478
|
return null;
|
|
478
479
|
}
|
|
@@ -484,7 +485,7 @@ var NOOP_LOGGER = {
|
|
|
484
485
|
componentFile
|
|
485
486
|
);
|
|
486
487
|
return typeAlias ? (seen.add(compodocType), resolveTypealias(typeAlias.rawtype, compodocJson, componentFile, seen)) : compodocType;
|
|
487
|
-
}, extractType = (property, defaultValue, compodocJson, componentFile) => {
|
|
488
|
+
}, isFunctionTypeString = (compodocType) => compodocType === "function" || /^(new\s+)?(<.*>\s*)?\(.*\)\s*=>/.test(compodocType), extractType = (property, defaultValue, compodocJson, componentFile, modern = !1) => {
|
|
488
489
|
let compodocType = property.type || extractTypeFromValue(defaultValue);
|
|
489
490
|
switch (compodocType) {
|
|
490
491
|
case "string":
|
|
@@ -494,7 +495,15 @@ var NOOP_LOGGER = {
|
|
|
494
495
|
case null:
|
|
495
496
|
return { name: "other", value: "void" };
|
|
496
497
|
default: {
|
|
497
|
-
|
|
498
|
+
if (modern && typeof compodocType == "string" && isFunctionTypeString(compodocType))
|
|
499
|
+
return { name: "function" };
|
|
500
|
+
let resolvedType = resolveTypealias(compodocType, compodocJson, componentFile);
|
|
501
|
+
if (modern && typeof resolvedType == "string" && resolvedType.indexOf("|") !== -1) {
|
|
502
|
+
let members = [...new Set(selectableUnionMembers(resolvedType))];
|
|
503
|
+
if (members.length === 1 && ["string", "boolean", "number"].includes(members[0]))
|
|
504
|
+
return { name: members[0] };
|
|
505
|
+
}
|
|
506
|
+
let enumValues = extractEnumValues(resolvedType, compodocJson, componentFile, modern);
|
|
498
507
|
return enumValues ? { name: "enum", value: enumValues } : { name: "other", value: "empty-enum" };
|
|
499
508
|
}
|
|
500
509
|
}
|
|
@@ -524,44 +533,84 @@ var NOOP_LOGGER = {
|
|
|
524
533
|
default:
|
|
525
534
|
return defaultValue;
|
|
526
535
|
}
|
|
527
|
-
},
|
|
536
|
+
}, castDefaultValueModern = (property, defaultValue) => {
|
|
537
|
+
if (defaultValue !== void 0)
|
|
538
|
+
switch (property.type) {
|
|
539
|
+
case "boolean":
|
|
540
|
+
return defaultValue === "true" || defaultValue === "false" ? defaultValue === "true" : defaultValue;
|
|
541
|
+
case "number": {
|
|
542
|
+
let parsed = Number(defaultValue);
|
|
543
|
+
return Number.isNaN(parsed) && defaultValue !== "NaN" ? defaultValue : parsed;
|
|
544
|
+
}
|
|
545
|
+
case "EventEmitter":
|
|
546
|
+
return;
|
|
547
|
+
case "string":
|
|
548
|
+
return defaultValue;
|
|
549
|
+
default:
|
|
550
|
+
return castDefaultValue(property, defaultValue);
|
|
551
|
+
}
|
|
552
|
+
}, extractDefaultValueFromComments = (property, value, unwrapHtml2, modern) => {
|
|
528
553
|
let commentValue = value;
|
|
529
554
|
return property.jsdoctags.forEach((tag) => {
|
|
530
555
|
let tagName = tag.tagName.escapedText;
|
|
531
|
-
(tagName === "default" || tagName === "defaultvalue")
|
|
556
|
+
if (tagName === "default" || tagName === "defaultvalue") {
|
|
557
|
+
if (modern) {
|
|
558
|
+
tag.comment !== void 0 && (commentValue = unquote(unwrapHtml2(tag.comment).trim()));
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
commentValue = unwrapHtml2(tag.comment);
|
|
562
|
+
}
|
|
532
563
|
}), commentValue;
|
|
533
|
-
}, extractDefaultValue = (property, logger2, unwrapHtml2) => {
|
|
564
|
+
}, unquote = (value) => value.replace(/^'(.*)'$/, "$1").replace(/^"(.*)"$/, "$1"), extractDefaultValue = (property, logger2, unwrapHtml2, modern) => {
|
|
534
565
|
try {
|
|
535
566
|
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;
|
|
567
|
+
return value = modern ? castDefaultValueModern(property, value) : castDefaultValue(property, value), value == null && (property.jsdoctags?.length ?? 0) > 0 && (value = extractDefaultValueFromComments(property, value, unwrapHtml2, modern)), value;
|
|
537
568
|
} catch {
|
|
538
569
|
logger2.debug(`Error extracting ${property.name}: ${property.defaultValue}`);
|
|
539
570
|
return;
|
|
540
571
|
}
|
|
541
|
-
},
|
|
542
|
-
let
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
572
|
+
}, extractMemberJsDocTags = (member, unwrapHtml2) => {
|
|
573
|
+
let deprecated, returns;
|
|
574
|
+
for (let tag of member.jsdoctags ?? []) {
|
|
575
|
+
let tagName = tag.tagName?.escapedText;
|
|
576
|
+
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() });
|
|
577
|
+
}
|
|
578
|
+
if (!(deprecated === void 0 && returns === void 0))
|
|
579
|
+
return {
|
|
580
|
+
...deprecated !== void 0 ? { deprecated } : {},
|
|
581
|
+
...returns !== void 0 ? { returns } : {}
|
|
582
|
+
};
|
|
583
|
+
}, readMembers = (componentData, key) => componentData[key] || [], isDirectiveEntry = (componentData) => componentData.type === "component" || componentData.type === "directive", getModelProperties = (componentData) => {
|
|
584
|
+
if (!isDirectiveEntry(componentData))
|
|
585
|
+
return [];
|
|
586
|
+
let inputsByName = new Map(componentData.inputsClass.map((item) => [item.name, item]));
|
|
587
|
+
return componentData.outputsClass.filter((item) => {
|
|
546
588
|
let input = inputsByName.get(item.name);
|
|
547
589
|
return input?.line !== void 0 && input.line === item.line;
|
|
548
590
|
});
|
|
549
|
-
}, extractArgTypesFromData = (componentData, {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
591
|
+
}, extractArgTypesFromData = (componentData, {
|
|
592
|
+
compodocJson,
|
|
593
|
+
filterNonInputControls: filterNonInputControls2,
|
|
594
|
+
logger: logger2 = NOOP_LOGGER,
|
|
595
|
+
unwrapHtml: unwrapHtml2,
|
|
596
|
+
modern = !1
|
|
597
|
+
}) => {
|
|
598
|
+
let sectionToItems = {}, componentClasses = filterNonInputControls2 ? ["inputsClass"] : ["propertiesClass", "methodsClass", "inputsClass", "outputsClass"], compodocClasses = isDirectiveEntry(componentData) ? componentClasses : ["properties", "methods"], modelProperties = getModelProperties(componentData), modelPropertyNames = new Set(modelProperties.map((item) => item.name));
|
|
553
599
|
compodocClasses.forEach((key) => {
|
|
554
600
|
readMembers(componentData, key).forEach((item) => {
|
|
601
|
+
if (modern && item.name.startsWith("#"))
|
|
602
|
+
return;
|
|
555
603
|
let section = mapItemToSection(key, item);
|
|
556
604
|
if (key === "outputsClass" && !isMethod(item) && modelPropertyNames.has(item.name))
|
|
557
605
|
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 = {
|
|
606
|
+
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
607
|
name: item.name,
|
|
560
608
|
description: item.rawdescription || item.description,
|
|
561
609
|
type,
|
|
562
610
|
...action,
|
|
563
611
|
table: {
|
|
564
612
|
category: section,
|
|
613
|
+
...jsDocTags !== void 0 ? { jsDocTags } : {},
|
|
565
614
|
type: {
|
|
566
615
|
summary: isMethod(item) ? displaySignature(item) : item.type,
|
|
567
616
|
required: isMethod(item) ? !1 : isRequired(item)
|
|
@@ -581,26 +630,14 @@ var NOOP_LOGGER = {
|
|
|
581
630
|
category: "outputs",
|
|
582
631
|
type: {
|
|
583
632
|
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
633
|
required: !1
|
|
588
634
|
}
|
|
589
635
|
}
|
|
590
636
|
};
|
|
591
637
|
sectionToItems.outputs || (sectionToItems.outputs = []), sectionToItems.outputs.push(argType);
|
|
592
638
|
});
|
|
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) => {
|
|
639
|
+
let argTypes = {};
|
|
640
|
+
return SECTION_ORDER.forEach((section) => {
|
|
604
641
|
let items = sectionToItems[section];
|
|
605
642
|
items && items.forEach((argType) => {
|
|
606
643
|
argTypes[argType.name] = argType;
|
|
@@ -614,27 +651,28 @@ import { logger } from "storybook/internal/client-logger";
|
|
|
614
651
|
import { global as global2 } from "@storybook/global";
|
|
615
652
|
var { FEATURES } = global2;
|
|
616
653
|
var getCompodocJson = () => global2.__STORYBOOK_COMPODOC_JSON__;
|
|
617
|
-
var unwrapHtml = (html) => new global2.DOMParser().parseFromString(html, "text/html").body.textContent ?? "", extractArgTypesFromData2 = (componentData) => extractArgTypesFromData(componentData, {
|
|
654
|
+
var unwrapHtml = (html) => new global2.DOMParser().parseFromString(html, "text/html").body.textContent ?? "", extractArgTypesFromData2 = (componentData, { filterNonInputControls: filterNonInputControls2 = FEATURES.angularFilterNonInputControls } = {}) => extractArgTypesFromData(componentData, {
|
|
618
655
|
compodocJson: getCompodocJson(),
|
|
619
|
-
|
|
620
|
-
// always thrown there rather than silently reading the flag as `false`.
|
|
621
|
-
filterNonInputControls: FEATURES.angularFilterNonInputControls,
|
|
656
|
+
filterNonInputControls: filterNonInputControls2,
|
|
622
657
|
logger,
|
|
623
658
|
unwrapHtml
|
|
624
|
-
}), extractArgTypes = (component) => {
|
|
659
|
+
}), extractArgTypes = (component, options) => {
|
|
625
660
|
let componentData = getComponentData(component, { compodocJson: getCompodocJson(), logger });
|
|
626
|
-
return componentData && extractArgTypesFromData2(componentData);
|
|
661
|
+
return componentData && extractArgTypesFromData2(componentData, options);
|
|
627
662
|
}, extractComponentDescription = (component) => {
|
|
628
663
|
let componentData = getComponentData(component, { compodocJson: getCompodocJson(), logger });
|
|
629
664
|
return componentData && (componentData.rawdescription || componentData.description);
|
|
630
665
|
};
|
|
631
666
|
|
|
667
|
+
// src/client/compodoc.ts
|
|
668
|
+
var filterNonInputControls = typeof STORYBOOK_ANGULAR_OPTIONS > "u" || STORYBOOK_ANGULAR_OPTIONS.propsTable === void 0 ? void 0 : STORYBOOK_ANGULAR_OPTIONS.propsTable === "inputs", extractArgTypes2 = (component) => extractArgTypes(component, { filterNonInputControls });
|
|
669
|
+
|
|
632
670
|
// src/client/config.ts
|
|
633
671
|
var parameters = {
|
|
634
672
|
renderer: "angular",
|
|
635
673
|
docs: {
|
|
636
674
|
story: { inline: !0 },
|
|
637
|
-
extractArgTypes,
|
|
675
|
+
extractArgTypes: (component) => global3.FEATURES?.experimentalDocgenServer === !0 ? {} : extractArgTypes2(component),
|
|
638
676
|
extractComponentDescription
|
|
639
677
|
}
|
|
640
678
|
}, argTypesEnhancers = [enhanceArgTypes];
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
config_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AL7GEPYM.js";
|
|
4
4
|
import {
|
|
5
5
|
config_exports as config_exports2
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-VP3W5GY3.js";
|
|
7
7
|
import {
|
|
8
8
|
computesTemplateFromComponent,
|
|
9
9
|
formatPropInTemplate,
|
|
10
10
|
isComponent,
|
|
11
11
|
render_exports
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-UJ3I56EP.js";
|
|
13
13
|
|
|
14
14
|
// src/client/portable-stories.ts
|
|
15
15
|
import {
|
|
@@ -25,6 +25,68 @@ 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 = "", selfClosing = !1 }) => {
|
|
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 closesItself = VOID_ELEMENTS.has(element) || selfClosing && element.includes("-") && innerTemplate === "", inlineTag = `<${element}${attributes}${bindings.map((binding) => ` ${binding}`).join("")}`, inline = closesItself ? `${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 (closesItself)
|
|
80
|
+
return selfClosing ? `${brokenTag}
|
|
81
|
+
/>` : `${brokenTag} />`;
|
|
82
|
+
let content = innerTemplate === "" ? `
|
|
83
|
+
` : `
|
|
84
|
+
${innerTemplate}
|
|
85
|
+
`;
|
|
86
|
+
return `${brokenTag}>${content}</${element}>`;
|
|
87
|
+
});
|
|
88
|
+
}, buildComponentOutletTemplate = (componentName, { selfClosing = !1 } = {}) => selfClosing ? `<ng-container *ngComponentOutlet="${componentName}" />` : `<ng-container *ngComponentOutlet="${componentName}"></ng-container>`;
|
|
89
|
+
|
|
28
90
|
// src/client/renderer/utils/NgComponentAnalyzer.ts
|
|
29
91
|
import {
|
|
30
92
|
Component,
|
|
@@ -103,108 +165,36 @@ var isComponent = (component) => component ? (reflectionCapabilities.annotations
|
|
|
103
165
|
var getComponentPropsDecoratorMetadata = (component) => reflectionCapabilities.propMetadata(component), getComponentDecoratorMetadata = (component) => reflectionCapabilities.annotations(component).reverse().find((d) => d instanceof Component);
|
|
104
166
|
|
|
105
167
|
// 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 = "") => {
|
|
168
|
+
var separateInputsOutputsAttributes = (ngComponentInputsOutputs, props = {}) => ({
|
|
169
|
+
inputs: ngComponentInputsOutputs.inputs.filter((i) => i.templateName in props).map((i) => i.templateName),
|
|
170
|
+
outputs: ngComponentInputsOutputs.outputs.filter((o) => o.templateName in props).map((o) => o.templateName)
|
|
171
|
+
}), computesTemplateFromComponent = (component, initialProps, innerTemplate = "") => {
|
|
114
172
|
let ngComponentMetadata = getComponentDecoratorMetadata(component), ngComponentInputsOutputs = getComponentInputsOutputs(component);
|
|
115
173
|
if (!ngComponentMetadata.selector)
|
|
116
174
|
return '<ng-container *ngComponentOutlet="storyComponent"></ng-container>';
|
|
117
|
-
let { inputs
|
|
175
|
+
let { inputs, outputs } = separateInputsOutputsAttributes(
|
|
118
176
|
ngComponentInputsOutputs,
|
|
119
177
|
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
178
|
);
|
|
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;
|
|
179
|
+
return buildTemplate(ngComponentMetadata.selector, {
|
|
180
|
+
inputs: inputs.map((name) => ({ name, expression: formatPropInTemplate(name) })),
|
|
181
|
+
outputs,
|
|
182
|
+
innerTemplate
|
|
137
183
|
});
|
|
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) => {
|
|
184
|
+
}, computesTemplateSourceFromComponent = (component, initialProps) => {
|
|
157
185
|
let ngComponentMetadata = getComponentDecoratorMetadata(component);
|
|
158
186
|
if (!ngComponentMetadata)
|
|
159
187
|
return null;
|
|
160
188
|
if (!ngComponentMetadata.selector)
|
|
161
|
-
return
|
|
162
|
-
let ngComponentInputsOutputs = getComponentInputsOutputs(component), { inputs
|
|
189
|
+
return buildComponentOutletTemplate(component.name);
|
|
190
|
+
let ngComponentInputsOutputs = getComponentInputsOutputs(component), { inputs, outputs } = separateInputsOutputsAttributes(
|
|
163
191
|
ngComponentInputsOutputs,
|
|
164
192
|
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
193
|
);
|
|
194
|
+
return buildTemplate(ngComponentMetadata.selector, {
|
|
195
|
+
inputs: inputs.map((name) => ({ name, expression: formatInputValue(initialProps?.[name]) })),
|
|
196
|
+
outputs
|
|
197
|
+
});
|
|
208
198
|
};
|
|
209
199
|
|
|
210
200
|
// src/client/renderer/StorybookWrapperComponent.ts
|
|
@@ -713,9 +703,8 @@ async function renderToCanvas({
|
|
|
713
703
|
|
|
714
704
|
export {
|
|
715
705
|
__export,
|
|
716
|
-
getComponentInputsOutputs,
|
|
717
|
-
isComponent,
|
|
718
706
|
formatPropInTemplate,
|
|
707
|
+
isComponent,
|
|
719
708
|
computesTemplateFromComponent,
|
|
720
709
|
computesTemplateSourceFromComponent,
|
|
721
710
|
render,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__export,
|
|
3
3
|
computesTemplateSourceFromComponent
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-UJ3I56EP.js";
|
|
5
5
|
|
|
6
6
|
// src/client/docs/config.ts
|
|
7
7
|
var config_exports = {};
|
|
@@ -22,23 +22,23 @@ 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 useStaticServiceSnippets = globalThis.FEATURES?.experimentalDocgenServer === !0, parameters = {
|
|
35
35
|
docs: {
|
|
36
36
|
source: {
|
|
37
37
|
type: SourceType2.DYNAMIC,
|
|
38
|
-
language: "html"
|
|
38
|
+
language: useStaticServiceSnippets ? "ts" : "html"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
}, decorators = [sourceDecorator];
|
|
41
|
+
}, decorators = useStaticServiceSnippets ? [] : [sourceDecorator];
|
|
42
42
|
|
|
43
43
|
export {
|
|
44
44
|
parameters,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import CJS_COMPAT_NODE_URL_8ni5g5ueuqs from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_8ni5g5ueuqs from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_8ni5g5ueuqs from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_8ni5g5ueuqs.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_8ni5g5ueuqs.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_8ni5g5ueuqs.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 {
|
|
15
|
+
createMetaComponentResolver,
|
|
16
|
+
createModuleResolver,
|
|
17
|
+
jsTsSourceExtensions
|
|
18
|
+
} from "storybook/internal/common";
|
|
19
|
+
import { loadCsf } from "storybook/internal/csf-tools";
|
|
20
|
+
import { readFileSync } from "node:fs";
|
|
21
|
+
var resolveMetaComponent = createMetaComponentResolver(), storyImportResolver = createModuleResolver({
|
|
22
|
+
extensions: [...jsTsSourceExtensions],
|
|
23
|
+
mainFields: ["module", "main"],
|
|
24
|
+
tsconfig: "auto"
|
|
25
|
+
});
|
|
26
|
+
function parseStoryFile(storyFilePath, title) {
|
|
27
|
+
try {
|
|
28
|
+
let source = readFileSync(storyFilePath, "utf8");
|
|
29
|
+
return loadCsf(source, { makeTitle: () => title }).parse();
|
|
30
|
+
} catch {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function resolveStoryComponent(storyFilePath, title = "Docgen") {
|
|
35
|
+
let csf = parseStoryFile(storyFilePath, title);
|
|
36
|
+
return csf ? resolveMetaComponent(csf, storyFilePath) : { reason: "no-meta-component" };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export {
|
|
40
|
+
parseStoryFile,
|
|
41
|
+
resolveStoryComponent
|
|
42
|
+
};
|