storybook-solidjs-vite 10.2.0 → 10.3.0

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/README.md CHANGED
@@ -9,16 +9,16 @@
9
9
  [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](./LICENSE)
10
10
  [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/solidjs-community/storybook/pulls)
11
11
 
12
- [Storybook](https://storybook.js.org/) **framework adapter** for [SolidJS](https://solidjs.com/), using Vite.
13
-
14
- Adds SolidJS support to Storybook.
12
+ [Storybook](https://storybook.js.org/) framework adapter for [SolidJS](https://solidjs.com/) on Vite.
15
13
 
16
14
  ## ✨ Features
17
15
 
18
16
  - [Solid 1](#solid-1) and [Solid 2](#solid-2) support
19
17
  - [Vite-powered builder](https://storybook.js.org/docs/builders/vite)
20
18
  - [TypeScript-first setup](https://storybook.js.org/docs/configure/integration/typescript)
21
- - Component props show up automatically in [Controls and Docs](#docgen)
19
+ - Automatic props in [Controls and Docs](#docgen)
20
+ - [Autodocs code snippets](#autodocs-code-snippets) — static JSX **Show code** blocks from story source (CSF Next + CSF3, enabled by default)
21
+ - [Components manifest](https://storybook.js.org/docs/ai/manifests) for AI agents ([debugger](#components-manifest-debugger))
22
22
  - [Storybook MCP](https://storybook.js.org/docs/ai/mcp/overview) support ([setup](#storybook-mcp))
23
23
  - [CSF Next](https://storybook.js.org/docs/api/csf/csf-next) factory API ([setup](#csf-next), optional)
24
24
  - [Integrated testing](https://storybook.js.org/docs/writing-tests) (Vitest, Playwright)
@@ -30,26 +30,18 @@ Run in your project:
30
30
 
31
31
  ```bash
32
32
  npx create-storybook --type=solid
33
- ```
34
-
35
- Then start Storybook:
36
-
37
- ```bash
38
- bun run storybook
33
+ npm run storybook
39
34
  ```
40
35
 
41
36
  Open the URL shown in the terminal.
42
37
 
43
38
  ## ⚙️ Configuration
44
39
 
45
- You can customize Vite and Storybook as usual.
46
-
47
- - Add stories in `src/**/*.stories.tsx` or `src/**/*.stories.js`
48
- - Use Storybook addons for additional functionality
40
+ Customize Vite and Storybook as usual. Add stories in `src/**/*.stories.{tsx,js}` and install addons as needed.
49
41
 
50
42
  ### Solid 1
51
43
 
52
- On Solid 1, import from `storybook-solidjs-vite` in config, preview, and stories:
44
+ Import from `storybook-solidjs-vite` in config, preview, and stories:
53
45
 
54
46
  ```ts
55
47
  // .storybook/main.ts
@@ -69,21 +61,19 @@ import type { Preview, Meta, StoryObj } from 'storybook-solidjs-vite';
69
61
 
70
62
  ### Solid 2
71
63
 
72
- On Solid 2, use `storybook-solidjs-vite/next` in preview and stories — the types there match the Solid 2 renderer:
64
+ Use `storybook-solidjs-vite/next` in preview and stories:
73
65
 
74
66
  ```ts
75
67
  import type { Preview, Meta, StoryObj } from 'storybook-solidjs-vite/next';
76
68
  ```
77
69
 
78
- Imports without `/next` often still run, but TypeScript may complain because those types describe the Solid 1 renderer.
70
+ Imports without `/next` may still run, but TypeScript can complain.
79
71
 
80
- In `main.ts` either framework name is fine: `storybook-solidjs-vite` reads the major version from your installed `solid-js`, and `storybook-solidjs-vite/next` forces Solid 2.
72
+ In `main.ts`, either framework name works: `storybook-solidjs-vite` reads the major version from `solid-js`; `storybook-solidjs-vite/next` forces Solid 2.
81
73
 
82
74
  ```ts
83
- // Solid 1 & 2
84
- framework: 'storybook-solidjs-vite'
85
- // Solid 2
86
- framework: 'storybook-solidjs-vite/next'
75
+ framework: 'storybook-solidjs-vite' // Solid auto-detect
76
+ framework: 'storybook-solidjs-vite/next' // Solid 2 only
87
77
  ```
88
78
 
89
79
  ### CSF Next
@@ -122,13 +112,11 @@ export const Primary = meta.story({
122
112
 
123
113
  ### Docgen
124
114
 
125
- TypeScript props for **Controls**, **Docs**, and the **components manifest** come from **React component-meta** (RCM) — a TypeScript LanguageService extractor aligned with Storybooks `react-component-meta` format.
126
-
127
- Docgen is **enabled by default**. The components manifest debugger is also enabled at:
115
+ Props for **Controls**, **Docs**, and the **components manifest** come from a TypeScript LanguageService extractor aligned with Storybook's `react-component-meta` format.
128
116
 
129
- `http://localhost:<port>/manifests/components.html`
117
+ Enabled by default. Inspect output in the [manifest debugger](#components-manifest-debugger).
130
118
 
131
- To disable docgen:
119
+ To disable:
132
120
 
133
121
  ```ts
134
122
  import type { StorybookConfig } from 'storybook-solidjs-vite';
@@ -136,9 +124,25 @@ import type { StorybookConfig } from 'storybook-solidjs-vite';
136
124
  const config: StorybookConfig = {
137
125
  framework: {
138
126
  name: 'storybook-solidjs-vite',
139
- options: {
140
- docgen: false,
141
- },
127
+ options: { docgen: false },
128
+ },
129
+ };
130
+
131
+ export default config;
132
+ ```
133
+
134
+ ### Autodocs code snippets
135
+
136
+ **Show code** blocks are static snippets generated from story source at index time (`experimentalCodeExamples`). Enabled by default.
137
+
138
+ To disable:
139
+
140
+ ```ts
141
+ import type { StorybookConfig } from 'storybook-solidjs-vite';
142
+
143
+ const config: StorybookConfig = {
144
+ features: {
145
+ experimentalCodeExamples: false
142
146
  },
143
147
  };
144
148
 
@@ -153,61 +157,57 @@ Solid projects can use [Storybook MCP](https://storybook.js.org/docs/ai/mcp/over
153
157
  npx storybook add @storybook/addon-mcp
154
158
  ```
155
159
 
156
- With Storybook running, the MCP server is at `http://localhost:<port>/mcp`. Connect your agent to that URL (see [Storybook MCP docs](https://storybook.js.org/docs/ai/mcp/overview#2-add-the-mcp-server-to-your-agent)). The components manifest debugger remains at `/manifests/components.html`.
160
+ See [Storybook MCP docs](https://storybook.js.org/docs/ai/mcp/overview#2-add-the-mcp-server-to-your-agent) for agent setup.
157
161
 
158
- ## 🎨 Decorators
162
+ ### Components manifest debugger
159
163
 
160
- On args or globals changes, Storybook re-runs decorators and storiesthe same model as React, where each update calls your functions again. Solid updates through fine-grained signals and usually does not need that.
164
+ Storybook builds [JSON manifests](https://storybook.js.org/docs/ai/manifests) from CSF stories and component source names, props, JSDoc, story ids, and more. Enabled by default (`features.componentsManifest`). Prop data comes from [docgen](#docgen); story snippets use the same [code generator](#autodocs-code-snippets).
165
+
166
+ While Storybook runs (or in a static build):
167
+
168
+ - **Debugger UI:** `http://localhost:6006/manifests/components.html` — browse manifests and generation errors/warnings
169
+ - **Components JSON:** `http://localhost:6006/manifests/components.json`
170
+ - **Docs JSON:** `http://localhost:6006/manifests/docs.json` (when MDX docs are present)
171
+
172
+ ## 🎨 Decorators
161
173
 
162
- If a decorator returns JSX, the extra runs can leave duplicate nodes in the DOM.
174
+ On args or globals changes, Storybook re-runs decorators and stories functions follows React reactivity model. Solid updates via fine-grained signals and usually doesn't need that. JSX decorators re-run can leave duplicate DOM nodes. To avoid this, use `createJSXDecorator` function to define decorators that return JSX.
163
175
 
164
176
  ### createJSXDecorator
165
177
 
166
- Use for decorators that return JSX. Ensures they run only once per story mount.
178
+ For decorators that return JSX. Runs once per story mount — `context.globals` and `context.args` are reactive stores, so bindings in JSX still update without re-running the decorator:
167
179
 
168
180
  ```tsx
169
181
  import { createJSXDecorator } from 'storybook-solidjs-vite';
170
182
 
171
- export const decorator = createJSXDecorator((Story) => {
172
- return (
173
- <main>
174
- <Story />
175
- </main>
176
- );
177
- });
183
+ export const withLayout = createJSXDecorator((Story, context) => (
184
+ <main data-theme={context.globals.theme}>
185
+ <Story />
186
+ </main>
187
+ ));
178
188
  ```
179
189
 
180
190
  ### createDecorator
181
191
 
182
- Use for decorators that do not return JSX.
192
+ For side effects that should run on every story update — e.g. sync `document.body` when globals change:
183
193
 
184
194
  ```tsx
185
195
  import { createDecorator } from 'storybook-solidjs-vite';
186
196
 
187
- export const decorator = createDecorator((Story) => {
197
+ export const withTheme = createDecorator((Story, context) => {
198
+ // Will run on every story update
199
+ document.body.setAttribute('data-theme', context.globals.theme);
188
200
  return Story();
189
201
  });
190
202
  ```
191
203
 
192
- ### Manual flag
193
-
194
- ```tsx
195
- import { IS_SOLID_JSX_FLAG } from 'storybook-solidjs-vite';
196
-
197
- export const decorator = (Story) => {
198
- return <div><Story /></div>;
199
- };
200
-
201
- decorator[IS_SOLID_JSX_FLAG] = true;
202
- ```
203
-
204
204
  ## 🔄 Migration from v9
205
205
 
206
- Check out [Migration Guide](./MIGRATION.md) for the instructions and breaking changes.
206
+ See [Migration Guide](./MIGRATION.md) for breaking changes.
207
207
 
208
208
  ## 🤝 Contributing
209
209
 
210
- Contributions, issues and feature requests are welcome! Feel free to [open an issue](https://github.com/solidjs-community/storybook/issues) or submit a PR.
210
+ Issues and PRs welcome [open an issue](https://github.com/solidjs-community/storybook/issues) or submit a pull request.
211
211
 
212
212
  ## 📖 License
213
213
 
@@ -1,7 +1,9 @@
1
- import { PresetProperty } from 'storybook/internal/types';
1
+ import { PresetPropertyFn, PresetProperty } from 'storybook/internal/types';
2
2
  import { S as StorybookConfig } from '../types-3qJHo3rN.js';
3
3
  import '@storybook/builder-vite';
4
4
 
5
+ declare const enrichCsf: PresetPropertyFn<'experimental_enrichCsf'>;
6
+
5
7
  type SerializedPropType = {
6
8
  name: string;
7
9
  raw?: string;
@@ -29,10 +31,10 @@ type ManifestEntry = {
29
31
  tags?: string[];
30
32
  storiesImports?: string[];
31
33
  };
32
- declare const experimental_manifests: (existingManifests: Record<string, unknown> | undefined, options: {
34
+ declare function generateComponentManifests(existingManifests: Record<string, unknown> | undefined, options: {
33
35
  manifestEntries: ManifestEntry[];
34
36
  watch?: boolean;
35
- }) => Promise<{
37
+ }): Promise<{
36
38
  components: {
37
39
  v: number;
38
40
  components: {
@@ -44,10 +46,22 @@ declare const experimental_manifests: (existingManifests: Record<string, unknown
44
46
  id: string;
45
47
  name: string;
46
48
  path: string;
47
- stories: {
49
+ stories: ({
50
+ id: string;
51
+ name: string;
52
+ snippet: string;
53
+ description: string;
54
+ error?: never;
55
+ } | {
48
56
  id: string;
49
57
  name: string;
50
- }[];
58
+ error: {
59
+ name: string;
60
+ message: string;
61
+ };
62
+ snippet?: never;
63
+ description?: never;
64
+ })[];
51
65
  import: string;
52
66
  jsDocTags: Record<string, string[]>;
53
67
  } | {
@@ -63,10 +77,22 @@ declare const experimental_manifests: (existingManifests: Record<string, unknown
63
77
  id: string;
64
78
  name: string;
65
79
  path: string;
66
- stories: {
80
+ stories: ({
81
+ id: string;
82
+ name: string;
83
+ snippet: string;
84
+ description: string;
85
+ error?: never;
86
+ } | {
67
87
  id: string;
68
88
  name: string;
69
- }[];
89
+ error: {
90
+ name: string;
91
+ message: string;
92
+ };
93
+ snippet?: never;
94
+ description?: never;
95
+ })[];
70
96
  import: string;
71
97
  jsDocTags: Record<string, string[]>;
72
98
  };
@@ -78,7 +104,7 @@ declare const experimental_manifests: (existingManifests: Record<string, unknown
78
104
  };
79
105
  };
80
106
  }>;
81
- declare function internal_getArgTypesData(_input: unknown, options?: {
107
+ declare function getArgTypesData(_input: unknown, options?: {
82
108
  componentFilePath?: string;
83
109
  componentExportName?: string;
84
110
  }): Promise<Record<string, unknown> | null>;
@@ -102,4 +128,4 @@ declare const features: PresetProperty<'features', StorybookConfig>;
102
128
  */
103
129
  declare const viteFinal: StorybookConfig['viteFinal'];
104
130
 
105
- export { core, experimental_manifests, features, internal_getArgTypesData, viteFinal };
131
+ export { core, enrichCsf as experimental_enrichCsf, generateComponentManifests as experimental_manifests, features, getArgTypesData as internal_getArgTypesData, viteFinal };