vibe-design-system 2.5.29 → 2.5.31
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
|
@@ -84,11 +84,10 @@ export default preview;
|
|
|
84
84
|
`;
|
|
85
85
|
|
|
86
86
|
const CURSORRULES = `# VDS — Vibe Design System
|
|
87
|
-
Bu proje VDS kullanıyor.
|
|
88
|
-
- npm run vds → projeyi tara
|
|
89
|
-
- npm run vds:stories → Storybook story'lerini üret
|
|
90
|
-
- npm run vds:watch → değişiklikleri izle
|
|
87
|
+
Bu proje VDS kullanıyor. Tek komut yeterli:
|
|
88
|
+
- npm run vds:stories → projeyi tara, story'leri üret, provider'ları ayarla (hepsi tek seferde)
|
|
91
89
|
- npm run storybook → design system'ı aç (localhost:6006)
|
|
90
|
+
- npm run vds:watch → değişiklikleri izle (tarama + story otomatik)
|
|
92
91
|
|
|
93
92
|
Geliştirme kuralları:
|
|
94
93
|
- UI component'leri src/components/ui/ altına koy
|
|
@@ -254,7 +253,7 @@ function addScripts(projectRoot) {
|
|
|
254
253
|
changed = true;
|
|
255
254
|
}
|
|
256
255
|
if (!scripts["vds:stories"]) {
|
|
257
|
-
scripts["vds:stories"] = "node vds-core/story-generator.mjs";
|
|
256
|
+
scripts["vds:stories"] = "node vds-core/scan.mjs && node vds-core/story-generator.mjs && node vds-core/setup-storybook-providers.mjs";
|
|
258
257
|
changed = true;
|
|
259
258
|
}
|
|
260
259
|
if (!scripts["vds:watch"]) {
|
|
@@ -398,6 +397,7 @@ runSetupStorybookProviders(projectRoot);
|
|
|
398
397
|
|
|
399
398
|
// ADIM 8
|
|
400
399
|
console.log("\n✅ VDS kuruldu!");
|
|
401
|
-
console.log("→ npm run storybook ile design system'
|
|
400
|
+
console.log("→ npm run storybook ile design system'ı aç (localhost:6006)");
|
|
401
|
+
console.log("→ Yeni component ekledikten sonra: npm run vds:stories (tek komut: tarama + story + provider)");
|
|
402
402
|
console.log("→ npm run vds:watch ile otomatik güncellemeyi başlat");
|
|
403
403
|
console.log("\nNot: Storybook başlarken (Node 24+) DEP0190 uyarısı çıkarsa Storybook kaynaklıdır, güvenle yok sayabilirsiniz.\n");
|
package/package.json
CHANGED
|
@@ -47,22 +47,30 @@ To see **live renders** of components in the dashboard (isolated, no app chrome)
|
|
|
47
47
|
|
|
48
48
|
## Storybook
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
**Tek komut** (tarama + story + provider hepsi birlikte):
|
|
51
51
|
```bash
|
|
52
52
|
npm run vds:stories
|
|
53
53
|
```
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
Script (`package.json`): `node vds-core/scan.mjs && node vds-core/story-generator.mjs && node vds-core/setup-storybook-providers.mjs`
|
|
55
|
+
|
|
56
|
+
- **Provider'lar:** `vds:stories` içinde zaten çalışır; ayrıca `node vds-core/setup-storybook-providers.mjs` çalıştırmanıza gerek yok. Hooks (useTimer, useSidebar, useCircles, useAuth, useSearch) and inject the matching providers into `.storybook/preview.ts`. Kalan "undefined (reading 'x')" hatalarında ilgili story'de args veya mock state ekleyin.
|
|
57
|
+
|
|
58
|
+
- **Icons:** The Foundations/Icons story lists only icons that are imported from `lucide-react` in your app code (src/, excluding `src/stories`), so it reflects real usage.
|
|
59
|
+
|
|
60
|
+
## Son hal / Final state
|
|
61
|
+
|
|
62
|
+
VDS, **tek komutla** projenizin design system'ını Storybook'ta stilleriyle eşitlemeyi hedefler:
|
|
58
63
|
|
|
59
|
-
|
|
64
|
+
1. **Kurulum (bir kez):** `npx vibe-design-system init` — Storybook, vds-core, scriptler ve ilk tarama + story + provider ayarı yapılır.
|
|
65
|
+
2. **Güncelleme:** Yeni component ekledikten veya projeyi değiştirdikten sonra sadece `npm run vds:stories` çalıştırın; tarama, story üretimi ve provider enjeksiyonu otomatik yapılır.
|
|
66
|
+
3. **Görüntüleme:** `npm run storybook` ile tüm component'lar stilleriyle (index.css vb. preview'da import edildiği için) listelenir.
|
|
60
67
|
|
|
61
|
-
|
|
68
|
+
Kullanıcının her projede ayrı ayrı provider eklemesi, manuel story düzeltmesi veya birden fazla komut çalıştırması gerekmez. Nadir kalan hatalar (belirli bir component'ın özel context'i) story dosyasında args/mock ile giderilir.
|
|
62
69
|
|
|
63
70
|
## Layout
|
|
64
71
|
|
|
65
|
-
- `vds-core/scan.mjs` —
|
|
66
|
-
- `vds-core/story-generator.mjs` —
|
|
67
|
-
- `vds-core/
|
|
68
|
-
-
|
|
72
|
+
- `vds-core/scan.mjs` — Projeyi tarar (src/components, CSS, Tailwind). `vds-output.json` ve `public/vds-output.json` yazar.
|
|
73
|
+
- `vds-core/story-generator.mjs` — `vds-output.json`'dan story'leri üretir; varsayılan args (filters, sayı, tarih) ekler.
|
|
74
|
+
- `vds-core/setup-storybook-providers.mjs` — Hook ve react-dnd kullanımını tespit eder, `.storybook/preview` decorator'larına provider ekler.
|
|
75
|
+
- `vds-core/VdsPreview.tsx` — İsteğe bağlı; `/vds-preview` ile dashboard canlı component önizlemesi yapar.
|
|
76
|
+
- Dashboard UI `/vds-output.json` okur; Foundations + Component Library gösterir.
|
|
@@ -105,7 +105,28 @@ function getPreviewPath(projectRoot) {
|
|
|
105
105
|
return null;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
/**
|
|
108
|
+
/** Detect if project uses react-dnd (useDrag, useDrop, or import from react-dnd). */
|
|
109
|
+
function detectReactDnd(projectRoot) {
|
|
110
|
+
const srcDir = path.join(projectRoot, "src");
|
|
111
|
+
const files = getAllSourceFiles(srcDir, srcDir).map((r) => path.join(projectRoot, "src", r));
|
|
112
|
+
for (const full of files) {
|
|
113
|
+
try {
|
|
114
|
+
const content = fs.readFileSync(full, "utf-8");
|
|
115
|
+
if (/\b(useDrag|useDrop|DndProvider)\b/.test(content) || /from\s+["']react-dnd["']/.test(content)) {
|
|
116
|
+
const pkgPath = path.join(projectRoot, "package.json");
|
|
117
|
+
if (fs.existsSync(pkgPath)) {
|
|
118
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
|
|
119
|
+
const deps = { ...pkg.dependencies, ...pkg.devDependencies };
|
|
120
|
+
if (deps["react-dnd"]) return true;
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
} catch (_) {}
|
|
125
|
+
}
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** Collect all hooks used in project; return { providersToAdd: [{ name, importPath, props? }], ... } */
|
|
109
130
|
function collectProvidersAndWarnings(projectRoot) {
|
|
110
131
|
const hooksByFile = detectHooksUsedInProject(projectRoot);
|
|
111
132
|
const allHooksUsed = new Set();
|
|
@@ -125,15 +146,25 @@ function collectProvidersAndWarnings(projectRoot) {
|
|
|
125
146
|
hooksWithoutProvider.add(hook);
|
|
126
147
|
}
|
|
127
148
|
}
|
|
149
|
+
if (detectReactDnd(projectRoot) && !providersToAdd.some((p) => p.name === "DndProvider")) {
|
|
150
|
+
providersToAdd.unshift({
|
|
151
|
+
name: "DndProvider",
|
|
152
|
+
importPath: "react-dnd",
|
|
153
|
+
props: "{ backend: HTML5Backend }",
|
|
154
|
+
extraImport: { name: "HTML5Backend", from: "react-dnd-html5-backend" },
|
|
155
|
+
});
|
|
156
|
+
}
|
|
128
157
|
return { providersToAdd, hooksWithoutProvider, hooksByFile };
|
|
129
158
|
}
|
|
130
159
|
|
|
131
|
-
/** Build withProviders decorator using React.createElement (no JSX so preview can stay .ts) */
|
|
160
|
+
/** Build withProviders decorator using React.createElement (no JSX so preview can stay .ts). Supports provider.props. */
|
|
132
161
|
function buildWithProvidersCode(providers) {
|
|
133
162
|
if (providers.length === 0) return null;
|
|
134
163
|
let inner = "React.createElement(Story)";
|
|
135
164
|
for (let i = providers.length - 1; i >= 0; i--) {
|
|
136
|
-
|
|
165
|
+
const p = providers[i];
|
|
166
|
+
const propsArg = p.props ? p.props : "null";
|
|
167
|
+
inner = `React.createElement(${p.name}, ${propsArg}, ${inner})`;
|
|
137
168
|
}
|
|
138
169
|
return `const withProviders = (Story: any) => ${inner};`;
|
|
139
170
|
}
|
|
@@ -160,7 +191,11 @@ function injectProviderDecorators(projectRoot) {
|
|
|
160
191
|
if (!content.includes(p.name)) {
|
|
161
192
|
const lastImportIdx = content.search(/\nimport\s+.+?;\s*$/m);
|
|
162
193
|
const insertAt = lastImportIdx >= 0 ? content.indexOf("\n", lastImportIdx) + 1 : content.indexOf("\n") + 1;
|
|
163
|
-
|
|
194
|
+
let importLine = `import { ${p.name} } from "${p.importPath}";\n`;
|
|
195
|
+
if (p.extraImport && !content.includes(p.extraImport.name)) {
|
|
196
|
+
importLine += `import { ${p.extraImport.name} } from "${p.extraImport.from}";\n`;
|
|
197
|
+
}
|
|
198
|
+
content = content.slice(0, insertAt) + importLine + content.slice(insertAt);
|
|
164
199
|
}
|
|
165
200
|
}
|
|
166
201
|
content = content.replace(/const withProviders\s*=\s*\([^)]*\)\s*=>\s*[\s\S]+?;\s*\n?/g, "").replace(/\n{3,}/g, "\n\n");
|
|
@@ -652,6 +652,24 @@ function buildDefaultArgsForRequiredProps(props, usageFromPages = null, componen
|
|
|
652
652
|
} else if (/string/.test(type)) {
|
|
653
653
|
argLines.push(` ${name}: ${stringFallback(name)},`);
|
|
654
654
|
added.add(name);
|
|
655
|
+
} else if (/number/.test(type) || /^(value|amount|total|count|hours|minutes|progress|percent)$/.test(name)) {
|
|
656
|
+
argLines.push(` ${name}: 0,`);
|
|
657
|
+
added.add(name);
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
// Optional props that often cause "reading X of undefined" in Storybook if missing
|
|
661
|
+
const NUMBER_LIKE_OPTIONAL = new Set(["value", "amount", "total", "count", "hours", "minutes", "progress", "percent", "visibility"]);
|
|
662
|
+
const DATE_RANGE_DEFAULT = `{ dateRange: { from: new Date().toISOString(), to: new Date().toISOString() } }`;
|
|
663
|
+
for (const p of props) {
|
|
664
|
+
const type = String(p.type || "").trim();
|
|
665
|
+
const name = p.name;
|
|
666
|
+
if (added.has(name)) continue;
|
|
667
|
+
if (name === "filters" || /dateRange|Filter.*object/.test(type)) {
|
|
668
|
+
argLines.push(` ${name}: ${DATE_RANGE_DEFAULT},`);
|
|
669
|
+
added.add(name);
|
|
670
|
+
} else if (/number/.test(type) || NUMBER_LIKE_OPTIONAL.has(name)) {
|
|
671
|
+
argLines.push(` ${name}: ${name === "visibility" ? "1" : "0"},`);
|
|
672
|
+
added.add(name);
|
|
655
673
|
}
|
|
656
674
|
}
|
|
657
675
|
}
|
|
@@ -13,6 +13,7 @@ function run() {
|
|
|
13
13
|
try {
|
|
14
14
|
execSync('node vds-core/scan.mjs', { stdio: 'inherit', cwd: ROOT });
|
|
15
15
|
execSync('node vds-core/story-generator.mjs', { stdio: 'inherit', cwd: ROOT });
|
|
16
|
+
execSync('node vds-core/setup-storybook-providers.mjs', { stdio: 'inherit', cwd: ROOT });
|
|
16
17
|
console.log(`[VDS ${ts}] ✅ Design system güncellendi.`);
|
|
17
18
|
} catch (e) {
|
|
18
19
|
console.error(`[VDS ${ts}] ❌ Hata:`, e.message);
|