storybook-solidjs-vite 10.1.2 → 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 +76 -68
- package/dist/SolidComponentMetaManager-KXVARPHU.js +4 -0
- package/dist/SolidComponentMetaManager-KXVARPHU.js.map +1 -0
- package/dist/chunk-6566KBHG.js +816 -0
- package/dist/chunk-6566KBHG.js.map +1 -0
- package/dist/{chunk-4GZSFB75.js → chunk-7IQZHF5A.js} +3 -3
- package/dist/chunk-7IQZHF5A.js.map +1 -0
- package/dist/chunk-FGHVLJAL.js +42 -0
- package/dist/chunk-FGHVLJAL.js.map +1 -0
- package/dist/{chunk-XQXXS54C.js → chunk-GF3JOYAC.js} +7 -8
- package/dist/chunk-GF3JOYAC.js.map +1 -0
- package/dist/chunk-GZ3XWUGK.js +65 -0
- package/dist/chunk-GZ3XWUGK.js.map +1 -0
- package/dist/{chunk-W3QB2KPF.js → chunk-H7QHQTFU.js} +3 -3
- package/dist/{chunk-W3QB2KPF.js.map → chunk-H7QHQTFU.js.map} +1 -1
- package/dist/chunk-PZ5AY32C.js +9 -0
- package/dist/{chunk-G3PMV62Z.js.map → chunk-PZ5AY32C.js.map} +1 -1
- package/dist/{chunk-W35XFTHU.js → chunk-QRPXDQGQ.js} +4 -4
- package/dist/{chunk-W35XFTHU.js.map → chunk-QRPXDQGQ.js.map} +1 -1
- package/dist/entry-preview/argtypes.d.ts +2 -3
- package/dist/entry-preview/argtypes.js +2 -2
- package/dist/entry-preview/docs.js +2 -2
- package/dist/entry-preview/solid-1.js +2 -2
- package/dist/entry-preview/solid-2.js +2 -2
- package/dist/framework/node.d.ts +1 -2
- package/dist/framework/node.js +1 -1
- package/dist/framework/preset.d.ts +116 -4
- package/dist/framework/preset.js +970 -11
- package/dist/framework/preset.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +5 -5
- package/dist/next.d.ts +1 -2
- package/dist/next.js +5 -5
- package/dist/renderer/playwright.js +1 -1
- package/dist/renderer.js +1 -1
- package/dist/toDocgenInfo-PQOQHVB2.js +4 -0
- package/dist/toDocgenInfo-PQOQHVB2.js.map +1 -0
- package/dist/{types-CixQ_ttK.d.ts → types-3qJHo3rN.d.ts} +3 -45
- package/package.json +6 -13
- package/src/codeExamples/enrichCsf.ts +106 -0
- package/src/codeExamples/generateCodeSnippet.test.ts +235 -0
- package/src/codeExamples/generateCodeSnippet.ts +728 -0
- package/src/codeExamples/invariant.ts +11 -0
- package/src/componentManifest/getComponents.ts +276 -0
- package/src/componentManifest/manifests.ts +257 -0
- package/src/componentManifest/solidComponentMeta/SolidComponentMetaManager.ts +260 -0
- package/src/componentManifest/solidComponentMeta/SolidComponentMetaProject.ts +421 -0
- package/src/componentManifest/solidComponentMeta/resolveProps.ts +494 -0
- package/src/componentManifest/solidComponentMetaPlugin.ts +67 -0
- package/src/componentManifest/toDocgenInfo.ts +57 -0
- package/src/componentManifest/types.ts +48 -0
- package/src/framework/preset.ts +23 -21
- package/src/framework/types.ts +3 -3
- package/src/renderer/docs/entry-preview-argtypes.ts +69 -4
- package/src/renderer/shared/create-define-preview.ts +0 -1
- package/src/renderer/v1/entry-preview.ts +3 -3
- package/src/renderer/v2/entry-preview.ts +8 -10
- package/template/cli-v2/js/Button.jsx +29 -0
- package/template/cli-v2/js/Button.stories.js +52 -0
- package/template/cli-v2/js/Header.jsx +54 -0
- package/template/cli-v2/js/Header.stories.js +32 -0
- package/template/cli-v2/js/Page.jsx +76 -0
- package/template/cli-v2/js/Page.stories.js +33 -0
- package/template/cli-v2/ts/Button.stories.ts +55 -0
- package/template/cli-v2/ts/Button.tsx +37 -0
- package/template/cli-v2/ts/Header.stories.ts +35 -0
- package/template/cli-v2/ts/Header.tsx +63 -0
- package/template/cli-v2/ts/Page.stories.ts +36 -0
- package/template/cli-v2/ts/Page.tsx +77 -0
- package/dist/chunk-4GZSFB75.js.map +0 -1
- package/dist/chunk-G3PMV62Z.js +0 -33
- package/dist/chunk-SHOV6BHW.js +0 -18415
- package/dist/chunk-SHOV6BHW.js.map +0 -1
- package/dist/chunk-XQXXS54C.js.map +0 -1
- package/src/renderer/docs/extractArgTypes.ts +0 -86
- package/src/renderer/docs/lib/captions.ts +0 -6
- package/src/renderer/docs/lib/defaultValues/createDefaultValue.ts +0 -87
- package/src/renderer/docs/lib/defaultValues/createFromRawDefaultProp.ts +0 -183
- package/src/renderer/docs/lib/defaultValues/generateArray.ts +0 -24
- package/src/renderer/docs/lib/defaultValues/generateObject.ts +0 -24
- package/src/renderer/docs/lib/defaultValues/index.ts +0 -2
- package/src/renderer/docs/lib/defaultValues/prettyIdentifier.ts +0 -28
- package/src/renderer/docs/lib/generateCode.ts +0 -70
- package/src/renderer/docs/lib/inspection/acornParser.test.ts +0 -257
- package/src/renderer/docs/lib/inspection/acornParser.ts +0 -241
- package/src/renderer/docs/lib/inspection/index.ts +0 -2
- package/src/renderer/docs/lib/inspection/inspectValue.ts +0 -17
- package/src/renderer/docs/lib/inspection/types.ts +0 -65
- package/src/renderer/docs/lib/isHtmlTag.ts +0 -5
- package/src/renderer/docs/propTypes/createType.ts +0 -433
- package/src/renderer/docs/propTypes/generateFuncSignature.ts +0 -70
- package/src/renderer/docs/propTypes/handleProp.ts +0 -51
- package/src/renderer/docs/propTypes/rawDefaultPropResolvers.ts +0 -36
- package/src/renderer/docs/propTypes/sortProps.ts +0 -18
- package/src/renderer/docs/typeScript/handleProp.ts +0 -31
package/README.md
CHANGED
|
@@ -9,19 +9,20 @@
|
|
|
9
9
|
[](./LICENSE)
|
|
10
10
|
[](https://github.com/solidjs-community/storybook/pulls)
|
|
11
11
|
|
|
12
|
-
[Storybook](https://storybook.js.org/)
|
|
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
|
-
- Solid 1 and Solid 2 support
|
|
19
|
-
- Vite-powered builder
|
|
20
|
-
- TypeScript-first setup
|
|
21
|
-
-
|
|
22
|
-
- [
|
|
23
|
-
-
|
|
24
|
-
-
|
|
16
|
+
- [Solid 1](#solid-1) and [Solid 2](#solid-2) support
|
|
17
|
+
- [Vite-powered builder](https://storybook.js.org/docs/builders/vite)
|
|
18
|
+
- [TypeScript-first setup](https://storybook.js.org/docs/configure/integration/typescript)
|
|
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
|
+
- [Storybook MCP](https://storybook.js.org/docs/ai/mcp/overview) support ([setup](#storybook-mcp))
|
|
23
|
+
- [CSF Next](https://storybook.js.org/docs/api/csf/csf-next) factory API ([setup](#csf-next), optional)
|
|
24
|
+
- [Integrated testing](https://storybook.js.org/docs/writing-tests) (Vitest, Playwright)
|
|
25
|
+
- [Compatible with Storybook addons](https://storybook.js.org/docs/addons)
|
|
25
26
|
|
|
26
27
|
## 🚀 Getting Started
|
|
27
28
|
|
|
@@ -29,26 +30,18 @@ Run in your project:
|
|
|
29
30
|
|
|
30
31
|
```bash
|
|
31
32
|
npx create-storybook --type=solid
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
Then start Storybook:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
bun run storybook
|
|
33
|
+
npm run storybook
|
|
38
34
|
```
|
|
39
35
|
|
|
40
36
|
Open the URL shown in the terminal.
|
|
41
37
|
|
|
42
38
|
## ⚙️ Configuration
|
|
43
39
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
- Add stories in `src/**/*.stories.tsx` or `src/**/*.stories.js`
|
|
47
|
-
- 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.
|
|
48
41
|
|
|
49
42
|
### Solid 1
|
|
50
43
|
|
|
51
|
-
|
|
44
|
+
Import from `storybook-solidjs-vite` in config, preview, and stories:
|
|
52
45
|
|
|
53
46
|
```ts
|
|
54
47
|
// .storybook/main.ts
|
|
@@ -68,19 +61,19 @@ import type { Preview, Meta, StoryObj } from 'storybook-solidjs-vite';
|
|
|
68
61
|
|
|
69
62
|
### Solid 2
|
|
70
63
|
|
|
71
|
-
|
|
64
|
+
Use `storybook-solidjs-vite/next` in preview and stories:
|
|
72
65
|
|
|
73
66
|
```ts
|
|
74
67
|
import type { Preview, Meta, StoryObj } from 'storybook-solidjs-vite/next';
|
|
75
68
|
```
|
|
76
69
|
|
|
77
|
-
Imports without `/next`
|
|
70
|
+
Imports without `/next` may still run, but TypeScript can complain.
|
|
78
71
|
|
|
79
|
-
In `main.ts
|
|
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.
|
|
80
73
|
|
|
81
74
|
```ts
|
|
82
|
-
framework: 'storybook-solidjs-vite'
|
|
83
|
-
framework: 'storybook-solidjs-vite/next'
|
|
75
|
+
framework: 'storybook-solidjs-vite' // Solid auto-detect
|
|
76
|
+
framework: 'storybook-solidjs-vite/next' // Solid 2 only
|
|
84
77
|
```
|
|
85
78
|
|
|
86
79
|
### CSF Next
|
|
@@ -100,7 +93,7 @@ export default defineMain({
|
|
|
100
93
|
// .storybook/preview.tsx
|
|
101
94
|
import { definePreview } from 'storybook-solidjs-vite';
|
|
102
95
|
// for Solid 2, use:
|
|
103
|
-
|
|
96
|
+
import { definePreview } from 'storybook-solidjs-vite/next';
|
|
104
97
|
```
|
|
105
98
|
|
|
106
99
|
```ts
|
|
@@ -117,15 +110,13 @@ export const Primary = meta.story({
|
|
|
117
110
|
});
|
|
118
111
|
```
|
|
119
112
|
|
|
120
|
-
###
|
|
113
|
+
### Docgen
|
|
121
114
|
|
|
122
|
-
|
|
115
|
+
Props for **Controls**, **Docs**, and the **components manifest** come from a TypeScript LanguageService extractor aligned with Storybook's `react-component-meta` format.
|
|
123
116
|
|
|
124
|
-
|
|
117
|
+
Enabled by default. Inspect output in the [manifest debugger](#components-manifest-debugger).
|
|
125
118
|
|
|
126
|
-
|
|
127
|
-
`true` (default) — enable docgen with the default configuration
|
|
128
|
-
`object` — override default configuration
|
|
119
|
+
To disable:
|
|
129
120
|
|
|
130
121
|
```ts
|
|
131
122
|
import type { StorybookConfig } from 'storybook-solidjs-vite';
|
|
@@ -133,73 +124,90 @@ import type { StorybookConfig } from 'storybook-solidjs-vite';
|
|
|
133
124
|
const config: StorybookConfig = {
|
|
134
125
|
framework: {
|
|
135
126
|
name: 'storybook-solidjs-vite',
|
|
136
|
-
options: {
|
|
137
|
-
docgen: {
|
|
138
|
-
savePropValueAsString: true,
|
|
139
|
-
shouldExtractLiteralValuesFromEnum: true,
|
|
140
|
-
propFilter: (prop: any) =>
|
|
141
|
-
prop.parent ? !/node_modules/.test(prop.parent.fileName) : true,
|
|
142
|
-
},
|
|
143
|
-
},
|
|
127
|
+
options: { docgen: false },
|
|
144
128
|
},
|
|
145
129
|
};
|
|
146
130
|
|
|
147
131
|
export default config;
|
|
148
132
|
```
|
|
149
133
|
|
|
150
|
-
|
|
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
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export default config;
|
|
150
|
+
```
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
### Storybook MCP
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
Solid projects can use [Storybook MCP](https://storybook.js.org/docs/ai/mcp/overview) so AI agents can list components, read prop docs from component meta, and preview stories. Requires docgen (enabled by default) and `@storybook/addon-docs`.
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
npx storybook add @storybook/addon-mcp
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
See [Storybook MCP docs](https://storybook.js.org/docs/ai/mcp/overview#2-add-the-mcp-server-to-your-agent) for agent setup.
|
|
161
|
+
|
|
162
|
+
### Components manifest debugger
|
|
163
|
+
|
|
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
|
|
173
|
+
|
|
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.
|
|
155
175
|
|
|
156
176
|
### createJSXDecorator
|
|
157
177
|
|
|
158
|
-
|
|
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:
|
|
159
179
|
|
|
160
180
|
```tsx
|
|
161
181
|
import { createJSXDecorator } from 'storybook-solidjs-vite';
|
|
162
182
|
|
|
163
|
-
export const
|
|
164
|
-
|
|
165
|
-
<
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
);
|
|
169
|
-
});
|
|
183
|
+
export const withLayout = createJSXDecorator((Story, context) => (
|
|
184
|
+
<main data-theme={context.globals.theme}>
|
|
185
|
+
<Story />
|
|
186
|
+
</main>
|
|
187
|
+
));
|
|
170
188
|
```
|
|
171
189
|
|
|
172
190
|
### createDecorator
|
|
173
191
|
|
|
174
|
-
|
|
192
|
+
For side effects that should run on every story update — e.g. sync `document.body` when globals change:
|
|
175
193
|
|
|
176
194
|
```tsx
|
|
177
195
|
import { createDecorator } from 'storybook-solidjs-vite';
|
|
178
196
|
|
|
179
|
-
export const
|
|
197
|
+
export const withTheme = createDecorator((Story, context) => {
|
|
198
|
+
// Will run on every story update
|
|
199
|
+
document.body.setAttribute('data-theme', context.globals.theme);
|
|
180
200
|
return Story();
|
|
181
201
|
});
|
|
182
202
|
```
|
|
183
203
|
|
|
184
|
-
### Manual flag
|
|
185
|
-
|
|
186
|
-
```tsx
|
|
187
|
-
import { IS_SOLID_JSX_FLAG } from 'storybook-solidjs-vite';
|
|
188
|
-
|
|
189
|
-
export const decorator = (Story) => {
|
|
190
|
-
return <div><Story /></div>;
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
decorator[IS_SOLID_JSX_FLAG] = true;
|
|
194
|
-
```
|
|
195
|
-
|
|
196
204
|
## 🔄 Migration from v9
|
|
197
205
|
|
|
198
|
-
|
|
206
|
+
See [Migration Guide](./MIGRATION.md) for breaking changes.
|
|
199
207
|
|
|
200
208
|
## 🤝 Contributing
|
|
201
209
|
|
|
202
|
-
|
|
210
|
+
Issues and PRs welcome — [open an issue](https://github.com/solidjs-community/storybook/issues) or submit a pull request.
|
|
203
211
|
|
|
204
212
|
## 📖 License
|
|
205
213
|
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { DOCGEN_ENGINE, MANIFEST_DOCGEN_ENGINE, SolidComponentMetaManager, getOrCreateSolidComponentMetaManager } from './chunk-6566KBHG.js';
|
|
2
|
+
import './chunk-PZ5AY32C.js';
|
|
3
|
+
//# sourceMappingURL=SolidComponentMetaManager-KXVARPHU.js.map
|
|
4
|
+
//# sourceMappingURL=SolidComponentMetaManager-KXVARPHU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"SolidComponentMetaManager-KXVARPHU.js"}
|