vibe-design-system 2.5.12 → 2.5.14

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/bin/init.js CHANGED
@@ -24,9 +24,6 @@ const TEMPLATE_DIR = path.join(INSTALLER_ROOT, "vds-core-template");
24
24
  const STORYBOOK_MAIN_TS = `import type { StorybookConfig } from "@storybook/react-vite";
25
25
  import { mergeConfig } from "vite";
26
26
  import path from "path";
27
- import { fileURLToPath } from "url";
28
-
29
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
30
27
 
31
28
  const config: StorybookConfig = {
32
29
  stories: ["../src/**/*.stories.@(js|jsx|mjs|ts|tsx)"],
@@ -39,7 +36,7 @@ const config: StorybookConfig = {
39
36
  return mergeConfig(config, {
40
37
  resolve: {
41
38
  alias: {
42
- "@": path.resolve(__dirname, "../src"),
39
+ "@": path.resolve(process.cwd(), "src"),
43
40
  },
44
41
  },
45
42
  });
@@ -50,8 +47,18 @@ export default config;
50
47
  `;
51
48
 
52
49
  const STORYBOOK_PREVIEW_TS = `import type { Preview } from "@storybook/react";
50
+ import React from "react";
51
+ import { MemoryRouter } from "react-router-dom";
53
52
  import "../src/index.css";
54
53
 
54
+ const withRouter = (Story: any) => {
55
+ try {
56
+ return React.createElement(MemoryRouter, null, React.createElement(Story));
57
+ } catch {
58
+ return React.createElement(Story);
59
+ }
60
+ };
61
+
55
62
  const preview: Preview = {
56
63
  parameters: {
57
64
  layout: "fullscreen",
@@ -69,6 +76,7 @@ const preview: Preview = {
69
76
  },
70
77
  },
71
78
  },
79
+ decorators: [withRouter],
72
80
  };
73
81
 
74
82
  export default preview;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vibe-design-system",
3
- "version": "2.5.12",
3
+ "version": "2.5.14",
4
4
  "description": "Auto-generate design systems for vibe coding projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -374,6 +374,15 @@ function hasNamedExports(source, names) {
374
374
  return true;
375
375
  }
376
376
 
377
+ /** Whether component has children prop typed as ReactNode / React.ReactNode (use createElement fallback in render). */
378
+ function hasChildrenPropReactNode(props) {
379
+ if (!Array.isArray(props) || props.length === 0) return false;
380
+ const childrenProp = props.find((p) => p.name === "children");
381
+ if (!childrenProp) return false;
382
+ const type = String(childrenProp.type || "").toLowerCase();
383
+ return type.includes("reactnode") || type.includes("react.reactnode");
384
+ }
385
+
377
386
  /** Void HTML elements: img, input, hr, br — must not receive children. If component wraps one and has children in props, omit children in story args. */
378
387
  function componentWrapsVoidElement(source) {
379
388
  if (!source || typeof source !== "string") return false;
@@ -710,6 +719,7 @@ function buildStoryFileContent(comp) {
710
719
  // Props: manifest or parse from source for default args (LucideIcon, array types)
711
720
  const effectiveProps = Array.isArray(comp.props) && comp.props.length > 0 ? comp.props : parsePropsFromSource(source);
712
721
  const { argLines: defaultArgLines, lucideImports } = buildDefaultArgsForRequiredProps(effectiveProps);
722
+ const useReactNodeChildrenRender = !omitChildren && hasChildrenPropReactNode(effectiveProps);
713
723
 
714
724
  // Skip story only if not a page and no export found
715
725
  if (exportStyle === "unknown" && !isPage && (!source.includes("export") || !new RegExp(`\\b${componentName}\\b`).test(source))) {
@@ -722,6 +732,9 @@ function buildStoryFileContent(comp) {
722
732
 
723
733
  const lines = [];
724
734
  lines.push(`import type { Meta, StoryObj } from "@storybook/react";`);
735
+ if (useReactNodeChildrenRender) {
736
+ lines.push(`import React from "react";`);
737
+ }
725
738
  if (lucideImports.length > 0) {
726
739
  lines.push(`import { ${lucideImports.join(", ")} } from "lucide-react";`);
727
740
  }
@@ -770,21 +783,26 @@ function buildStoryFileContent(comp) {
770
783
  }
771
784
 
772
785
  // Generic variant-based stories — render real component with args (omit children for img/void)
786
+ const renderLine = useReactNodeChildrenRender
787
+ ? ` render: (args) => React.createElement(ComponentRef, { ...args, children: args.children || React.createElement('span', null, 'Example') }),`
788
+ : ` render: (args) => <ComponentRef {...args} />,`;
789
+ const childrenArgLine = (label) => (!omitChildren && !useReactNodeChildrenRender ? ` children: ${JSON.stringify(label)},` : null);
790
+
773
791
  if (!variants.length) {
774
792
  lines.push(`export const Default: Story = {`);
775
- lines.push(` render: (args) => <ComponentRef {...args} />,`);
793
+ lines.push(renderLine);
776
794
  lines.push(` args: {`);
777
- if (!omitChildren) lines.push(` children: "${componentName}",`);
795
+ if (childrenArgLine(componentName)) lines.push(childrenArgLine(componentName));
778
796
  for (const line of defaultArgLines) lines.push(line);
779
797
  lines.push(` },`);
780
798
  lines.push(`};`);
781
799
  } else {
782
800
  const defaultVariant = variants[0];
783
801
  lines.push(`export const ${capitalize(defaultVariant)}: Story = {`);
784
- lines.push(` render: (args) => <ComponentRef {...args} />,`);
802
+ lines.push(renderLine);
785
803
  lines.push(` args: {`);
786
804
  lines.push(` variant: "${defaultVariant}",`);
787
- if (!omitChildren) lines.push(` children: "${componentName}",`);
805
+ if (childrenArgLine(componentName)) lines.push(childrenArgLine(componentName));
788
806
  for (const line of defaultArgLines) lines.push(line);
789
807
  lines.push(` },`);
790
808
  lines.push(`};`);
@@ -792,10 +810,10 @@ function buildStoryFileContent(comp) {
792
810
  for (const v of variants.slice(1)) {
793
811
  const storyName = capitalize(v);
794
812
  lines.push(`export const ${storyName}: Story = {`);
795
- lines.push(` render: (args) => <ComponentRef {...args} />,`);
813
+ lines.push(renderLine);
796
814
  lines.push(` args: {`);
797
815
  lines.push(` variant: "${v}",`);
798
- if (!omitChildren) lines.push(` children: "${storyName}",`);
816
+ if (childrenArgLine(storyName)) lines.push(childrenArgLine(storyName));
799
817
  for (const line of defaultArgLines) lines.push(line);
800
818
  lines.push(` },`);
801
819
  lines.push(`};`);