@poveste/plugin-react 0.19.1 → 0.21.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 +1 -1
- package/dist/collect/index.js +1 -0
- package/dist/docgen/extractor.d.ts +5 -0
- package/dist/docgen/extractor.js +12 -0
- package/dist/index.js +12 -0
- package/dist/types.d.ts +2 -2
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -42,4 +42,4 @@ export default defineStory({
|
|
|
42
42
|
|
|
43
43
|
## What it does
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
It renders stories and variants. The source panel shows the story file. A story that names its component in its `component` field gets a props, slots and events table on its Docs tab, read from the component's types; it needs `typescript` 6 or earlier and `@types/react` in the book. See [Component docs](https://poveste.dev/guide/react/getting-started#component-docs). The controls panel is not wired to React: a variant with `initState` gets the generic state editor, and one without says why there is nothing there.
|
package/dist/collect/index.js
CHANGED
|
@@ -11,6 +11,7 @@ export async function run({ file, storyData }) {
|
|
|
11
11
|
icon: options.icon,
|
|
12
12
|
iconColor: options.iconColor,
|
|
13
13
|
docsOnly: options.docsOnly ?? false,
|
|
14
|
+
...options.autoDocs !== undefined ? { autoDocs: options.autoDocs } : {},
|
|
14
15
|
variants: [],
|
|
15
16
|
};
|
|
16
17
|
story.variants = variantOptions(options).map((variant, index) => ({
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DocgenExtractor, DocgenExtractorContext } from '@poveste/shared';
|
|
2
|
+
import type { JsxDialect } from 'poveste/docgen';
|
|
3
|
+
export declare const REACT_DIALECT: JsxDialect;
|
|
4
|
+
/** Runs in the docgen worker, never in the book. */
|
|
5
|
+
export declare function createExtractor(context: DocgenExtractorContext): DocgenExtractor;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createJsxExtractor } from 'poveste/docgen';
|
|
2
|
+
export const REACT_DIALECT = {
|
|
3
|
+
jsxImportSource: 'react',
|
|
4
|
+
// React merges no defaults by call: they are destructuring defaults, which the walker reads anyway.
|
|
5
|
+
defaultCalls: [],
|
|
6
|
+
slotType: /\b(?:ReactNode|ReactElement|JSX\.Element)\b/,
|
|
7
|
+
childrenTypes: ['PropsWithChildren'],
|
|
8
|
+
};
|
|
9
|
+
/** Runs in the docgen worker, never in the book. */
|
|
10
|
+
export function createExtractor(context) {
|
|
11
|
+
return createJsxExtractor(context, REACT_DIALECT);
|
|
12
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
// No Node-only import here, on purpose: a story file imports `defineStory` from
|
|
2
2
|
// this entry, so it is bundled for the browser as well as loaded by the config.
|
|
3
3
|
export const REACT_SETUP_HOOK_NAMES = ['setupReact'];
|
|
4
|
+
// A variable, not a literal: Vite turns `new URL('<literal>', import.meta.url)` into
|
|
5
|
+
// an asset, and this entry is bundled for the browser too.
|
|
6
|
+
const DOCGEN_EXTRACTOR = './docgen/extractor.js';
|
|
4
7
|
export function HstReact() {
|
|
5
8
|
return {
|
|
6
9
|
name: '@poveste/plugin-react',
|
|
10
|
+
// A React story names its component in `component`, so the extractor reads the story (#1161).
|
|
11
|
+
docgen: {
|
|
12
|
+
scope: 'story',
|
|
13
|
+
match: file => /\.story\.[jt]sx$/.test(file),
|
|
14
|
+
module: new URL(DOCGEN_EXTRACTOR, import.meta.url).href,
|
|
15
|
+
// The JSX walker loads the book's TypeScript (#1401). React ships no types of its own.
|
|
16
|
+
typescript: 'book',
|
|
17
|
+
types: ['@types/react'],
|
|
18
|
+
},
|
|
7
19
|
defaultConfig() {
|
|
8
20
|
return {
|
|
9
21
|
// Added to core's defaults rather than replacing them (#1124), so a book
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Awaitable, Story, StoryProps, Variant, VariantProps } from '@poveste/shared';
|
|
1
|
+
import type { Awaitable, Story, StoryComponentOptions, StoryProps, Variant, VariantProps } from '@poveste/shared';
|
|
2
2
|
import type { ComponentType, ReactNode } from 'react';
|
|
3
3
|
export interface ReactRenderApi<S extends object> {
|
|
4
4
|
/** This render's snapshot. Never mutate it; call `setState`. */
|
|
@@ -31,7 +31,7 @@ export interface VariantOptions<S extends object = Record<string, any>> extends
|
|
|
31
31
|
initState?: () => Awaitable<S>;
|
|
32
32
|
setupApp?: ReactStorySetupHandler;
|
|
33
33
|
}
|
|
34
|
-
export interface StoryOptions<S extends object = Record<string, any>> extends Omit<StoryProps, 'setupApp'
|
|
34
|
+
export interface StoryOptions<S extends object = Record<string, any>> extends Omit<StoryProps, 'setupApp'>, StoryComponentOptions<ComponentType<any>> {
|
|
35
35
|
/** A story with no `variants` and a `render` of its own has one implicit variant. */
|
|
36
36
|
variants?: VariantOptions<S>[];
|
|
37
37
|
render?: (api: ReactRenderApi<S>) => ReactNode;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poveste/plugin-react",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"description": "Poveste plugin for React support,
|
|
4
|
+
"version": "0.21.0",
|
|
5
|
+
"description": "Poveste plugin for React support, with props tables read from your components' types and no controls yet",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Sorin Gitlan",
|
|
8
8
|
"url": "https://x.com/50rayn"
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"@vitejs/plugin-react": "^6.0.0",
|
|
61
|
-
"poveste": "^0.
|
|
61
|
+
"poveste": "^0.21.0",
|
|
62
62
|
"react": "^19.0.0",
|
|
63
63
|
"react-dom": "^19.0.0"
|
|
64
64
|
},
|
|
@@ -68,21 +68,21 @@
|
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@poveste/shared": "^0.
|
|
72
|
-
"@poveste/vendors": "^0.
|
|
71
|
+
"@poveste/shared": "^0.21.0",
|
|
72
|
+
"@poveste/vendors": "^0.21.0"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
|
-
"@types/node": "^26.6.
|
|
75
|
+
"@types/node": "^26.6.5",
|
|
76
76
|
"@types/react": "^19.3.0",
|
|
77
77
|
"@types/react-dom": "^19.3.0",
|
|
78
|
-
"@vitejs/plugin-react": "^6.1.
|
|
79
|
-
"jsdom": "^30.1.
|
|
80
|
-
"poveste": "0.
|
|
81
|
-
"react": "^19.3.
|
|
82
|
-
"react-dom": "^19.3.
|
|
78
|
+
"@vitejs/plugin-react": "^6.1.2",
|
|
79
|
+
"jsdom": "^30.1.3",
|
|
80
|
+
"poveste": "0.21.0",
|
|
81
|
+
"react": "^19.3.1",
|
|
82
|
+
"react-dom": "^19.3.1",
|
|
83
83
|
"typescript": "6.0.3",
|
|
84
|
-
"vite": "^8.3.
|
|
85
|
-
"vitest": "^5.0.
|
|
84
|
+
"vite": "^8.3.4",
|
|
85
|
+
"vitest": "^5.0.5"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
88
|
"build": "rimraf dist && tsc -d",
|