@repobuddy/storybook 2.19.0 → 2.20.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/esm/index.d.ts +3 -3
- package/esm/index.js +3 -2
- package/package.json +25 -11
- package/src/arg-types/fn-to-arg-types.ts +1 -1
- package/src/decorators/show_doc_source.tsx +7 -6
package/esm/index.d.ts
CHANGED
|
@@ -18,7 +18,7 @@ export * from "@repobuddy/test";
|
|
|
18
18
|
* type R = FnToArgTypes<F, ['x', 'y']> // { x: number; y: string }
|
|
19
19
|
*/
|
|
20
20
|
type FnToArgTypes<F extends AnyFunction, Names extends CreateTuple<Parameters<F>['length'], string> = CreateTuple<Parameters<F>['length'], string>> = Properties<ReduceToRecord<Parameters<F>, Names>>;
|
|
21
|
-
type ReduceToRecord<Params extends Array<any>, Names extends Array<any>> = Names['length'] extends 0 ? unknown : Names['length'] extends 1 ? Names extends [infer K extends string] ? { [I in K]: Params[0] } : never : Names extends [infer K extends string, ...infer Rest] ? { [I in K]: Params[0] } & ReduceToRecord<Tail<Params>, Rest> :
|
|
21
|
+
type ReduceToRecord<Params extends Array<any>, Names extends Array<any>> = Names['length'] extends 0 ? unknown : Names['length'] extends 1 ? Names extends [infer K extends string] ? { [I in K]: Params[0] } : never : Names extends [infer K extends string, ...infer Rest] ? { [I in K]: Params[0] } & ReduceToRecord<Tail<Params>, Rest> : Record<string, any>;
|
|
22
22
|
//#endregion
|
|
23
23
|
//#region src/components/show_html.d.ts
|
|
24
24
|
type ShowHtmlProps = ClassNameProps & StyleProps & {
|
|
@@ -110,12 +110,12 @@ declare function StoryCard({
|
|
|
110
110
|
* @param options - Options for the showDocSource decorator
|
|
111
111
|
* @param options.showOriginalSource - Whether to show the original source code in a card
|
|
112
112
|
* @param options.className - Class name to apply to the card
|
|
113
|
-
* @param options.source - Source code to show
|
|
113
|
+
* @param options.source - Source code to show. Can be a string, or a function `(originalSource) => string` that receives the story's original source and returns the code to display.
|
|
114
114
|
* @param options.placement - Where to show the source code relative to the story.
|
|
115
115
|
* @returns A decorator function that shows the source code of a story above or below the rendered story
|
|
116
116
|
*/
|
|
117
117
|
declare function showDocSource<TRenderer extends Renderer = Renderer, TArgs = Args>(options?: Pick<StoryCardProps, 'className'> & {
|
|
118
|
-
source?: string | undefined;
|
|
118
|
+
source?: ((source: string | undefined) => string) | string | undefined;
|
|
119
119
|
showOriginalSource?: boolean | undefined;
|
|
120
120
|
/**
|
|
121
121
|
* Where to show the source code relative to the story.
|
package/esm/index.js
CHANGED
|
@@ -168,7 +168,7 @@ const channel = addons.getChannel();
|
|
|
168
168
|
* @param options - Options for the showDocSource decorator
|
|
169
169
|
* @param options.showOriginalSource - Whether to show the original source code in a card
|
|
170
170
|
* @param options.className - Class name to apply to the card
|
|
171
|
-
* @param options.source - Source code to show
|
|
171
|
+
* @param options.source - Source code to show. Can be a string, or a function `(originalSource) => string` that receives the story's original source and returns the code to display.
|
|
172
172
|
* @param options.placement - Where to show the source code relative to the story.
|
|
173
173
|
* @returns A decorator function that shows the source code of a story above or below the rendered story
|
|
174
174
|
*/
|
|
@@ -181,7 +181,8 @@ function showDocSource(options) {
|
|
|
181
181
|
channel.on("DARK_MODE", setIsDark);
|
|
182
182
|
return () => channel.off("DARK_MODE", setIsDark);
|
|
183
183
|
}, []);
|
|
184
|
-
const
|
|
184
|
+
const originalSource = options?.showOriginalSource ? docs?.source?.originalSource : docs?.source?.code ?? docs?.source?.originalSource;
|
|
185
|
+
const code = typeof options?.source === "function" ? options?.source(originalSource) : options?.source ?? originalSource;
|
|
185
186
|
const language = code === docs?.source?.originalSource ? void 0 : docs?.source?.language;
|
|
186
187
|
const isOriginalSource = code === docs?.source?.originalSource;
|
|
187
188
|
const sourceContent = /* @__PURE__ */ jsx(SyntaxHighlighter, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@repobuddy/storybook",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.20.0",
|
|
4
4
|
"description": "Storybook repo buddy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -24,7 +24,10 @@
|
|
|
24
24
|
},
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
|
-
"types":
|
|
27
|
+
"types": [
|
|
28
|
+
"./esm/index.d.ts",
|
|
29
|
+
"./src/index.ts"
|
|
30
|
+
],
|
|
28
31
|
"default": "./esm/index.js"
|
|
29
32
|
},
|
|
30
33
|
"./manager": {
|
|
@@ -32,11 +35,17 @@
|
|
|
32
35
|
"default": "./esm/manager/index.js"
|
|
33
36
|
},
|
|
34
37
|
"./storybook-addon-tag-badges": {
|
|
35
|
-
"types":
|
|
38
|
+
"types": [
|
|
39
|
+
"./esm/storybook-addon-tag-badges/index.d.ts",
|
|
40
|
+
"./src/storybook-addon-tag-badges/index.ts"
|
|
41
|
+
],
|
|
36
42
|
"default": "./esm/storybook-addon-tag-badges/index.js"
|
|
37
43
|
},
|
|
38
44
|
"./storybook-dark-mode": {
|
|
39
|
-
"types":
|
|
45
|
+
"types": [
|
|
46
|
+
"./esm/storybook-dark-mode/index.d.ts",
|
|
47
|
+
"./src/storybook-dark-mode/index.ts"
|
|
48
|
+
],
|
|
40
49
|
"default": "./esm/storybook-dark-mode/index.js"
|
|
41
50
|
},
|
|
42
51
|
"./tailwind": {
|
|
@@ -65,11 +74,11 @@
|
|
|
65
74
|
"type-plus": "8.0.0-beta.8"
|
|
66
75
|
},
|
|
67
76
|
"devDependencies": {
|
|
68
|
-
"@repobuddy/vitest": "^2.
|
|
69
|
-
"@storybook-community/storybook-dark-mode": "^7.0
|
|
70
|
-
"@storybook/addon-docs": "^10.2.
|
|
71
|
-
"@storybook/addon-vitest": "^10.
|
|
72
|
-
"@storybook/react-vite": "^10.2.
|
|
77
|
+
"@repobuddy/vitest": "^2.1.1",
|
|
78
|
+
"@storybook-community/storybook-dark-mode": "^7.1.0",
|
|
79
|
+
"@storybook/addon-docs": "^10.2.8",
|
|
80
|
+
"@storybook/addon-vitest": "^10.2.8",
|
|
81
|
+
"@storybook/react-vite": "^10.2.8",
|
|
73
82
|
"@tailwindcss/cli": "^4.1.17",
|
|
74
83
|
"@tailwindcss/vite": "^4.1.17",
|
|
75
84
|
"@vitest/browser": "^4.0.16",
|
|
@@ -80,8 +89,9 @@
|
|
|
80
89
|
"react": "^19.2.0",
|
|
81
90
|
"react-dom": "^19.2.0",
|
|
82
91
|
"rimraf": "^6.1.0",
|
|
83
|
-
"storybook": "^10.
|
|
84
|
-
"storybook-addon-
|
|
92
|
+
"storybook": "^10.2.8",
|
|
93
|
+
"storybook-addon-code-editor": "^6.1.3",
|
|
94
|
+
"storybook-addon-tag-badges": "^3.0.6",
|
|
85
95
|
"tailwindcss": "^4.1.17",
|
|
86
96
|
"tsdown": "^0.20.0",
|
|
87
97
|
"vite": "^7.3.0",
|
|
@@ -90,12 +100,16 @@
|
|
|
90
100
|
"peerDependencies": {
|
|
91
101
|
"@storybook-community/storybook-dark-mode": "^7.0.0",
|
|
92
102
|
"@storybook/addon-docs": "^10.2.4",
|
|
103
|
+
"@types/react": ">= 16",
|
|
93
104
|
"storybook-addon-tag-badges": "^3.0.2"
|
|
94
105
|
},
|
|
95
106
|
"peerDependenciesMeta": {
|
|
96
107
|
"@storybook-community/storybook-dark-mode": {
|
|
97
108
|
"optional": true
|
|
98
109
|
},
|
|
110
|
+
"@types/react": {
|
|
111
|
+
"optional": true
|
|
112
|
+
},
|
|
99
113
|
"storybook-addon-tag-badges": {
|
|
100
114
|
"optional": true
|
|
101
115
|
}
|
|
@@ -16,13 +16,13 @@ const channel = addons.getChannel()
|
|
|
16
16
|
* @param options - Options for the showDocSource decorator
|
|
17
17
|
* @param options.showOriginalSource - Whether to show the original source code in a card
|
|
18
18
|
* @param options.className - Class name to apply to the card
|
|
19
|
-
* @param options.source - Source code to show
|
|
19
|
+
* @param options.source - Source code to show. Can be a string, or a function `(originalSource) => string` that receives the story's original source and returns the code to display.
|
|
20
20
|
* @param options.placement - Where to show the source code relative to the story.
|
|
21
21
|
* @returns A decorator function that shows the source code of a story above or below the rendered story
|
|
22
22
|
*/
|
|
23
23
|
export function showDocSource<TRenderer extends Renderer = Renderer, TArgs = Args>(
|
|
24
24
|
options?: Pick<StoryCardProps, 'className'> & {
|
|
25
|
-
source?: string | undefined
|
|
25
|
+
source?: ((source: string | undefined) => string) | string | undefined
|
|
26
26
|
showOriginalSource?: boolean | undefined
|
|
27
27
|
/**
|
|
28
28
|
* Where to show the source code relative to the story.
|
|
@@ -44,11 +44,12 @@ export function showDocSource<TRenderer extends Renderer = Renderer, TArgs = Arg
|
|
|
44
44
|
return () => channel.off('DARK_MODE', setIsDark)
|
|
45
45
|
}, [])
|
|
46
46
|
|
|
47
|
+
const originalSource = options?.showOriginalSource
|
|
48
|
+
? docs?.source?.originalSource
|
|
49
|
+
: (docs?.source?.code ?? docs?.source?.originalSource)
|
|
50
|
+
|
|
47
51
|
const code =
|
|
48
|
-
options?.source ??
|
|
49
|
-
(options?.showOriginalSource
|
|
50
|
-
? docs?.source?.originalSource
|
|
51
|
-
: (docs?.source?.code ?? docs?.source?.originalSource))
|
|
52
|
+
typeof options?.source === 'function' ? options?.source(originalSource) : (options?.source ?? originalSource)
|
|
52
53
|
|
|
53
54
|
const language = code === docs?.source?.originalSource ? undefined : docs?.source?.language
|
|
54
55
|
|