vibe-design-system 2.5.3 → 2.5.4
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 +1 -1
- package/vds-core-template/scan.mjs +45 -11
package/package.json
CHANGED
|
@@ -666,7 +666,6 @@ function flattenJsx(jsx) {
|
|
|
666
666
|
continue;
|
|
667
667
|
}
|
|
668
668
|
if (jsx[i] === "{" && (i === 0 || jsx[i - 1] !== "{")) {
|
|
669
|
-
const start = i;
|
|
670
669
|
i++;
|
|
671
670
|
let depth = 1;
|
|
672
671
|
while (i < len && depth > 0) {
|
|
@@ -684,6 +683,39 @@ function flattenJsx(jsx) {
|
|
|
684
683
|
return result;
|
|
685
684
|
}
|
|
686
685
|
|
|
686
|
+
/** Convert HTML style="key: value; ..." to React style={{ key: 'value', ... }} (camelCase keys). */
|
|
687
|
+
function convertHtmlStyleToReact(jsx) {
|
|
688
|
+
return jsx.replace(
|
|
689
|
+
/style\s*=\s*["']([^"']*)["']/g,
|
|
690
|
+
(_, cssStr) => {
|
|
691
|
+
const obj = {};
|
|
692
|
+
const parts = (cssStr || "").split(";").map((s) => s.trim()).filter(Boolean);
|
|
693
|
+
for (const part of parts) {
|
|
694
|
+
const colon = part.indexOf(":");
|
|
695
|
+
if (colon <= 0) continue;
|
|
696
|
+
const key = part.slice(0, colon).trim().replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
697
|
+
const value = part.slice(colon + 1).trim().replace(/^["']|["']$/g, "");
|
|
698
|
+
if (key) obj[key] = value;
|
|
699
|
+
}
|
|
700
|
+
if (Object.keys(obj).length === 0) return "style={{}}";
|
|
701
|
+
const entries = Object.entries(obj).map(([k, v]) => `${k}: "${String(v).replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`).join(", ");
|
|
702
|
+
return `style={{ ${entries} }}`;
|
|
703
|
+
}
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/** Replace Lucide icon tags with LucideIcons.TagName so namespace import works. */
|
|
708
|
+
function applyLucideNamespace(jsx, lucideTags) {
|
|
709
|
+
let out = jsx;
|
|
710
|
+
for (const tag of lucideTags) {
|
|
711
|
+
const openRe = new RegExp("<" + tag.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "(?=[\\s/>])", "g");
|
|
712
|
+
const closeRe = new RegExp("</" + tag.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + ">", "g");
|
|
713
|
+
out = out.replace(openRe, "<LucideIcons." + tag);
|
|
714
|
+
out = out.replace(closeRe, "</LucideIcons." + tag + ">");
|
|
715
|
+
}
|
|
716
|
+
return out;
|
|
717
|
+
}
|
|
718
|
+
|
|
687
719
|
/** Collect PascalCase tag names from JSX that are not known HTML. */
|
|
688
720
|
function collectComponentTags(jsx) {
|
|
689
721
|
const tags = new Set();
|
|
@@ -716,6 +748,7 @@ function writeVdsGeneratedComponents(suggestions) {
|
|
|
716
748
|
const tokens = [];
|
|
717
749
|
if (s.fullJsx && s.fullJsx.trim().length > 0) {
|
|
718
750
|
bodyJsx = flattenJsx(s.fullJsx);
|
|
751
|
+
bodyJsx = convertHtmlStyleToReact(bodyJsx);
|
|
719
752
|
const componentTags = collectComponentTags(bodyJsx);
|
|
720
753
|
const lucideTags = [];
|
|
721
754
|
const uiTags = [];
|
|
@@ -723,15 +756,14 @@ function writeVdsGeneratedComponents(suggestions) {
|
|
|
723
756
|
if (/^[A-Z][a-z0-9]+$/.test(tag) && tag.length > 2) lucideTags.push(tag);
|
|
724
757
|
else uiTags.push(tag);
|
|
725
758
|
}
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
}
|
|
759
|
+
bodyJsx = applyLucideNamespace(bodyJsx, lucideTags);
|
|
760
|
+
const standardImports = [
|
|
761
|
+
'import React from "react";',
|
|
762
|
+
'import { motion } from "framer-motion";',
|
|
763
|
+
'import * as LucideIcons from "lucide-react";',
|
|
764
|
+
];
|
|
765
|
+
const uiImportLines = uiTags.map((tag) => `import { ${tag} } from "@/components/ui/${toKebab(tag)}";`);
|
|
766
|
+
const importLines = [...standardImports, ...uiImportLines];
|
|
735
767
|
const content = importLines.join("\n") + "\n\n" +
|
|
736
768
|
`export function ${componentName}() {\n return (\n ` +
|
|
737
769
|
bodyJsx.replace(/\n/g, "\n ") + "\n );\n}\n";
|
|
@@ -741,7 +773,9 @@ function writeVdsGeneratedComponents(suggestions) {
|
|
|
741
773
|
const tagName = s.tagName || "div";
|
|
742
774
|
const className = s.pattern || "";
|
|
743
775
|
bodyJsx = `<${tagName} className="${className.replace(/"/g, '\\"')}">\n {null}\n </${tagName}>`;
|
|
744
|
-
const content = `import
|
|
776
|
+
const content = `import React from "react";
|
|
777
|
+
import { motion } from "framer-motion";
|
|
778
|
+
import * as LucideIcons from "lucide-react";
|
|
745
779
|
|
|
746
780
|
export function ${componentName}() {
|
|
747
781
|
return (
|