@tpitre/story-ui 2.2.0 → 2.3.1
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/.env.sample +82 -11
- package/README.md +89 -0
- package/dist/cli/deploy.d.ts +17 -0
- package/dist/cli/deploy.d.ts.map +1 -0
- package/dist/cli/deploy.js +696 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +26 -2
- package/dist/cli/setup.d.ts +11 -0
- package/dist/cli/setup.d.ts.map +1 -0
- package/dist/cli/setup.js +437 -110
- package/dist/mcp-server/index.d.ts +2 -0
- package/dist/mcp-server/index.d.ts.map +1 -0
- package/dist/mcp-server/index.js +120 -2
- package/dist/mcp-server/mcp-stdio-server.d.ts +3 -0
- package/dist/mcp-server/mcp-stdio-server.d.ts.map +1 -0
- package/dist/mcp-server/mcp-stdio-server.js +8 -1
- package/dist/mcp-server/routes/claude.d.ts +3 -0
- package/dist/mcp-server/routes/claude.d.ts.map +1 -0
- package/dist/mcp-server/routes/claude.js +60 -23
- package/dist/mcp-server/routes/components.d.ts +4 -0
- package/dist/mcp-server/routes/components.d.ts.map +1 -0
- package/dist/mcp-server/routes/frameworks.d.ts +38 -0
- package/dist/mcp-server/routes/frameworks.d.ts.map +1 -0
- package/dist/mcp-server/routes/frameworks.js +183 -0
- package/dist/mcp-server/routes/generateStory.d.ts +3 -0
- package/dist/mcp-server/routes/generateStory.d.ts.map +1 -0
- package/dist/mcp-server/routes/generateStory.js +160 -76
- package/dist/mcp-server/routes/generateStoryStream.d.ts +12 -0
- package/dist/mcp-server/routes/generateStoryStream.d.ts.map +1 -0
- package/dist/mcp-server/routes/generateStoryStream.js +947 -0
- package/dist/mcp-server/routes/hybridStories.d.ts +18 -0
- package/dist/mcp-server/routes/hybridStories.d.ts.map +1 -0
- package/dist/mcp-server/routes/mcpRemote.d.ts +14 -0
- package/dist/mcp-server/routes/mcpRemote.d.ts.map +1 -0
- package/dist/mcp-server/routes/mcpRemote.js +489 -0
- package/dist/mcp-server/routes/memoryStories.d.ts +26 -0
- package/dist/mcp-server/routes/memoryStories.d.ts.map +1 -0
- package/dist/mcp-server/routes/providers.d.ts +89 -0
- package/dist/mcp-server/routes/providers.d.ts.map +1 -0
- package/dist/mcp-server/routes/providers.js +369 -0
- package/dist/mcp-server/routes/storySync.d.ts +26 -0
- package/dist/mcp-server/routes/storySync.d.ts.map +1 -0
- package/dist/mcp-server/routes/streamTypes.d.ts +110 -0
- package/dist/mcp-server/routes/streamTypes.d.ts.map +1 -0
- package/dist/mcp-server/routes/streamTypes.js +18 -0
- package/dist/mcp-server/sessionManager.d.ts +50 -0
- package/dist/mcp-server/sessionManager.d.ts.map +1 -0
- package/dist/story-generator/componentBlacklist.d.ts +21 -0
- package/dist/story-generator/componentBlacklist.d.ts.map +1 -0
- package/dist/story-generator/componentDiscovery.d.ts +28 -0
- package/dist/story-generator/componentDiscovery.d.ts.map +1 -0
- package/dist/story-generator/componentRegistryGenerator.d.ts +49 -0
- package/dist/story-generator/componentRegistryGenerator.d.ts.map +1 -0
- package/dist/story-generator/componentRegistryGenerator.js +205 -0
- package/dist/story-generator/configLoader.d.ts +33 -0
- package/dist/story-generator/configLoader.d.ts.map +1 -0
- package/dist/story-generator/considerationsLoader.d.ts +32 -0
- package/dist/story-generator/considerationsLoader.d.ts.map +1 -0
- package/dist/story-generator/documentation-sources.d.ts +28 -0
- package/dist/story-generator/documentation-sources.d.ts.map +1 -0
- package/dist/story-generator/documentationLoader.d.ts +64 -0
- package/dist/story-generator/documentationLoader.d.ts.map +1 -0
- package/dist/story-generator/dynamicPackageDiscovery.d.ts +97 -0
- package/dist/story-generator/dynamicPackageDiscovery.d.ts.map +1 -0
- package/dist/story-generator/enhancedComponentDiscovery.d.ts +125 -0
- package/dist/story-generator/enhancedComponentDiscovery.d.ts.map +1 -0
- package/dist/story-generator/enhancedComponentDiscovery.js +111 -11
- package/dist/story-generator/framework-adapters/angular-adapter.d.ts +40 -0
- package/dist/story-generator/framework-adapters/angular-adapter.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/angular-adapter.js +427 -0
- package/dist/story-generator/framework-adapters/base-adapter.d.ts +75 -0
- package/dist/story-generator/framework-adapters/base-adapter.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/base-adapter.js +147 -0
- package/dist/story-generator/framework-adapters/framework-detector.d.ts +55 -0
- package/dist/story-generator/framework-adapters/framework-detector.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/framework-detector.js +323 -0
- package/dist/story-generator/framework-adapters/index.d.ts +97 -0
- package/dist/story-generator/framework-adapters/index.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/index.js +198 -0
- package/dist/story-generator/framework-adapters/react-adapter.d.ts +40 -0
- package/dist/story-generator/framework-adapters/react-adapter.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/react-adapter.js +316 -0
- package/dist/story-generator/framework-adapters/svelte-adapter.d.ts +40 -0
- package/dist/story-generator/framework-adapters/svelte-adapter.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/svelte-adapter.js +372 -0
- package/dist/story-generator/framework-adapters/types.d.ts +182 -0
- package/dist/story-generator/framework-adapters/types.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/types.js +8 -0
- package/dist/story-generator/framework-adapters/vue-adapter.d.ts +36 -0
- package/dist/story-generator/framework-adapters/vue-adapter.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/vue-adapter.js +336 -0
- package/dist/story-generator/framework-adapters/web-components-adapter.d.ts +54 -0
- package/dist/story-generator/framework-adapters/web-components-adapter.d.ts.map +1 -0
- package/dist/story-generator/framework-adapters/web-components-adapter.js +387 -0
- package/dist/story-generator/generateStory.d.ts +7 -0
- package/dist/story-generator/generateStory.d.ts.map +1 -0
- package/dist/story-generator/gitignoreManager.d.ts +50 -0
- package/dist/story-generator/gitignoreManager.d.ts.map +1 -0
- package/dist/story-generator/imageProcessor.d.ts +80 -0
- package/dist/story-generator/imageProcessor.d.ts.map +1 -0
- package/dist/story-generator/imageProcessor.js +391 -0
- package/dist/story-generator/inMemoryStoryService.d.ts +89 -0
- package/dist/story-generator/inMemoryStoryService.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/base-provider.d.ts +36 -0
- package/dist/story-generator/llm-providers/base-provider.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/base-provider.js +135 -0
- package/dist/story-generator/llm-providers/claude-provider.d.ts +23 -0
- package/dist/story-generator/llm-providers/claude-provider.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/claude-provider.js +414 -0
- package/dist/story-generator/llm-providers/gemini-provider.d.ts +24 -0
- package/dist/story-generator/llm-providers/gemini-provider.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/gemini-provider.js +406 -0
- package/dist/story-generator/llm-providers/index.d.ts +63 -0
- package/dist/story-generator/llm-providers/index.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/index.js +169 -0
- package/dist/story-generator/llm-providers/openai-provider.d.ts +24 -0
- package/dist/story-generator/llm-providers/openai-provider.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/openai-provider.js +458 -0
- package/dist/story-generator/llm-providers/settings-manager.d.ts +75 -0
- package/dist/story-generator/llm-providers/settings-manager.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/settings-manager.js +173 -0
- package/dist/story-generator/llm-providers/story-llm-service.d.ts +79 -0
- package/dist/story-generator/llm-providers/story-llm-service.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/story-llm-service.js +240 -0
- package/dist/story-generator/llm-providers/types.d.ts +153 -0
- package/dist/story-generator/llm-providers/types.d.ts.map +1 -0
- package/dist/story-generator/llm-providers/types.js +8 -0
- package/dist/story-generator/logger.d.ts +14 -0
- package/dist/story-generator/logger.d.ts.map +1 -0
- package/dist/story-generator/logger.js +96 -29
- package/dist/story-generator/postProcessStory.d.ts +6 -0
- package/dist/story-generator/postProcessStory.d.ts.map +1 -0
- package/dist/story-generator/productionGitignoreManager.d.ts +91 -0
- package/dist/story-generator/productionGitignoreManager.d.ts.map +1 -0
- package/dist/story-generator/promptGenerator.d.ts +48 -0
- package/dist/story-generator/promptGenerator.d.ts.map +1 -0
- package/dist/story-generator/promptGenerator.js +186 -1
- package/dist/story-generator/storyHistory.d.ts +44 -0
- package/dist/story-generator/storyHistory.d.ts.map +1 -0
- package/dist/story-generator/storySync.d.ts +68 -0
- package/dist/story-generator/storySync.d.ts.map +1 -0
- package/dist/story-generator/storyTracker.d.ts +48 -0
- package/dist/story-generator/storyTracker.d.ts.map +1 -0
- package/dist/story-generator/storyValidator.d.ts +6 -0
- package/dist/story-generator/storyValidator.d.ts.map +1 -0
- package/dist/story-generator/universalDesignSystemAdapter.d.ts +68 -0
- package/dist/story-generator/universalDesignSystemAdapter.d.ts.map +1 -0
- package/dist/story-generator/universalDesignSystemAdapter.js +138 -1
- package/dist/story-generator/urlRedirectService.d.ts +21 -0
- package/dist/story-generator/urlRedirectService.d.ts.map +1 -0
- package/dist/story-generator/validateStory.d.ts +19 -0
- package/dist/story-generator/validateStory.d.ts.map +1 -0
- package/dist/story-generator/validateStory.js +6 -2
- package/dist/story-generator/visionPrompts.d.ts +88 -0
- package/dist/story-generator/visionPrompts.d.ts.map +1 -0
- package/dist/story-generator/visionPrompts.js +462 -0
- package/dist/story-ui.config.d.ts +78 -0
- package/dist/story-ui.config.d.ts.map +1 -0
- package/dist/templates/StoryUI/StoryUIPanel.d.ts +4 -0
- package/dist/templates/StoryUI/StoryUIPanel.d.ts.map +1 -0
- package/dist/templates/StoryUI/StoryUIPanel.js +1874 -0
- package/dist/templates/StoryUI/StoryUIPanel.stories.d.ts +18 -0
- package/dist/templates/StoryUI/StoryUIPanel.stories.d.ts.map +1 -0
- package/dist/templates/StoryUI/StoryUIPanel.stories.js +37 -0
- package/dist/templates/StoryUI/index.d.ts +3 -0
- package/dist/templates/StoryUI/index.d.ts.map +1 -0
- package/dist/templates/StoryUI/index.js +2 -0
- package/package.json +17 -3
- package/templates/StoryUI/StoryUIPanel.tsx +1960 -384
- package/templates/StoryUI/index.tsx +1 -1
- package/templates/StoryUI/manager.tsx +264 -0
- package/templates/production-app/.env.example +11 -0
- package/templates/production-app/index.html +66 -0
- package/templates/production-app/package.json +30 -0
- package/templates/production-app/public/favicon.svg +5 -0
- package/templates/production-app/src/App.tsx +1560 -0
- package/templates/production-app/src/LivePreviewRenderer.tsx +420 -0
- package/templates/production-app/src/componentRegistry.ts +315 -0
- package/templates/production-app/src/considerations.ts +16 -0
- package/templates/production-app/src/index.css +284 -0
- package/templates/production-app/src/main.tsx +25 -0
- package/templates/production-app/tsconfig.json +32 -0
- package/templates/production-app/tsconfig.node.json +11 -0
- package/templates/production-app/vite.config.ts +83 -0
- package/templates/react-import-rule.json +2 -2
- package/dist/index.js +0 -12
- package/dist/story-ui.config.loader.js +0 -205
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue Framework Adapter
|
|
3
|
+
*
|
|
4
|
+
* Generates Storybook stories for Vue 3 components.
|
|
5
|
+
* Supports Composition API and Options API.
|
|
6
|
+
*/
|
|
7
|
+
import { BaseFrameworkAdapter } from './base-adapter.js';
|
|
8
|
+
export class VueAdapter extends BaseFrameworkAdapter {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
11
|
+
this.type = 'vue';
|
|
12
|
+
this.name = 'Vue';
|
|
13
|
+
this.supportedStoryFrameworks = [
|
|
14
|
+
'storybook-vue3',
|
|
15
|
+
'histoire',
|
|
16
|
+
'chromatic',
|
|
17
|
+
];
|
|
18
|
+
this.defaultExtension = '.stories.ts';
|
|
19
|
+
}
|
|
20
|
+
generateSystemPrompt(config, options) {
|
|
21
|
+
if (config.systemPrompt) {
|
|
22
|
+
return config.systemPrompt;
|
|
23
|
+
}
|
|
24
|
+
const componentSystemName = config.componentPrefix
|
|
25
|
+
? `${config.componentPrefix.replace(/^[A-Z]+/, '')} design system`
|
|
26
|
+
: 'component library';
|
|
27
|
+
return `You are an expert Vue 3 developer creating Storybook stories using CSF 3.0 format.
|
|
28
|
+
Use ONLY the Vue components from the ${componentSystemName} listed below.
|
|
29
|
+
|
|
30
|
+
MANDATORY IMPORTS - First lines of every story file:
|
|
31
|
+
1. import type { Meta, StoryObj } from '@storybook/vue3';
|
|
32
|
+
2. import { ComponentName } from '${config.importPath || 'your-library'}';
|
|
33
|
+
|
|
34
|
+
VUE 3 STORY FORMAT:
|
|
35
|
+
- Use Vue 3 Composition API style
|
|
36
|
+
- Components can use render functions or template syntax
|
|
37
|
+
- Props are passed via args
|
|
38
|
+
- Events use v-on or @ shorthand
|
|
39
|
+
|
|
40
|
+
STORY STRUCTURE (CSF 3.0):
|
|
41
|
+
- Meta object with component, title, and parameters
|
|
42
|
+
- Use render function for complex templates
|
|
43
|
+
- Export named stories as StoryObj
|
|
44
|
+
|
|
45
|
+
CRITICAL RULES:
|
|
46
|
+
- Import components from the library, NOT .vue files
|
|
47
|
+
- Use render functions for dynamic content
|
|
48
|
+
- Slots use v-slot directive or # shorthand
|
|
49
|
+
|
|
50
|
+
Example structure:
|
|
51
|
+
\`\`\`typescript
|
|
52
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
53
|
+
import { Button } from 'your-library';
|
|
54
|
+
|
|
55
|
+
const meta: Meta<typeof Button> = {
|
|
56
|
+
title: 'Components/Button',
|
|
57
|
+
component: Button,
|
|
58
|
+
tags: ['autodocs'],
|
|
59
|
+
argTypes: {
|
|
60
|
+
variant: {
|
|
61
|
+
control: 'select',
|
|
62
|
+
options: ['primary', 'secondary', 'ghost'],
|
|
63
|
+
},
|
|
64
|
+
onClick: { action: 'clicked' },
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default meta;
|
|
69
|
+
type Story = StoryObj<typeof meta>;
|
|
70
|
+
|
|
71
|
+
export const Primary: Story = {
|
|
72
|
+
args: {
|
|
73
|
+
variant: 'primary',
|
|
74
|
+
label: 'Click me',
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export const WithSlot: Story = {
|
|
79
|
+
render: (args) => ({
|
|
80
|
+
components: { Button },
|
|
81
|
+
setup() {
|
|
82
|
+
return { args };
|
|
83
|
+
},
|
|
84
|
+
template: \`
|
|
85
|
+
<Button v-bind="args">
|
|
86
|
+
<template #icon>
|
|
87
|
+
<span>★</span>
|
|
88
|
+
</template>
|
|
89
|
+
Click me
|
|
90
|
+
</Button>
|
|
91
|
+
\`,
|
|
92
|
+
}),
|
|
93
|
+
};
|
|
94
|
+
\`\`\`
|
|
95
|
+
|
|
96
|
+
TEMPLATE VS RENDER FUNCTION:
|
|
97
|
+
- Simple props: Use args directly
|
|
98
|
+
- Slots/complex content: Use render function with template
|
|
99
|
+
- Dynamic content: Use render function with setup()
|
|
100
|
+
|
|
101
|
+
SLOT SYNTAX:
|
|
102
|
+
- Default slot: Content between tags
|
|
103
|
+
- Named slots: <template #name> or <template v-slot:name>
|
|
104
|
+
- Scoped slots: <template #default="{ item }">
|
|
105
|
+
|
|
106
|
+
EVENT HANDLING:
|
|
107
|
+
- Use @event or v-on:event syntax
|
|
108
|
+
- Use action argTypes to log events in Storybook
|
|
109
|
+
|
|
110
|
+
${this.getCommonRules()}`;
|
|
111
|
+
}
|
|
112
|
+
generateExamples(config) {
|
|
113
|
+
const lib = config.importPath || 'your-library';
|
|
114
|
+
return `
|
|
115
|
+
## Example Stories for Vue 3
|
|
116
|
+
|
|
117
|
+
### Single Component Story
|
|
118
|
+
\`\`\`typescript
|
|
119
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
120
|
+
import { Button } from 'your-library';
|
|
121
|
+
|
|
122
|
+
const meta: Meta<typeof Button> = {
|
|
123
|
+
title: 'Components/Button',
|
|
124
|
+
component: Button,
|
|
125
|
+
tags: ['autodocs'],
|
|
126
|
+
argTypes: {
|
|
127
|
+
variant: {
|
|
128
|
+
control: 'select',
|
|
129
|
+
options: ['primary', 'secondary', 'ghost'],
|
|
130
|
+
},
|
|
131
|
+
size: {
|
|
132
|
+
control: 'select',
|
|
133
|
+
options: ['small', 'medium', 'large'],
|
|
134
|
+
},
|
|
135
|
+
onClick: { action: 'clicked' },
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export default meta;
|
|
140
|
+
type Story = StoryObj<typeof meta>;
|
|
141
|
+
|
|
142
|
+
export const Default: Story = {
|
|
143
|
+
args: {
|
|
144
|
+
variant: 'primary',
|
|
145
|
+
size: 'medium',
|
|
146
|
+
label: 'Button',
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export const AllVariants: Story = {
|
|
151
|
+
render: () => ({
|
|
152
|
+
components: { Button },
|
|
153
|
+
template: \`
|
|
154
|
+
<div style="display: flex; gap: 8px;">
|
|
155
|
+
<Button variant="primary">Primary</Button>
|
|
156
|
+
<Button variant="secondary">Secondary</Button>
|
|
157
|
+
<Button variant="ghost">Ghost</Button>
|
|
158
|
+
</div>
|
|
159
|
+
\`,
|
|
160
|
+
}),
|
|
161
|
+
};
|
|
162
|
+
\`\`\`
|
|
163
|
+
|
|
164
|
+
### With Slots
|
|
165
|
+
\`\`\`typescript
|
|
166
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
167
|
+
import { Card, Button, Text } from '${lib}';
|
|
168
|
+
|
|
169
|
+
const meta: Meta<typeof Card> = {
|
|
170
|
+
title: 'Components/Card',
|
|
171
|
+
component: Card,
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
export default meta;
|
|
175
|
+
type Story = StoryObj<typeof meta>;
|
|
176
|
+
|
|
177
|
+
export const WithSlots: Story = {
|
|
178
|
+
render: () => ({
|
|
179
|
+
components: { Card, Button, Text },
|
|
180
|
+
template: \`
|
|
181
|
+
<Card style="width: 300px">
|
|
182
|
+
<template #header>
|
|
183
|
+
<Text variant="heading">Card Title</Text>
|
|
184
|
+
</template>
|
|
185
|
+
|
|
186
|
+
<Text>This is the card content using the default slot.</Text>
|
|
187
|
+
|
|
188
|
+
<template #footer>
|
|
189
|
+
<Button variant="primary">Action</Button>
|
|
190
|
+
</template>
|
|
191
|
+
</Card>
|
|
192
|
+
\`,
|
|
193
|
+
}),
|
|
194
|
+
};
|
|
195
|
+
\`\`\`
|
|
196
|
+
|
|
197
|
+
### With Reactive State
|
|
198
|
+
\`\`\`typescript
|
|
199
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
200
|
+
import { ref } from 'vue';
|
|
201
|
+
import { Input } from '${lib}';
|
|
202
|
+
|
|
203
|
+
const meta: Meta<typeof Input> = {
|
|
204
|
+
title: 'Components/Input',
|
|
205
|
+
component: Input,
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
export default meta;
|
|
209
|
+
type Story = StoryObj<typeof meta>;
|
|
210
|
+
|
|
211
|
+
export const Controlled: Story = {
|
|
212
|
+
render: () => ({
|
|
213
|
+
components: { Input },
|
|
214
|
+
setup() {
|
|
215
|
+
const value = ref('');
|
|
216
|
+
return { value };
|
|
217
|
+
},
|
|
218
|
+
template: \`
|
|
219
|
+
<div>
|
|
220
|
+
<Input v-model="value" placeholder="Type here..." />
|
|
221
|
+
<p>Value: {{ value }}</p>
|
|
222
|
+
</div>
|
|
223
|
+
\`,
|
|
224
|
+
}),
|
|
225
|
+
};
|
|
226
|
+
\`\`\`
|
|
227
|
+
`;
|
|
228
|
+
}
|
|
229
|
+
generateSampleStory(config, components) {
|
|
230
|
+
const lib = config.importPath || 'your-library';
|
|
231
|
+
const firstComponent = components[0];
|
|
232
|
+
if (!firstComponent) {
|
|
233
|
+
return `
|
|
234
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
235
|
+
|
|
236
|
+
const meta: Meta = {
|
|
237
|
+
title: 'Examples/Sample',
|
|
238
|
+
parameters: { layout: 'centered' },
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
export default meta;
|
|
242
|
+
type Story = StoryObj;
|
|
243
|
+
|
|
244
|
+
export const Default: Story = {
|
|
245
|
+
render: () => ({
|
|
246
|
+
template: '<div>Sample story content</div>',
|
|
247
|
+
}),
|
|
248
|
+
};
|
|
249
|
+
`;
|
|
250
|
+
}
|
|
251
|
+
return `
|
|
252
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
253
|
+
import { ${firstComponent.name} } from '${lib}';
|
|
254
|
+
|
|
255
|
+
const meta: Meta<typeof ${firstComponent.name}> = {
|
|
256
|
+
title: 'Components/${firstComponent.name}',
|
|
257
|
+
component: ${firstComponent.name},
|
|
258
|
+
tags: ['autodocs'],
|
|
259
|
+
parameters: { layout: 'centered' },
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
export default meta;
|
|
263
|
+
type Story = StoryObj<typeof meta>;
|
|
264
|
+
|
|
265
|
+
export const Default: Story = {
|
|
266
|
+
args: {},
|
|
267
|
+
};
|
|
268
|
+
`;
|
|
269
|
+
}
|
|
270
|
+
getStoryTemplate(options) {
|
|
271
|
+
return `
|
|
272
|
+
// {{componentName}}.stories.ts
|
|
273
|
+
import type { Meta, StoryObj } from '@storybook/vue3';
|
|
274
|
+
import { {{componentName}} } from '{{importPath}}';
|
|
275
|
+
|
|
276
|
+
const meta: Meta<typeof {{componentName}}> = {
|
|
277
|
+
title: '{{category}}/{{componentName}}',
|
|
278
|
+
component: {{componentName}},
|
|
279
|
+
tags: ['autodocs'],
|
|
280
|
+
parameters: { layout: 'centered' },
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
export default meta;
|
|
284
|
+
type Story = StoryObj<typeof meta>;
|
|
285
|
+
|
|
286
|
+
export const Default: Story = {
|
|
287
|
+
args: {},
|
|
288
|
+
};
|
|
289
|
+
`;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Post-process Vue stories
|
|
293
|
+
*/
|
|
294
|
+
postProcess(storyContent) {
|
|
295
|
+
let processed = super.postProcess(storyContent);
|
|
296
|
+
// Remove React imports if present
|
|
297
|
+
processed = processed.replace(/import React from ['"]react['"];?\n?/g, '');
|
|
298
|
+
// Fix JSX to Vue template syntax
|
|
299
|
+
processed = processed
|
|
300
|
+
// Fix className to class
|
|
301
|
+
.replace(/className=/g, 'class=')
|
|
302
|
+
// Fix onClick to @click
|
|
303
|
+
.replace(/onClick=/g, '@click=')
|
|
304
|
+
.replace(/onChange=/g, '@change=')
|
|
305
|
+
.replace(/onInput=/g, '@input=');
|
|
306
|
+
return processed;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Validate Vue story
|
|
310
|
+
*/
|
|
311
|
+
validate(storyContent) {
|
|
312
|
+
const baseValidation = super.validate(storyContent);
|
|
313
|
+
const errors = [...baseValidation.errors];
|
|
314
|
+
// Vue-specific validations
|
|
315
|
+
if (!storyContent.includes('@storybook/vue3')) {
|
|
316
|
+
errors.push("Missing '@storybook/vue3' import");
|
|
317
|
+
}
|
|
318
|
+
if (storyContent.includes("import React from 'react'")) {
|
|
319
|
+
errors.push('React import found in Vue story');
|
|
320
|
+
}
|
|
321
|
+
// Check for JSX-style event handlers
|
|
322
|
+
if (/onClick=\{/.test(storyContent)) {
|
|
323
|
+
errors.push('Using JSX-style event handlers instead of Vue @event syntax');
|
|
324
|
+
}
|
|
325
|
+
return {
|
|
326
|
+
valid: errors.length === 0,
|
|
327
|
+
errors,
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* Factory function
|
|
333
|
+
*/
|
|
334
|
+
export function createVueAdapter() {
|
|
335
|
+
return new VueAdapter();
|
|
336
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web Components Framework Adapter
|
|
3
|
+
*
|
|
4
|
+
* Generates Storybook stories for Web Components (Lit, vanilla, etc.).
|
|
5
|
+
* Supports standard Web Components and Lit framework.
|
|
6
|
+
*/
|
|
7
|
+
import { FrameworkType, StoryFramework, StoryGenerationOptions } from './types.js';
|
|
8
|
+
import { BaseFrameworkAdapter } from './base-adapter.js';
|
|
9
|
+
import { StoryUIConfig } from '../../story-ui.config.js';
|
|
10
|
+
import { DiscoveredComponent } from '../componentDiscovery.js';
|
|
11
|
+
export declare class WebComponentsAdapter extends BaseFrameworkAdapter {
|
|
12
|
+
readonly type: FrameworkType;
|
|
13
|
+
readonly name = "Web Components";
|
|
14
|
+
readonly supportedStoryFrameworks: StoryFramework[];
|
|
15
|
+
readonly defaultExtension = ".stories.ts";
|
|
16
|
+
generateSystemPrompt(config: StoryUIConfig, options?: StoryGenerationOptions): string;
|
|
17
|
+
generateExamples(config: StoryUIConfig): string;
|
|
18
|
+
generateSampleStory(config: StoryUIConfig, components: DiscoveredComponent[]): string;
|
|
19
|
+
getStoryTemplate(options?: StoryGenerationOptions): string;
|
|
20
|
+
/**
|
|
21
|
+
* Convert PascalCase to kebab-case
|
|
22
|
+
*/
|
|
23
|
+
private toKebabCase;
|
|
24
|
+
/**
|
|
25
|
+
* Post-process Web Components stories
|
|
26
|
+
*/
|
|
27
|
+
postProcess(storyContent: string): string;
|
|
28
|
+
/**
|
|
29
|
+
* Fix nested template literal escaping issues
|
|
30
|
+
*
|
|
31
|
+
* Problem: LLMs generate code like:
|
|
32
|
+
* innerHTML: \`<sl-icon></sl-icon>\`
|
|
33
|
+
*
|
|
34
|
+
* This causes Babel syntax errors. The fix converts problematic patterns
|
|
35
|
+
* to use string concatenation instead of nested template literals.
|
|
36
|
+
*/
|
|
37
|
+
private fixNestedTemplateLiterals;
|
|
38
|
+
/**
|
|
39
|
+
* Validate Web Components story
|
|
40
|
+
*/
|
|
41
|
+
validate(storyContent: string): {
|
|
42
|
+
valid: boolean;
|
|
43
|
+
errors: string[];
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Generate import statements for Web Components
|
|
47
|
+
*/
|
|
48
|
+
generateImports(components: DiscoveredComponent[], config: StoryUIConfig): string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Factory function
|
|
52
|
+
*/
|
|
53
|
+
export declare function createWebComponentsAdapter(): WebComponentsAdapter;
|
|
54
|
+
//# sourceMappingURL=web-components-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web-components-adapter.d.ts","sourceRoot":"","sources":["../../../story-generator/framework-adapters/web-components-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,aAAa,EACb,cAAc,EACd,sBAAsB,EACvB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,qBAAa,oBAAqB,SAAQ,oBAAoB;IAC5D,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAoB;IAChD,QAAQ,CAAC,IAAI,oBAAoB;IACjC,QAAQ,CAAC,wBAAwB,EAAE,cAAc,EAAE,CAGjD;IACF,QAAQ,CAAC,gBAAgB,iBAAiB;IAE1C,oBAAoB,CAClB,MAAM,EAAE,aAAa,EACrB,OAAO,CAAC,EAAE,sBAAsB,GAC/B,MAAM;IA4FT,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM;IA0G/C,mBAAmB,CACjB,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,mBAAmB,EAAE,GAChC,MAAM;IA8CT,gBAAgB,CAAC,OAAO,CAAC,EAAE,sBAAsB,GAAG,MAAM;IAsB1D;;OAEG;IACH,OAAO,CAAC,WAAW;IAOnB;;OAEG;IACH,WAAW,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;IA+BzC;;;;;;;;OAQG;IACH,OAAO,CAAC,yBAAyB;IAiCjC;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE;IAwBpE;;OAEG;IACH,eAAe,CACb,UAAU,EAAE,mBAAmB,EAAE,EACjC,MAAM,EAAE,aAAa,GACpB,MAAM;CAYV;AAED;;GAEG;AACH,wBAAgB,0BAA0B,IAAI,oBAAoB,CAEjE"}
|