@repobuddy/storybook 1.0.1 → 2.0.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/cjs/components/show_html.d.ts +16 -0
- package/cjs/components/show_html.js +29 -0
- package/cjs/decorators/show_doc_source.d.ts +6 -0
- package/cjs/decorators/show_doc_source.js +38 -0
- package/cjs/index.d.ts +13 -0
- package/cjs/index.js +137 -0
- package/cjs/manager/brand_title.d.ts +35 -0
- package/cjs/manager/brand_title.js +12 -0
- package/cjs/manager/index.d.ts +1 -0
- package/cjs/manager/index.js +16 -0
- package/cjs/parameters/define_actions_param.d.ts +24 -0
- package/cjs/parameters/define_actions_param.js +11 -0
- package/cjs/parameters/define_backgrounds_param.d.ts +45 -0
- package/cjs/parameters/define_backgrounds_param.js +10 -0
- package/cjs/parameters/define_docs_param.d.ts +217 -0
- package/cjs/parameters/define_docs_param.js +11 -0
- package/cjs/parameters/define_layout_param.d.ts +20 -0
- package/cjs/parameters/define_layout_param.js +10 -0
- package/cjs/parameters/define_parameters.d.ts +39 -0
- package/cjs/parameters/define_parameters.js +9 -0
- package/cjs/parameters/define_test_param.d.ts +34 -0
- package/cjs/parameters/define_test_param.js +11 -0
- package/cjs/parameters/define_viewport_param.d.ts +78 -0
- package/cjs/parameters/define_viewport_param.js +11 -0
- package/cjs/parameters/story_sort.d.ts +27 -0
- package/cjs/parameters/story_sort.js +1 -0
- package/cjs/storybook-addon-tag-badges/index.d.ts +2 -0
- package/cjs/storybook-addon-tag-badges/index.js +16 -0
- package/cjs/storybook-addon-tag-badges/tag_badges.d.ts +41 -0
- package/cjs/storybook-addon-tag-badges/tag_badges.js +179 -0
- package/cjs/storybook-addon-tag-badges/types.d.ts +9 -0
- package/cjs/storybook-addon-tag-badges/types.js +1 -0
- package/cjs/storybook-dark-mode/dark_mode_docs_container.d.ts +26 -0
- package/cjs/storybook-dark-mode/dark_mode_docs_container.js +23 -0
- package/cjs/storybook-dark-mode/define_dark_mode.d.ts +54 -0
- package/cjs/storybook-dark-mode/define_dark_mode.js +11 -0
- package/cjs/storybook-dark-mode/index.d.ts +3 -0
- package/cjs/storybook-dark-mode/index.js +38 -0
- package/cjs/storybook-dark-mode/with_dark_mode.d.ts +22 -0
- package/cjs/storybook-dark-mode/with_dark_mode.js +54 -0
- package/cjs/testing/decorators/when_running_in_test.d.ts +5 -0
- package/cjs/testing/decorators/when_running_in_test.js +12 -0
- package/cjs/testing/decorators/when_running_in_text.ctx.d.ts +3 -0
- package/cjs/testing/decorators/when_running_in_text.ctx.js +10 -0
- package/cjs/types.d.ts +41 -0
- package/cjs/types.js +1 -0
- package/cjs/variants/index.d.ts +1 -0
- package/cjs/variants/index.js +8 -0
- package/cjs/variants/package.json +3 -0
- package/cjs/variants/preset.d.ts +11 -0
- package/cjs/variants/preset.js +3 -0
- package/esm/components/show_html.d.ts +1 -1
- package/esm/components/show_html.js +17 -26
- package/esm/decorators/show_doc_source.js +26 -12
- package/esm/index.d.ts +1 -0
- package/esm/index.js +12 -12
- package/esm/manager/brand_title.js +2 -24
- package/esm/manager/index.js +1 -1
- package/esm/parameters/define_actions_param.js +1 -9
- package/esm/parameters/define_backgrounds_param.js +1 -7
- package/esm/parameters/define_docs_param.d.ts +2 -2
- package/esm/parameters/define_docs_param.js +1 -28
- package/esm/parameters/define_layout_param.js +1 -15
- package/esm/parameters/define_parameters.d.ts +1 -1
- package/esm/parameters/define_parameters.js +1 -30
- package/esm/parameters/define_test_param.js +1 -17
- package/esm/parameters/define_viewport_param.js +1 -28
- package/esm/parameters/story_sort.js +0 -1
- package/esm/storybook-addon-tag-badges/index.js +1 -1
- package/esm/storybook-addon-tag-badges/tag_badges.d.ts +1 -1
- package/esm/storybook-addon-tag-badges/tag_badges.js +153 -172
- package/esm/storybook-addon-tag-badges/types.d.ts +7 -6
- package/esm/storybook-addon-tag-badges/types.js +0 -1
- package/esm/storybook-dark-mode/dark_mode_docs_container.d.ts +2 -2
- package/esm/storybook-dark-mode/dark_mode_docs_container.js +19 -30
- package/esm/storybook-dark-mode/define_dark_mode.d.ts +3 -3
- package/esm/storybook-dark-mode/define_dark_mode.js +1 -17
- package/esm/storybook-dark-mode/index.js +3 -3
- package/esm/storybook-dark-mode/with_dark_mode.js +36 -47
- package/esm/testing/decorators/when_running_in_test.js +4 -8
- package/esm/testing/decorators/when_running_in_text.ctx.d.ts +1 -2
- package/esm/testing/decorators/when_running_in_text.ctx.js +2 -2
- package/esm/types.d.ts +41 -0
- package/esm/types.js +0 -0
- package/esm/variants/index.d.ts +1 -0
- package/esm/variants/index.js +2 -0
- package/esm/variants/package.json +3 -0
- package/esm/variants/preset.d.ts +11 -0
- package/esm/variants/preset.js +1 -0
- package/package.json +51 -34
- package/readme.md +3 -3
- package/src/decorators/show_doc_source.tsx +30 -11
- package/src/index.ts +1 -0
- package/src/parameters/define_docs_param.ts +2 -2
- package/src/storybook-addon-tag-badges/tag_badges.ts +1 -1
- package/src/storybook-addon-tag-badges/types.ts +7 -6
- package/src/storybook-dark-mode/dark_mode_docs_container.tsx +2 -2
- package/src/storybook-dark-mode/define_dark_mode.ts +3 -3
- package/src/storybook-dark-mode/with_dark_mode.tsx +2 -1
- package/src/types.ts +51 -0
- package/src/variants/index.ts +3 -0
- package/src/variants/package.json +3 -0
- package/src/variants/preset.ts +22 -0
- package/src/overview.mdx +0 -7
- package/src/storybook-dark-mode/dark_mode_docs_container.mdx +0 -33
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ClassNameProps, StyleProps } from '@just-web/css';
|
|
2
|
+
import { type UserConfig } from 'htmlfy';
|
|
3
|
+
export type ShowHtmlProps = ClassNameProps & StyleProps & {
|
|
4
|
+
selector?: string | undefined;
|
|
5
|
+
config?: UserConfig | undefined;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A component that displays the HTML of a subject element.
|
|
9
|
+
* Uses `htmlfy` internally to format and prettify the HTML output.
|
|
10
|
+
*
|
|
11
|
+
* @param selector - CSS selector to find the subject element. Defaults to '[data-testid="subject"]'
|
|
12
|
+
* @param config - Configuration options passed to htmlfy's prettify function
|
|
13
|
+
* @param props - Additional props (className, style) passed to the pre element
|
|
14
|
+
* @returns A pre element containing the formatted HTML
|
|
15
|
+
*/
|
|
16
|
+
export declare function ShowHtml({ selector, config, ...props }: ShowHtmlProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ShowHtml = ShowHtml;
|
|
7
|
+
var _htmlfy = require("htmlfy");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
function ShowHtml({
|
|
10
|
+
selector = '[data-testid="subject"]',
|
|
11
|
+
config,
|
|
12
|
+
...props
|
|
13
|
+
}) {
|
|
14
|
+
const [html, setHtml] = (0, _react.useState)("");
|
|
15
|
+
(0, _react.useEffect)(() => {
|
|
16
|
+
const subject = document.querySelector(selector);
|
|
17
|
+
if (subject) {
|
|
18
|
+
setHtml((0, _htmlfy.prettify)(subject.outerHTML, {
|
|
19
|
+
tag_wrap: 40,
|
|
20
|
+
...config
|
|
21
|
+
}));
|
|
22
|
+
} else {
|
|
23
|
+
setHtml("No subject found");
|
|
24
|
+
}
|
|
25
|
+
}, [selector]);
|
|
26
|
+
return /* @__PURE__ */React.createElement("pre", {
|
|
27
|
+
...props
|
|
28
|
+
}, html);
|
|
29
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Args, DecoratorFunction, Renderer } from 'storybook/internal/csf';
|
|
2
|
+
/**
|
|
3
|
+
* A decorator that shows the source code of a story above the rendered story.
|
|
4
|
+
* The source code is taken from the story's `parameters.docs.source.code`.
|
|
5
|
+
*/
|
|
6
|
+
export declare function showDocSource<TRenderer extends Renderer = Renderer, TArgs = Args>(): DecoratorFunction<TRenderer, TArgs>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.showDocSource = showDocSource;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _components = require("storybook/internal/components");
|
|
9
|
+
var _previewApi = require("storybook/preview-api");
|
|
10
|
+
var _theming = require("storybook/theming");
|
|
11
|
+
const channel = _previewApi.addons.getChannel();
|
|
12
|
+
function showDocSource() {
|
|
13
|
+
return (Story, {
|
|
14
|
+
parameters: {
|
|
15
|
+
docs,
|
|
16
|
+
darkMode
|
|
17
|
+
}
|
|
18
|
+
}) => {
|
|
19
|
+
const storedItem = window.localStorage.getItem("sb-addon-themes-3");
|
|
20
|
+
const current = typeof storedItem === "string" ? JSON.parse(storedItem).current : darkMode?.current;
|
|
21
|
+
const [isDark, setIsDark] = (0, _react.useState)((darkMode?.stylePreview && current === "dark") ?? false);
|
|
22
|
+
(0, _react.useEffect)(() => {
|
|
23
|
+
channel.on("DARK_MODE", setIsDark);
|
|
24
|
+
return () => channel.off("DARK_MODE", setIsDark);
|
|
25
|
+
}, []);
|
|
26
|
+
return /* @__PURE__ */React.createElement(_theming.ThemeProvider, {
|
|
27
|
+
theme: (0, _theming.convert)(docs?.theme ?? (isDark ? _theming.themes.dark : _theming.themes.light))
|
|
28
|
+
}, /* @__PURE__ */React.createElement("section", {
|
|
29
|
+
style: {
|
|
30
|
+
display: "flex",
|
|
31
|
+
flexDirection: "column",
|
|
32
|
+
gap: "1rem"
|
|
33
|
+
}
|
|
34
|
+
}, /* @__PURE__ */React.createElement(_components.SyntaxHighlighter, {
|
|
35
|
+
language: docs?.source?.language
|
|
36
|
+
}, docs?.source?.code), /* @__PURE__ */React.createElement(Story, null)));
|
|
37
|
+
};
|
|
38
|
+
}
|
package/cjs/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from '@repobuddy/test';
|
|
2
|
+
export * from './components/show_html.tsx';
|
|
3
|
+
export * from './decorators/show_doc_source.tsx';
|
|
4
|
+
export * from './parameters/define_actions_param.ts';
|
|
5
|
+
export * from './parameters/define_backgrounds_param.ts';
|
|
6
|
+
export * from './parameters/define_docs_param.ts';
|
|
7
|
+
export * from './parameters/define_layout_param.ts';
|
|
8
|
+
export * from './parameters/define_parameters.ts';
|
|
9
|
+
export * from './parameters/define_test_param.ts';
|
|
10
|
+
export * from './parameters/define_viewport_param.ts';
|
|
11
|
+
export * from './parameters/story_sort.ts';
|
|
12
|
+
export * from './testing/decorators/when_running_in_test.tsx';
|
|
13
|
+
export type * from './types.ts';
|
package/cjs/index.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _test = require("@repobuddy/test");
|
|
7
|
+
Object.keys(_test).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _test[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _test[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _show_html = require("./components/show_html.tsx");
|
|
18
|
+
Object.keys(_show_html).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _show_html[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _show_html[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _show_doc_source = require("./decorators/show_doc_source.tsx");
|
|
29
|
+
Object.keys(_show_doc_source).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _show_doc_source[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _show_doc_source[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _define_actions_param = require("./parameters/define_actions_param.ts");
|
|
40
|
+
Object.keys(_define_actions_param).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _define_actions_param[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _define_actions_param[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
var _define_backgrounds_param = require("./parameters/define_backgrounds_param.ts");
|
|
51
|
+
Object.keys(_define_backgrounds_param).forEach(function (key) {
|
|
52
|
+
if (key === "default" || key === "__esModule") return;
|
|
53
|
+
if (key in exports && exports[key] === _define_backgrounds_param[key]) return;
|
|
54
|
+
Object.defineProperty(exports, key, {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
get: function () {
|
|
57
|
+
return _define_backgrounds_param[key];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
var _define_docs_param = require("./parameters/define_docs_param.ts");
|
|
62
|
+
Object.keys(_define_docs_param).forEach(function (key) {
|
|
63
|
+
if (key === "default" || key === "__esModule") return;
|
|
64
|
+
if (key in exports && exports[key] === _define_docs_param[key]) return;
|
|
65
|
+
Object.defineProperty(exports, key, {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
get: function () {
|
|
68
|
+
return _define_docs_param[key];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
var _define_layout_param = require("./parameters/define_layout_param.ts");
|
|
73
|
+
Object.keys(_define_layout_param).forEach(function (key) {
|
|
74
|
+
if (key === "default" || key === "__esModule") return;
|
|
75
|
+
if (key in exports && exports[key] === _define_layout_param[key]) return;
|
|
76
|
+
Object.defineProperty(exports, key, {
|
|
77
|
+
enumerable: true,
|
|
78
|
+
get: function () {
|
|
79
|
+
return _define_layout_param[key];
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
var _define_parameters = require("./parameters/define_parameters.ts");
|
|
84
|
+
Object.keys(_define_parameters).forEach(function (key) {
|
|
85
|
+
if (key === "default" || key === "__esModule") return;
|
|
86
|
+
if (key in exports && exports[key] === _define_parameters[key]) return;
|
|
87
|
+
Object.defineProperty(exports, key, {
|
|
88
|
+
enumerable: true,
|
|
89
|
+
get: function () {
|
|
90
|
+
return _define_parameters[key];
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
var _define_test_param = require("./parameters/define_test_param.ts");
|
|
95
|
+
Object.keys(_define_test_param).forEach(function (key) {
|
|
96
|
+
if (key === "default" || key === "__esModule") return;
|
|
97
|
+
if (key in exports && exports[key] === _define_test_param[key]) return;
|
|
98
|
+
Object.defineProperty(exports, key, {
|
|
99
|
+
enumerable: true,
|
|
100
|
+
get: function () {
|
|
101
|
+
return _define_test_param[key];
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
var _define_viewport_param = require("./parameters/define_viewport_param.ts");
|
|
106
|
+
Object.keys(_define_viewport_param).forEach(function (key) {
|
|
107
|
+
if (key === "default" || key === "__esModule") return;
|
|
108
|
+
if (key in exports && exports[key] === _define_viewport_param[key]) return;
|
|
109
|
+
Object.defineProperty(exports, key, {
|
|
110
|
+
enumerable: true,
|
|
111
|
+
get: function () {
|
|
112
|
+
return _define_viewport_param[key];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
var _story_sort = require("./parameters/story_sort.ts");
|
|
117
|
+
Object.keys(_story_sort).forEach(function (key) {
|
|
118
|
+
if (key === "default" || key === "__esModule") return;
|
|
119
|
+
if (key in exports && exports[key] === _story_sort[key]) return;
|
|
120
|
+
Object.defineProperty(exports, key, {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () {
|
|
123
|
+
return _story_sort[key];
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
var _when_running_in_test = require("./testing/decorators/when_running_in_test.tsx");
|
|
128
|
+
Object.keys(_when_running_in_test).forEach(function (key) {
|
|
129
|
+
if (key === "default" || key === "__esModule") return;
|
|
130
|
+
if (key in exports && exports[key] === _when_running_in_test[key]) return;
|
|
131
|
+
Object.defineProperty(exports, key, {
|
|
132
|
+
enumerable: true,
|
|
133
|
+
get: function () {
|
|
134
|
+
return _when_running_in_test[key];
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface BrandTitleOptions {
|
|
2
|
+
/**
|
|
3
|
+
* The title to display in the brand title.
|
|
4
|
+
* It can be a simple string or raw HTML.
|
|
5
|
+
*/
|
|
6
|
+
title: string;
|
|
7
|
+
/**
|
|
8
|
+
* The logo to display in the brand title.
|
|
9
|
+
* It can be a simple string or raw HTML (e.g. `<svg>`).
|
|
10
|
+
*/
|
|
11
|
+
logo?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Creates a brand title element for the Storybook manager UI.
|
|
15
|
+
*
|
|
16
|
+
* @param options - The options for customizing the brand title
|
|
17
|
+
* @param options.title - The title text or HTML to display
|
|
18
|
+
* @param options.logo - Optional logo HTML to display before the title
|
|
19
|
+
* @returns An HTML string containing the brand title element
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
*
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { brandTitle } from '@repobuddy/storybook'
|
|
25
|
+
* import { addons } from 'storybook/manager-api'
|
|
26
|
+
*
|
|
27
|
+
* addons.setConfig({
|
|
28
|
+
* brandTitle: brandTitle({
|
|
29
|
+
* title: 'My Storybook',
|
|
30
|
+
* logo: '<img src="logo.png" alt="Logo" width="24" height="24">'
|
|
31
|
+
* })
|
|
32
|
+
* })
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function brandTitle(options: BrandTitleOptions): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.brandTitle = brandTitle;
|
|
7
|
+
function brandTitle(options) {
|
|
8
|
+
return `<span style="display: flex; align-items: center; gap: 2px;">
|
|
9
|
+
${options.logo ?? ""}
|
|
10
|
+
${options.title}
|
|
11
|
+
</span>`;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './brand_title.ts';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _brand_title = require("./brand_title.ts");
|
|
7
|
+
Object.keys(_brand_title).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _brand_title[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _brand_title[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface ActionsParam {
|
|
2
|
+
actions: {
|
|
3
|
+
argTypesRegex?: string | undefined;
|
|
4
|
+
disable?: boolean | undefined;
|
|
5
|
+
handles?: string[] | undefined;
|
|
6
|
+
[k: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Defines actions parameters for Storybook stories.
|
|
11
|
+
*
|
|
12
|
+
* @see https://storybook.js.org/docs/essentials/actions#parameters
|
|
13
|
+
*
|
|
14
|
+
* @param actions - Configuration for actions parameters
|
|
15
|
+
* @returns An object containing the actions parameter configuration
|
|
16
|
+
*/
|
|
17
|
+
export declare function defineActionsParam(actions: ActionsParam['actions']): {
|
|
18
|
+
actions: {
|
|
19
|
+
[k: string]: unknown;
|
|
20
|
+
argTypesRegex?: string | undefined;
|
|
21
|
+
disable?: boolean | undefined;
|
|
22
|
+
handles?: string[] | undefined;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export interface BackgroundsParam {
|
|
2
|
+
backgrounds: {
|
|
3
|
+
default?: string | undefined;
|
|
4
|
+
values?: Array<{
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}>;
|
|
8
|
+
disable?: boolean | undefined;
|
|
9
|
+
grid?: {
|
|
10
|
+
cellAmount?: number | undefined;
|
|
11
|
+
cellSize?: number | undefined;
|
|
12
|
+
disable?: boolean | undefined;
|
|
13
|
+
offsetX?: number | undefined;
|
|
14
|
+
offsetY?: number | undefined;
|
|
15
|
+
opacity?: number | undefined;
|
|
16
|
+
} | undefined;
|
|
17
|
+
[k: string]: unknown;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export interface GlobalApiBackgroundsParam {
|
|
21
|
+
backgrounds: {
|
|
22
|
+
default?: string | undefined;
|
|
23
|
+
options?: Array<{
|
|
24
|
+
name: string;
|
|
25
|
+
value: string;
|
|
26
|
+
}>;
|
|
27
|
+
disabled?: boolean | undefined;
|
|
28
|
+
grid?: {
|
|
29
|
+
cellAmount?: number | undefined;
|
|
30
|
+
cellSize?: number | undefined;
|
|
31
|
+
disable?: boolean | undefined;
|
|
32
|
+
offsetX?: number | undefined;
|
|
33
|
+
offsetY?: number | undefined;
|
|
34
|
+
opacity?: number | undefined;
|
|
35
|
+
} | undefined;
|
|
36
|
+
[k: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Defines backgrounds parameters for Storybook stories.
|
|
41
|
+
*
|
|
42
|
+
* @param backgrounds - The backgrounds configuration
|
|
43
|
+
* @returns An object containing the backgrounds parameter configuration
|
|
44
|
+
*/
|
|
45
|
+
export declare const defineBackgroundsParam: (backgrounds: BackgroundsParam["backgrounds"] | GlobalApiBackgroundsParam["backgrounds"]) => BackgroundsParam;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import type { StoryContext } from '@storybook/react-vite';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace JSX {
|
|
4
|
+
interface Element {
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export interface SourceProps {
|
|
9
|
+
/**
|
|
10
|
+
* Provides the source code to be rendered.
|
|
11
|
+
*
|
|
12
|
+
* This is useful when the story contains extra code that would be confusing in the docs.
|
|
13
|
+
*
|
|
14
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-source#code
|
|
15
|
+
*/
|
|
16
|
+
code?: string | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* Specifies whether the source code should be rendered in dark mode.
|
|
19
|
+
*
|
|
20
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-source#dark
|
|
21
|
+
*/
|
|
22
|
+
dark?: boolean | undefined;
|
|
23
|
+
/**
|
|
24
|
+
* Specifies whether decorators should be excluded from the source code.
|
|
25
|
+
*
|
|
26
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-source#excludedecorators
|
|
27
|
+
*
|
|
28
|
+
* Note: Has no effect in React.
|
|
29
|
+
* @see https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#parameter-docssourceexcludedecorators-has-no-effect-in-react
|
|
30
|
+
*/
|
|
31
|
+
excludeDecorators?: boolean | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Specifies the language of the source code.
|
|
34
|
+
*
|
|
35
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-source#language
|
|
36
|
+
*/
|
|
37
|
+
language?: string | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* A function to dynamically transform the source before being rendered,
|
|
40
|
+
* based on the original source and any story context necessary.
|
|
41
|
+
* The returned string is displayed as-is.
|
|
42
|
+
*
|
|
43
|
+
* If both code and transform are specified, transform will be ignored.
|
|
44
|
+
*
|
|
45
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-source#transform
|
|
46
|
+
*/
|
|
47
|
+
transform?: ((code: string, storyContext: StoryContext) => string) | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* Specifies how the source code is rendered.
|
|
50
|
+
*
|
|
51
|
+
* - auto: Same as dynamic, if the story's render function accepts args inputs and dynamic is supported by the framework in use; otherwise same as code
|
|
52
|
+
* - code: Renders the value of code prop, otherwise renders static story source
|
|
53
|
+
* - dynamic: Renders the story source with dynamically updated arg values
|
|
54
|
+
*
|
|
55
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-source#type
|
|
56
|
+
*/
|
|
57
|
+
type?: 'auto' | 'code' | 'dynamic' | undefined;
|
|
58
|
+
}
|
|
59
|
+
export interface DocsParam {
|
|
60
|
+
docs: {
|
|
61
|
+
argTypes?: {
|
|
62
|
+
/**
|
|
63
|
+
* Specifies which controls to exclude from the args table.
|
|
64
|
+
* Any controls whose names match the regex or are part of the array will be left out.
|
|
65
|
+
*
|
|
66
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-argtypes#exclude
|
|
67
|
+
*/
|
|
68
|
+
exclude?: string[] | RegExp | undefined;
|
|
69
|
+
/**
|
|
70
|
+
* Specifies which controls to include in the args table.
|
|
71
|
+
* Any controls whose names don't match the regex or are not part of the array will be left out.
|
|
72
|
+
*
|
|
73
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-argtypes#include
|
|
74
|
+
*/
|
|
75
|
+
include?: string[] | RegExp | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Specifies how the arg types are sorted.
|
|
78
|
+
*
|
|
79
|
+
* - none: Unsorted, displayed in the same order the arg types are processed in
|
|
80
|
+
* - alpha: Sorted alphabetically, by the arg type's name
|
|
81
|
+
* - requiredFirst: Same as alpha, with any required arg types displayed first
|
|
82
|
+
*
|
|
83
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-argtypes#sort
|
|
84
|
+
*/
|
|
85
|
+
sort?: 'alpha' | 'requiredFirst' | 'none' | undefined;
|
|
86
|
+
} | undefined;
|
|
87
|
+
description?: {
|
|
88
|
+
/**
|
|
89
|
+
* `docs.description.story` can be used to describe the story in doc.
|
|
90
|
+
*/
|
|
91
|
+
story?: string | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* `docs.description.component` can be used to describe the component in meta.
|
|
94
|
+
* It has no effect on the stories.
|
|
95
|
+
*/
|
|
96
|
+
component?: string | undefined;
|
|
97
|
+
} | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Determines whether to show the code panel.
|
|
100
|
+
*
|
|
101
|
+
* @see https://storybook.js.org/docs/writing-docs/code-panel
|
|
102
|
+
*/
|
|
103
|
+
codePanel?: boolean | undefined;
|
|
104
|
+
source?: SourceProps | undefined;
|
|
105
|
+
canvas?: {
|
|
106
|
+
/**
|
|
107
|
+
* Provides any additional custom actions to show in the bottom right corner.
|
|
108
|
+
* These are simple buttons that do anything you specify in the onClick function.
|
|
109
|
+
*
|
|
110
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-canvas#additionalactions
|
|
111
|
+
*/
|
|
112
|
+
additionalActions?: Array<{
|
|
113
|
+
title: string | JSX.Element;
|
|
114
|
+
className?: string;
|
|
115
|
+
onClick: () => void;
|
|
116
|
+
disabled?: boolean;
|
|
117
|
+
}> | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Provides HTML class(es) to the preview element, for custom styling.
|
|
120
|
+
*
|
|
121
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-canvas#classname
|
|
122
|
+
*/
|
|
123
|
+
className?: string | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Specifies how the canvas should layout the story.
|
|
126
|
+
*
|
|
127
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-canvas#layout
|
|
128
|
+
*/
|
|
129
|
+
layout?: 'centered' | 'padded' | 'fullscreen' | undefined;
|
|
130
|
+
/**
|
|
131
|
+
* Specifies the initial state of the source panel.
|
|
132
|
+
*
|
|
133
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-canvas#sourcestate
|
|
134
|
+
*/
|
|
135
|
+
sourceState?: 'hidden' | 'shown' | 'none' | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* Determines whether to render a toolbar containing tools to interact with the story.
|
|
138
|
+
*
|
|
139
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-canvas#withtoolbar
|
|
140
|
+
*/
|
|
141
|
+
withToolbar?: boolean | undefined;
|
|
142
|
+
} | undefined;
|
|
143
|
+
controls?: {
|
|
144
|
+
/**
|
|
145
|
+
* Specifies which controls to exclude from the args table.
|
|
146
|
+
* Any controls whose names match the regex or are part of the array will be left out.
|
|
147
|
+
*
|
|
148
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-controls#exclude
|
|
149
|
+
*/
|
|
150
|
+
exclude?: string[] | RegExp | undefined;
|
|
151
|
+
/**
|
|
152
|
+
* Specifies which controls to include in the args table.
|
|
153
|
+
* Any controls whose names don't match the regex or are not part of the array will be left out.
|
|
154
|
+
*
|
|
155
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-controls#include
|
|
156
|
+
*/
|
|
157
|
+
include?: string[] | RegExp | undefined;
|
|
158
|
+
/**
|
|
159
|
+
*
|
|
160
|
+
* Specifies how the controls are sorted.
|
|
161
|
+
*
|
|
162
|
+
* - none: Unsorted, displayed in the same order the controls are processed in
|
|
163
|
+
* - alpha: Sorted alphabetically, by the arg type's name
|
|
164
|
+
* - requiredFirst: Same as alpha, with any required controls displayed first
|
|
165
|
+
*
|
|
166
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-controls#sort
|
|
167
|
+
*/
|
|
168
|
+
sort?: 'alpha' | 'requiredFirst' | 'none' | undefined;
|
|
169
|
+
} | undefined;
|
|
170
|
+
story?: {
|
|
171
|
+
/**
|
|
172
|
+
* Specifies whether the story should be autoplayed.
|
|
173
|
+
*
|
|
174
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-story#autoplay
|
|
175
|
+
*/
|
|
176
|
+
autoplay?: boolean | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* Set a minimum height (note for an iframe this is the actual height) when rendering a story in an iframe or inline.
|
|
179
|
+
* This overrides parameters.docs.story.iframeHeight for iframes.
|
|
180
|
+
*/
|
|
181
|
+
height?: string | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Determines whether the story is rendered inline (in the same browser frame as the other docs content) or in an iframe.
|
|
184
|
+
*/
|
|
185
|
+
inline?: boolean | undefined;
|
|
186
|
+
} | undefined;
|
|
187
|
+
[k: string]: unknown;
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Defines docs parameters for Storybook stories.
|
|
192
|
+
*
|
|
193
|
+
* @param docs - Configuration for docs parameters including options for:
|
|
194
|
+
* - Controls display and sorting
|
|
195
|
+
* - Story rendering (autoplay, height, inline vs iframe)
|
|
196
|
+
* - And other docs-related settings
|
|
197
|
+
* @returns An object containing the docs parameter configuration
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```ts
|
|
201
|
+
* import { defineDocsParam } from '@repobuddy/storybook'
|
|
202
|
+
*
|
|
203
|
+
* export default {
|
|
204
|
+
* parameters: defineDocsParam({
|
|
205
|
+
* controls: {
|
|
206
|
+
* sort: 'alpha',
|
|
207
|
+
* exclude: ['internal*']
|
|
208
|
+
* },
|
|
209
|
+
* story: {
|
|
210
|
+
* inline: true,
|
|
211
|
+
* height: '400px'
|
|
212
|
+
* }
|
|
213
|
+
* })
|
|
214
|
+
* }
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
217
|
+
export declare function defineDocsParam(docs: DocsParam['docs']): DocsParam['docs'];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface LayoutParam {
|
|
2
|
+
layout: 'padded' | 'fullscreen' | 'centered';
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Helper function to define the layout parameter for a story
|
|
6
|
+
*
|
|
7
|
+
* @see https://storybook.js.org/docs/api/parameters#layout
|
|
8
|
+
*
|
|
9
|
+
* @param layout - The layout type to use ('padded', 'fullscreen', or 'centered')
|
|
10
|
+
* @returns An object containing the layout parameter
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* export const MyStory = {
|
|
14
|
+
* parameters: defineLayoutParam('centered')
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare const defineLayoutParam: (layout: LayoutParam["layout"]) => {
|
|
19
|
+
layout: "centered" | "padded" | "fullscreen";
|
|
20
|
+
};
|