vibe-design-system 2.5.2 → 2.5.3
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/package.json
CHANGED
|
@@ -648,6 +648,42 @@ function toKebab(str) {
|
|
|
648
648
|
return str.replace(/([A-Z])/g, "-$1").toLowerCase().replace(/^-/, "");
|
|
649
649
|
}
|
|
650
650
|
|
|
651
|
+
/** Flatten JSX: replace ${...} and {...} (variables/expressions) with placeholders so generated component has no "item is not defined". */
|
|
652
|
+
function flattenJsx(jsx) {
|
|
653
|
+
let result = "";
|
|
654
|
+
let i = 0;
|
|
655
|
+
const len = jsx.length;
|
|
656
|
+
while (i < len) {
|
|
657
|
+
if (jsx.slice(i, i + 2) === "${") {
|
|
658
|
+
i += 2;
|
|
659
|
+
let depth = 1;
|
|
660
|
+
while (i < len && depth > 0) {
|
|
661
|
+
if (jsx[i] === "{") depth++;
|
|
662
|
+
else if (jsx[i] === "}") depth--;
|
|
663
|
+
i++;
|
|
664
|
+
}
|
|
665
|
+
result += '"Sample"';
|
|
666
|
+
continue;
|
|
667
|
+
}
|
|
668
|
+
if (jsx[i] === "{" && (i === 0 || jsx[i - 1] !== "{")) {
|
|
669
|
+
const start = i;
|
|
670
|
+
i++;
|
|
671
|
+
let depth = 1;
|
|
672
|
+
while (i < len && depth > 0) {
|
|
673
|
+
const c = jsx[i];
|
|
674
|
+
if (c === "{") depth++;
|
|
675
|
+
else if (c === "}") depth--;
|
|
676
|
+
i++;
|
|
677
|
+
}
|
|
678
|
+
result += '{"Sample"}';
|
|
679
|
+
continue;
|
|
680
|
+
}
|
|
681
|
+
result += jsx[i];
|
|
682
|
+
i++;
|
|
683
|
+
}
|
|
684
|
+
return result;
|
|
685
|
+
}
|
|
686
|
+
|
|
651
687
|
/** Collect PascalCase tag names from JSX that are not known HTML. */
|
|
652
688
|
function collectComponentTags(jsx) {
|
|
653
689
|
const tags = new Set();
|
|
@@ -679,7 +715,7 @@ function writeVdsGeneratedComponents(suggestions) {
|
|
|
679
715
|
let bodyJsx;
|
|
680
716
|
const tokens = [];
|
|
681
717
|
if (s.fullJsx && s.fullJsx.trim().length > 0) {
|
|
682
|
-
bodyJsx = s.fullJsx;
|
|
718
|
+
bodyJsx = flattenJsx(s.fullJsx);
|
|
683
719
|
const componentTags = collectComponentTags(bodyJsx);
|
|
684
720
|
const lucideTags = [];
|
|
685
721
|
const uiTags = [];
|
|
@@ -587,9 +587,10 @@ function buildStoryFileContent(comp) {
|
|
|
587
587
|
}
|
|
588
588
|
const exportStyle = detectExportStyle(source, componentName);
|
|
589
589
|
const omitChildren = componentWrapsVoidElement(source);
|
|
590
|
+
const isPage = comp.file.startsWith("pages/");
|
|
590
591
|
|
|
591
|
-
// Skip story if
|
|
592
|
-
if (exportStyle === "unknown" && (!source.includes("export") || !new RegExp(`\\b${componentName}\\b`).test(source))) {
|
|
592
|
+
// Skip story only if not a page and no export found
|
|
593
|
+
if (exportStyle === "unknown" && !isPage && (!source.includes("export") || !new RegExp(`\\b${componentName}\\b`).test(source))) {
|
|
593
594
|
return null;
|
|
594
595
|
}
|
|
595
596
|
|
|
@@ -600,7 +601,10 @@ function buildStoryFileContent(comp) {
|
|
|
600
601
|
const lines = [];
|
|
601
602
|
lines.push(`import type { Meta, StoryObj } from "@storybook/react";`);
|
|
602
603
|
|
|
603
|
-
if (exportStyle
|
|
604
|
+
if (isPage && exportStyle !== "default") {
|
|
605
|
+
lines.push(`import * as Named from "${importPath}";`);
|
|
606
|
+
lines.push(`const ComponentRef = Named["${componentName}"] ?? Named.default;`);
|
|
607
|
+
} else if (exportStyle === "default") {
|
|
604
608
|
lines.push(`import ${componentName} from "${importPath}";`);
|
|
605
609
|
lines.push(`const ComponentRef = ${componentName};`);
|
|
606
610
|
} else if (exportStyle === "named" || exportStyle === "unknown") {
|