@repobuddy/storybook 2.0.1 → 2.1.1
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 +574 -13
- package/esm/index.js +251 -12
- package/esm/manager/index.d.ts +38 -1
- package/esm/manager/index.js +32 -1
- package/esm/storybook-addon-tag-badges/index.d.ts +95 -2
- package/esm/storybook-addon-tag-badges/index.js +207 -1
- package/esm/storybook-dark-mode/index.d.ts +110 -3
- package/esm/storybook-dark-mode/index.js +102 -3
- package/package.json +4 -12
- package/cjs/components/show_html.d.ts +0 -16
- package/cjs/components/show_html.js +0 -29
- package/cjs/decorators/show_doc_source.d.ts +0 -6
- package/cjs/decorators/show_doc_source.js +0 -38
- package/cjs/index.d.ts +0 -13
- package/cjs/index.js +0 -137
- package/cjs/manager/brand_title.d.ts +0 -35
- package/cjs/manager/brand_title.js +0 -12
- package/cjs/manager/index.d.ts +0 -1
- package/cjs/manager/index.js +0 -16
- package/cjs/parameters/define_actions_param.d.ts +0 -24
- package/cjs/parameters/define_actions_param.js +0 -11
- package/cjs/parameters/define_backgrounds_param.d.ts +0 -45
- package/cjs/parameters/define_backgrounds_param.js +0 -10
- package/cjs/parameters/define_docs_param.d.ts +0 -217
- package/cjs/parameters/define_docs_param.js +0 -11
- package/cjs/parameters/define_layout_param.d.ts +0 -20
- package/cjs/parameters/define_layout_param.js +0 -10
- package/cjs/parameters/define_parameters.d.ts +0 -39
- package/cjs/parameters/define_parameters.js +0 -9
- package/cjs/parameters/define_test_param.d.ts +0 -34
- package/cjs/parameters/define_test_param.js +0 -11
- package/cjs/parameters/define_viewport_param.d.ts +0 -78
- package/cjs/parameters/define_viewport_param.js +0 -11
- package/cjs/parameters/story_sort.d.ts +0 -27
- package/cjs/parameters/story_sort.js +0 -1
- package/cjs/storybook-addon-tag-badges/index.d.ts +0 -2
- package/cjs/storybook-addon-tag-badges/index.js +0 -16
- package/cjs/storybook-addon-tag-badges/tag_badges.d.ts +0 -41
- package/cjs/storybook-addon-tag-badges/tag_badges.js +0 -179
- package/cjs/storybook-addon-tag-badges/types.d.ts +0 -9
- package/cjs/storybook-addon-tag-badges/types.js +0 -1
- package/cjs/storybook-dark-mode/dark_mode_docs_container.d.ts +0 -26
- package/cjs/storybook-dark-mode/dark_mode_docs_container.js +0 -23
- package/cjs/storybook-dark-mode/define_dark_mode.d.ts +0 -54
- package/cjs/storybook-dark-mode/define_dark_mode.js +0 -11
- package/cjs/storybook-dark-mode/index.d.ts +0 -3
- package/cjs/storybook-dark-mode/index.js +0 -38
- package/cjs/storybook-dark-mode/with_dark_mode.d.ts +0 -22
- package/cjs/storybook-dark-mode/with_dark_mode.js +0 -54
- package/cjs/testing/decorators/when_running_in_test.d.ts +0 -5
- package/cjs/testing/decorators/when_running_in_test.js +0 -12
- package/cjs/testing/decorators/when_running_in_text.ctx.d.ts +0 -3
- package/cjs/testing/decorators/when_running_in_text.ctx.js +0 -10
- package/cjs/types.d.ts +0 -41
- package/cjs/types.js +0 -1
- package/cjs/variants/index.d.ts +0 -1
- package/cjs/variants/index.js +0 -8
- package/cjs/variants/package.json +0 -3
- package/cjs/variants/preset.d.ts +0 -11
- package/cjs/variants/preset.js +0 -3
- package/esm/components/show_html.d.ts +0 -16
- package/esm/components/show_html.js +0 -19
- package/esm/decorators/show_doc_source.d.ts +0 -6
- package/esm/decorators/show_doc_source.js +0 -28
- package/esm/manager/brand_title.d.ts +0 -35
- package/esm/manager/brand_title.js +0 -6
- package/esm/parameters/define_actions_param.d.ts +0 -24
- package/esm/parameters/define_actions_param.js +0 -3
- package/esm/parameters/define_backgrounds_param.d.ts +0 -45
- package/esm/parameters/define_backgrounds_param.js +0 -3
- package/esm/parameters/define_docs_param.d.ts +0 -217
- package/esm/parameters/define_docs_param.js +0 -3
- package/esm/parameters/define_layout_param.d.ts +0 -20
- package/esm/parameters/define_layout_param.js +0 -3
- package/esm/parameters/define_parameters.d.ts +0 -39
- package/esm/parameters/define_parameters.js +0 -3
- package/esm/parameters/define_test_param.d.ts +0 -34
- package/esm/parameters/define_test_param.js +0 -3
- package/esm/parameters/define_viewport_param.d.ts +0 -78
- package/esm/parameters/define_viewport_param.js +0 -3
- package/esm/parameters/story_sort.d.ts +0 -27
- package/esm/parameters/story_sort.js +0 -0
- package/esm/storybook-addon-tag-badges/tag_badges.d.ts +0 -41
- package/esm/storybook-addon-tag-badges/tag_badges.js +0 -189
- package/esm/storybook-addon-tag-badges/types.d.ts +0 -9
- package/esm/storybook-addon-tag-badges/types.js +0 -0
- package/esm/storybook-dark-mode/dark_mode_docs_container.d.ts +0 -26
- package/esm/storybook-dark-mode/dark_mode_docs_container.js +0 -21
- package/esm/storybook-dark-mode/define_dark_mode.d.ts +0 -54
- package/esm/storybook-dark-mode/define_dark_mode.js +0 -3
- package/esm/storybook-dark-mode/with_dark_mode.d.ts +0 -22
- package/esm/storybook-dark-mode/with_dark_mode.js +0 -46
- package/esm/testing/decorators/when_running_in_test.d.ts +0 -5
- package/esm/testing/decorators/when_running_in_test.js +0 -6
- package/esm/testing/decorators/when_running_in_text.ctx.d.ts +0 -3
- package/esm/testing/decorators/when_running_in_text.ctx.js +0 -4
- package/esm/types.d.ts +0 -41
- package/esm/types.js +0 -0
- package/esm/variants/index.d.ts +0 -1
- package/esm/variants/index.js +0 -2
- package/esm/variants/package.json +0 -3
- package/esm/variants/preset.d.ts +0 -11
- package/esm/variants/preset.js +0 -1
package/esm/index.d.ts
CHANGED
|
@@ -1,13 +1,574 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export * from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { UserConfig } from "htmlfy";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
import { ClassNameProps, StyleProps } from "@just-web/css";
|
|
4
|
+
import { Args, DecoratorFunction, Renderer } from "storybook/internal/csf";
|
|
5
|
+
import { Decorator, Meta, StoryContext, StoryObj, StrictArgs } from "@storybook/react-vite";
|
|
6
|
+
export * from "@repobuddy/test";
|
|
7
|
+
|
|
8
|
+
//#region src/components/show_html.d.ts
|
|
9
|
+
type ShowHtmlProps = ClassNameProps & StyleProps & {
|
|
10
|
+
selector?: string | undefined;
|
|
11
|
+
config?: UserConfig | undefined;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* A component that displays the HTML of a subject element.
|
|
15
|
+
* Uses `htmlfy` internally to format and prettify the HTML output.
|
|
16
|
+
*
|
|
17
|
+
* @param selector - CSS selector to find the subject element. Defaults to '[data-testid="subject"]'
|
|
18
|
+
* @param config - Configuration options passed to htmlfy's prettify function
|
|
19
|
+
* @param props - Additional props (className, style) passed to the pre element
|
|
20
|
+
* @returns A pre element containing the formatted HTML
|
|
21
|
+
*/
|
|
22
|
+
declare function ShowHtml({
|
|
23
|
+
selector,
|
|
24
|
+
config,
|
|
25
|
+
...props
|
|
26
|
+
}: ShowHtmlProps): react_jsx_runtime0.JSX.Element;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/decorators/show_doc_source.d.ts
|
|
29
|
+
/**
|
|
30
|
+
* A decorator that shows the source code of a story above the rendered story.
|
|
31
|
+
* The source code is taken from the story's `parameters.docs.source.code`.
|
|
32
|
+
*/
|
|
33
|
+
declare function showDocSource<TRenderer extends Renderer = Renderer, TArgs = Args>(): DecoratorFunction<TRenderer, TArgs>;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/parameters/define_actions_param.d.ts
|
|
36
|
+
interface ActionsParam {
|
|
37
|
+
actions: {
|
|
38
|
+
argTypesRegex?: string | undefined;
|
|
39
|
+
disable?: boolean | undefined;
|
|
40
|
+
handles?: string[] | undefined;
|
|
41
|
+
[k: string]: unknown;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Defines actions parameters for Storybook stories.
|
|
46
|
+
*
|
|
47
|
+
* @see https://storybook.js.org/docs/essentials/actions#parameters
|
|
48
|
+
*
|
|
49
|
+
* @param actions - Configuration for actions parameters
|
|
50
|
+
* @returns An object containing the actions parameter configuration
|
|
51
|
+
*/
|
|
52
|
+
declare function defineActionsParam(actions: ActionsParam['actions']): {
|
|
53
|
+
actions: {
|
|
54
|
+
[k: string]: unknown;
|
|
55
|
+
argTypesRegex?: string | undefined;
|
|
56
|
+
disable?: boolean | undefined;
|
|
57
|
+
handles?: string[] | undefined;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
//#endregion
|
|
61
|
+
//#region src/parameters/define_backgrounds_param.d.ts
|
|
62
|
+
interface BackgroundsParam {
|
|
63
|
+
backgrounds: {
|
|
64
|
+
default?: string | undefined;
|
|
65
|
+
values?: Array<{
|
|
66
|
+
name: string;
|
|
67
|
+
value: string;
|
|
68
|
+
}>;
|
|
69
|
+
disable?: boolean | undefined;
|
|
70
|
+
grid?: {
|
|
71
|
+
cellAmount?: number | undefined;
|
|
72
|
+
cellSize?: number | undefined;
|
|
73
|
+
disable?: boolean | undefined;
|
|
74
|
+
offsetX?: number | undefined;
|
|
75
|
+
offsetY?: number | undefined;
|
|
76
|
+
opacity?: number | undefined;
|
|
77
|
+
} | undefined;
|
|
78
|
+
[k: string]: unknown;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
interface GlobalApiBackgroundsParam {
|
|
82
|
+
backgrounds: {
|
|
83
|
+
default?: string | undefined;
|
|
84
|
+
options?: Array<{
|
|
85
|
+
name: string;
|
|
86
|
+
value: string;
|
|
87
|
+
}>;
|
|
88
|
+
disabled?: boolean | undefined;
|
|
89
|
+
grid?: {
|
|
90
|
+
cellAmount?: number | undefined;
|
|
91
|
+
cellSize?: number | undefined;
|
|
92
|
+
disable?: boolean | undefined;
|
|
93
|
+
offsetX?: number | undefined;
|
|
94
|
+
offsetY?: number | undefined;
|
|
95
|
+
opacity?: number | undefined;
|
|
96
|
+
} | undefined;
|
|
97
|
+
[k: string]: unknown;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Defines backgrounds parameters for Storybook stories.
|
|
102
|
+
*
|
|
103
|
+
* @param backgrounds - The backgrounds configuration
|
|
104
|
+
* @returns An object containing the backgrounds parameter configuration
|
|
105
|
+
*/
|
|
106
|
+
declare const defineBackgroundsParam: (backgrounds: BackgroundsParam["backgrounds"] | GlobalApiBackgroundsParam["backgrounds"]) => BackgroundsParam;
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/parameters/define_docs_param.d.ts
|
|
109
|
+
declare global {
|
|
110
|
+
namespace JSX {
|
|
111
|
+
interface Element {}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
interface SourceProps {
|
|
115
|
+
/**
|
|
116
|
+
* Provides the source code to be rendered.
|
|
117
|
+
*
|
|
118
|
+
* This is useful when the story contains extra code that would be confusing in the docs.
|
|
119
|
+
*
|
|
120
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-source#code
|
|
121
|
+
*/
|
|
122
|
+
code?: string | undefined;
|
|
123
|
+
/**
|
|
124
|
+
* Specifies whether the source code should be rendered in dark mode.
|
|
125
|
+
*
|
|
126
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-source#dark
|
|
127
|
+
*/
|
|
128
|
+
dark?: boolean | undefined;
|
|
129
|
+
/**
|
|
130
|
+
* Specifies whether decorators should be excluded from the source code.
|
|
131
|
+
*
|
|
132
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-source#excludedecorators
|
|
133
|
+
*
|
|
134
|
+
* Note: Has no effect in React.
|
|
135
|
+
* @see https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#parameter-docssourceexcludedecorators-has-no-effect-in-react
|
|
136
|
+
*/
|
|
137
|
+
excludeDecorators?: boolean | undefined;
|
|
138
|
+
/**
|
|
139
|
+
* Specifies the language of the source code.
|
|
140
|
+
*
|
|
141
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-source#language
|
|
142
|
+
*/
|
|
143
|
+
language?: string | undefined;
|
|
144
|
+
/**
|
|
145
|
+
* A function to dynamically transform the source before being rendered,
|
|
146
|
+
* based on the original source and any story context necessary.
|
|
147
|
+
* The returned string is displayed as-is.
|
|
148
|
+
*
|
|
149
|
+
* If both code and transform are specified, transform will be ignored.
|
|
150
|
+
*
|
|
151
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-source#transform
|
|
152
|
+
*/
|
|
153
|
+
transform?: ((code: string, storyContext: StoryContext) => string) | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* Specifies how the source code is rendered.
|
|
156
|
+
*
|
|
157
|
+
* - 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
|
|
158
|
+
* - code: Renders the value of code prop, otherwise renders static story source
|
|
159
|
+
* - dynamic: Renders the story source with dynamically updated arg values
|
|
160
|
+
*
|
|
161
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-source#type
|
|
162
|
+
*/
|
|
163
|
+
type?: 'auto' | 'code' | 'dynamic' | undefined;
|
|
164
|
+
}
|
|
165
|
+
interface DocsParam {
|
|
166
|
+
docs: {
|
|
167
|
+
argTypes?: {
|
|
168
|
+
/**
|
|
169
|
+
* Specifies which controls to exclude from the args table.
|
|
170
|
+
* Any controls whose names match the regex or are part of the array will be left out.
|
|
171
|
+
*
|
|
172
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-argtypes#exclude
|
|
173
|
+
*/
|
|
174
|
+
exclude?: string[] | RegExp | undefined;
|
|
175
|
+
/**
|
|
176
|
+
* Specifies which controls to include in the args table.
|
|
177
|
+
* Any controls whose names don't match the regex or are not part of the array will be left out.
|
|
178
|
+
*
|
|
179
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-argtypes#include
|
|
180
|
+
*/
|
|
181
|
+
include?: string[] | RegExp | undefined;
|
|
182
|
+
/**
|
|
183
|
+
* Specifies how the arg types are sorted.
|
|
184
|
+
*
|
|
185
|
+
* - none: Unsorted, displayed in the same order the arg types are processed in
|
|
186
|
+
* - alpha: Sorted alphabetically, by the arg type's name
|
|
187
|
+
* - requiredFirst: Same as alpha, with any required arg types displayed first
|
|
188
|
+
*
|
|
189
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-argtypes#sort
|
|
190
|
+
*/
|
|
191
|
+
sort?: 'alpha' | 'requiredFirst' | 'none' | undefined;
|
|
192
|
+
} | undefined;
|
|
193
|
+
description?: {
|
|
194
|
+
/**
|
|
195
|
+
* `docs.description.story` can be used to describe the story in doc.
|
|
196
|
+
*/
|
|
197
|
+
story?: string | undefined;
|
|
198
|
+
/**
|
|
199
|
+
* `docs.description.component` can be used to describe the component in meta.
|
|
200
|
+
* It has no effect on the stories.
|
|
201
|
+
*/
|
|
202
|
+
component?: string | undefined;
|
|
203
|
+
} | undefined;
|
|
204
|
+
/**
|
|
205
|
+
* Determines whether to show the code panel.
|
|
206
|
+
*
|
|
207
|
+
* @see https://storybook.js.org/docs/writing-docs/code-panel
|
|
208
|
+
*/
|
|
209
|
+
codePanel?: boolean | undefined;
|
|
210
|
+
source?: SourceProps | undefined;
|
|
211
|
+
canvas?: {
|
|
212
|
+
/**
|
|
213
|
+
* Provides any additional custom actions to show in the bottom right corner.
|
|
214
|
+
* These are simple buttons that do anything you specify in the onClick function.
|
|
215
|
+
*
|
|
216
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-canvas#additionalactions
|
|
217
|
+
*/
|
|
218
|
+
additionalActions?: Array<{
|
|
219
|
+
title: string | JSX.Element;
|
|
220
|
+
className?: string;
|
|
221
|
+
onClick: () => void;
|
|
222
|
+
disabled?: boolean;
|
|
223
|
+
}> | undefined;
|
|
224
|
+
/**
|
|
225
|
+
* Provides HTML class(es) to the preview element, for custom styling.
|
|
226
|
+
*
|
|
227
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-canvas#classname
|
|
228
|
+
*/
|
|
229
|
+
className?: string | undefined;
|
|
230
|
+
/**
|
|
231
|
+
* Specifies how the canvas should layout the story.
|
|
232
|
+
*
|
|
233
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-canvas#layout
|
|
234
|
+
*/
|
|
235
|
+
layout?: 'centered' | 'padded' | 'fullscreen' | undefined;
|
|
236
|
+
/**
|
|
237
|
+
* Specifies the initial state of the source panel.
|
|
238
|
+
*
|
|
239
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-canvas#sourcestate
|
|
240
|
+
*/
|
|
241
|
+
sourceState?: 'hidden' | 'shown' | 'none' | undefined;
|
|
242
|
+
/**
|
|
243
|
+
* Determines whether to render a toolbar containing tools to interact with the story.
|
|
244
|
+
*
|
|
245
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-canvas#withtoolbar
|
|
246
|
+
*/
|
|
247
|
+
withToolbar?: boolean | undefined;
|
|
248
|
+
} | undefined;
|
|
249
|
+
controls?: {
|
|
250
|
+
/**
|
|
251
|
+
* Specifies which controls to exclude from the args table.
|
|
252
|
+
* Any controls whose names match the regex or are part of the array will be left out.
|
|
253
|
+
*
|
|
254
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-controls#exclude
|
|
255
|
+
*/
|
|
256
|
+
exclude?: string[] | RegExp | undefined;
|
|
257
|
+
/**
|
|
258
|
+
* Specifies which controls to include in the args table.
|
|
259
|
+
* Any controls whose names don't match the regex or are not part of the array will be left out.
|
|
260
|
+
*
|
|
261
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-controls#include
|
|
262
|
+
*/
|
|
263
|
+
include?: string[] | RegExp | undefined;
|
|
264
|
+
/**
|
|
265
|
+
*
|
|
266
|
+
* Specifies how the controls are sorted.
|
|
267
|
+
*
|
|
268
|
+
* - none: Unsorted, displayed in the same order the controls are processed in
|
|
269
|
+
* - alpha: Sorted alphabetically, by the arg type's name
|
|
270
|
+
* - requiredFirst: Same as alpha, with any required controls displayed first
|
|
271
|
+
*
|
|
272
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-controls#sort
|
|
273
|
+
*/
|
|
274
|
+
sort?: 'alpha' | 'requiredFirst' | 'none' | undefined;
|
|
275
|
+
} | undefined;
|
|
276
|
+
story?: {
|
|
277
|
+
/**
|
|
278
|
+
* Specifies whether the story should be autoplayed.
|
|
279
|
+
*
|
|
280
|
+
* @see https://storybook.js.org/docs/api/doc-blocks/doc-block-story#autoplay
|
|
281
|
+
*/
|
|
282
|
+
autoplay?: boolean | undefined;
|
|
283
|
+
/**
|
|
284
|
+
* Set a minimum height (note for an iframe this is the actual height) when rendering a story in an iframe or inline.
|
|
285
|
+
* This overrides parameters.docs.story.iframeHeight for iframes.
|
|
286
|
+
*/
|
|
287
|
+
height?: string | undefined;
|
|
288
|
+
/**
|
|
289
|
+
* Determines whether the story is rendered inline (in the same browser frame as the other docs content) or in an iframe.
|
|
290
|
+
*/
|
|
291
|
+
inline?: boolean | undefined;
|
|
292
|
+
} | undefined;
|
|
293
|
+
[k: string]: unknown;
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Defines docs parameters for Storybook stories.
|
|
298
|
+
*
|
|
299
|
+
* @param docs - Configuration for docs parameters including options for:
|
|
300
|
+
* - Controls display and sorting
|
|
301
|
+
* - Story rendering (autoplay, height, inline vs iframe)
|
|
302
|
+
* - And other docs-related settings
|
|
303
|
+
* @returns An object containing the docs parameter configuration
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* ```ts
|
|
307
|
+
* import { defineDocsParam } from '@repobuddy/storybook'
|
|
308
|
+
*
|
|
309
|
+
* export default {
|
|
310
|
+
* parameters: defineDocsParam({
|
|
311
|
+
* controls: {
|
|
312
|
+
* sort: 'alpha',
|
|
313
|
+
* exclude: ['internal*']
|
|
314
|
+
* },
|
|
315
|
+
* story: {
|
|
316
|
+
* inline: true,
|
|
317
|
+
* height: '400px'
|
|
318
|
+
* }
|
|
319
|
+
* })
|
|
320
|
+
* }
|
|
321
|
+
* ```
|
|
322
|
+
*/
|
|
323
|
+
declare function defineDocsParam(docs: DocsParam['docs']): DocsParam['docs'];
|
|
324
|
+
//#endregion
|
|
325
|
+
//#region src/parameters/define_layout_param.d.ts
|
|
326
|
+
interface LayoutParam {
|
|
327
|
+
layout: 'padded' | 'fullscreen' | 'centered';
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Helper function to define the layout parameter for a story
|
|
331
|
+
*
|
|
332
|
+
* @see https://storybook.js.org/docs/api/parameters#layout
|
|
333
|
+
*
|
|
334
|
+
* @param layout - The layout type to use ('padded', 'fullscreen', or 'centered')
|
|
335
|
+
* @returns An object containing the layout parameter
|
|
336
|
+
* @example
|
|
337
|
+
* ```ts
|
|
338
|
+
* export const MyStory = {
|
|
339
|
+
* parameters: defineLayoutParam('centered')
|
|
340
|
+
* }
|
|
341
|
+
* ```
|
|
342
|
+
*/
|
|
343
|
+
declare const defineLayoutParam: (layout: LayoutParam["layout"]) => {
|
|
344
|
+
layout: "padded" | "fullscreen" | "centered";
|
|
345
|
+
};
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/parameters/define_test_param.d.ts
|
|
348
|
+
interface TestParam {
|
|
349
|
+
test: {
|
|
350
|
+
clearMocks?: boolean | undefined;
|
|
351
|
+
mockReset?: boolean | undefined;
|
|
352
|
+
restoreMocks?: boolean | undefined;
|
|
353
|
+
dangerouslyIgnoreUnhandledErrors?: boolean | undefined;
|
|
354
|
+
[k: string]: unknown;
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Defines test parameters for Storybook stories.
|
|
359
|
+
*
|
|
360
|
+
* @see https://storybook.js.org/docs/api/parameters#test
|
|
361
|
+
*
|
|
362
|
+
* @param test - Configuration for test parameters
|
|
363
|
+
* @returns An object containing the test parameter configuration
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* defineTestParam({
|
|
367
|
+
* clearMocks: true,
|
|
368
|
+
* mockReset: true,
|
|
369
|
+
* restoreMocks: true,
|
|
370
|
+
* dangerouslyIgnoreUnhandledErrors: true
|
|
371
|
+
* })
|
|
372
|
+
*/
|
|
373
|
+
declare function defineTestParam(test: TestParam['test']): {
|
|
374
|
+
test: {
|
|
375
|
+
[k: string]: unknown;
|
|
376
|
+
clearMocks?: boolean | undefined;
|
|
377
|
+
mockReset?: boolean | undefined;
|
|
378
|
+
restoreMocks?: boolean | undefined;
|
|
379
|
+
dangerouslyIgnoreUnhandledErrors?: boolean | undefined;
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
//#endregion
|
|
383
|
+
//#region src/parameters/define_viewport_param.d.ts
|
|
384
|
+
interface ViewportParam {
|
|
385
|
+
viewport: {
|
|
386
|
+
/**
|
|
387
|
+
* @see https://storybook.js.org/docs/essentials/viewport#viewports
|
|
388
|
+
*/
|
|
389
|
+
viewports?: Record<string, Viewport> | undefined;
|
|
390
|
+
/**
|
|
391
|
+
* @see https://storybook.js.org/docs/essentials/viewport#defaultorientation
|
|
392
|
+
*/
|
|
393
|
+
defaultOrientation?: 'landscape' | 'portrait' | undefined;
|
|
394
|
+
/**
|
|
395
|
+
* @see https://storybook.js.org/docs/essentials/viewport#defaultviewport
|
|
396
|
+
*/
|
|
397
|
+
defaultViewport?: string | undefined;
|
|
398
|
+
/**
|
|
399
|
+
* Disables the viewport parameter.
|
|
400
|
+
* @deprecated Use `disabled` instead.
|
|
401
|
+
*/
|
|
402
|
+
disable?: boolean | undefined;
|
|
403
|
+
[k: string]: unknown;
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
interface Viewport {
|
|
407
|
+
name: string;
|
|
408
|
+
styles: {
|
|
409
|
+
width: string;
|
|
410
|
+
height: string;
|
|
411
|
+
};
|
|
412
|
+
type: 'mobile' | 'tablet' | 'desktop';
|
|
413
|
+
}
|
|
414
|
+
interface GlobalApiViewportParam {
|
|
415
|
+
viewport: {
|
|
416
|
+
/**
|
|
417
|
+
* @see https://storybook.js.org/docs/essentials/viewport#viewports
|
|
418
|
+
*/
|
|
419
|
+
options?: Record<string, Viewport> | undefined;
|
|
420
|
+
/**
|
|
421
|
+
* @see https://storybook.js.org/docs/essentials/viewport#defaultviewport
|
|
422
|
+
*/
|
|
423
|
+
defaultViewport?: string | undefined;
|
|
424
|
+
/**
|
|
425
|
+
* @see https://storybook.js.org/docs/essentials/viewport#defaultorientation
|
|
426
|
+
*/
|
|
427
|
+
defaultOrientation?: 'landscape' | 'portrait' | undefined;
|
|
428
|
+
/**
|
|
429
|
+
* @see https://storybook.js.org/docs/essentials/viewport#disable
|
|
430
|
+
*/
|
|
431
|
+
disabled?: boolean | undefined;
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Defines viewport parameters for Storybook stories.
|
|
436
|
+
*
|
|
437
|
+
* @see https://storybook.js.org/docs/api/parameters#viewport
|
|
438
|
+
*
|
|
439
|
+
* @param viewport - Configuration for viewport parameters including:
|
|
440
|
+
* - viewports: Custom viewport definitions
|
|
441
|
+
* - defaultViewport: The default viewport to use
|
|
442
|
+
* - defaultOrientation: Default orientation (landscape/portrait)
|
|
443
|
+
* - disabled: Whether viewport controls are disabled
|
|
444
|
+
* @returns An object containing the viewport parameter configuration
|
|
445
|
+
*
|
|
446
|
+
* @example
|
|
447
|
+
* ```ts
|
|
448
|
+
* defineViewportParam({
|
|
449
|
+
* viewports: {
|
|
450
|
+
* mobile: {
|
|
451
|
+
* name: 'Mobile',
|
|
452
|
+
* styles: { width: '320px', height: '568px' },
|
|
453
|
+
* type: 'mobile'
|
|
454
|
+
* }
|
|
455
|
+
* },
|
|
456
|
+
* defaultViewport: 'mobile',
|
|
457
|
+
* defaultOrientation: 'portrait'
|
|
458
|
+
* })
|
|
459
|
+
* ```
|
|
460
|
+
*/
|
|
461
|
+
declare function defineViewportParam(viewport: ViewportParam['viewport'] | GlobalApiViewportParam['viewport']): ViewportParam;
|
|
462
|
+
//#endregion
|
|
463
|
+
//#region src/parameters/story_sort.d.ts
|
|
464
|
+
type StorySortConfig = {
|
|
465
|
+
includeNames?: boolean;
|
|
466
|
+
locales?: string;
|
|
467
|
+
method?: 'alphabetical' | 'alphabetical-by-kind' | 'custom';
|
|
468
|
+
order?: string[];
|
|
469
|
+
[k: string]: unknown;
|
|
470
|
+
};
|
|
471
|
+
type Story = {
|
|
472
|
+
id: string;
|
|
473
|
+
importPath: string;
|
|
474
|
+
name: string;
|
|
475
|
+
title: string;
|
|
476
|
+
};
|
|
477
|
+
type StorySortFn = (a: Story, b: Story) => number;
|
|
478
|
+
/**
|
|
479
|
+
* Interface for story sorting parameters in Storybook.
|
|
480
|
+
* Used to define how stories should be sorted in the navigation sidebar.
|
|
481
|
+
*/
|
|
482
|
+
interface StorySortParam {
|
|
483
|
+
/**
|
|
484
|
+
* Configuration for story sorting. Can be either:
|
|
485
|
+
* - A StorySortConfig object specifying sort method and options
|
|
486
|
+
* - A custom sorting function that takes two stories and returns their sort order
|
|
487
|
+
*/
|
|
488
|
+
storySort: StorySortConfig | StorySortFn;
|
|
489
|
+
}
|
|
490
|
+
//#endregion
|
|
491
|
+
//#region src/parameters/define_parameters.d.ts
|
|
492
|
+
type StorybookBuiltInParams = Partial<BackgroundsParam | GlobalApiBackgroundsParam> & Partial<DocsParam> & Partial<LayoutParam> & Partial<TestParam> & Partial<ViewportParam> & {
|
|
493
|
+
options?: StorySortParam & Record<string, any>;
|
|
494
|
+
} & Record<string, any>;
|
|
495
|
+
/**
|
|
496
|
+
* Defines parameters for Storybook stories, combining built-in parameters with custom ones.
|
|
497
|
+
*
|
|
498
|
+
* @param parameters - Configuration object containing both built-in Storybook parameters and custom parameters
|
|
499
|
+
* @returns The combined parameters object
|
|
500
|
+
*
|
|
501
|
+
* @example
|
|
502
|
+
* ```ts
|
|
503
|
+
* import { defineParameters } from '@repobuddy/storybook'
|
|
504
|
+
*
|
|
505
|
+
* export default {
|
|
506
|
+
* parameters: defineParameters({
|
|
507
|
+
* // Built-in parameters
|
|
508
|
+
* layout: 'centered',
|
|
509
|
+
* backgrounds: {
|
|
510
|
+
* default: 'light',
|
|
511
|
+
* values: [
|
|
512
|
+
* { name: 'light', value: '#ffffff' },
|
|
513
|
+
* { name: 'dark', value: '#333333' }
|
|
514
|
+
* ]
|
|
515
|
+
* },
|
|
516
|
+
* // Custom parameters
|
|
517
|
+
* myCustomParam: {
|
|
518
|
+
* someValue: true
|
|
519
|
+
* }
|
|
520
|
+
* })
|
|
521
|
+
* }
|
|
522
|
+
* ```
|
|
523
|
+
*/
|
|
524
|
+
declare function defineParameters<P extends Record<string, any>>(param: P & StorybookBuiltInParams, ...rest: Array<StorybookBuiltInParams>): StorybookBuiltInParams;
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region src/testing/decorators/when_running_in_test.d.ts
|
|
527
|
+
/**
|
|
528
|
+
* executes the specified decorator or handler if the code is running in test.
|
|
529
|
+
*/
|
|
530
|
+
declare function whenRunningInTest<TArgs = StrictArgs>(decoratorOrHandler: ((...args: Parameters<Decorator<TArgs>>) => ReturnType<Decorator<TArgs>> | undefined | void) | (() => ReturnType<Decorator<TArgs>> | undefined | void)): Decorator<TArgs>;
|
|
531
|
+
//#endregion
|
|
532
|
+
//#region src/types.d.ts
|
|
533
|
+
/**
|
|
534
|
+
* Extends the Storybook Meta type with custom tag types
|
|
535
|
+
* @template TCmpOrArgs - The component or args type
|
|
536
|
+
* @template M - The base Meta type
|
|
537
|
+
* @template E - The extension type containing tagType
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* ```ts
|
|
541
|
+
* // Create a generic Meta type for a project
|
|
542
|
+
* type Meta<TCmpOrArgs = Args> = ExtendMeta<TCmpOrArgs, Meta<TCmpOrArgs>, { tagType: 'tag1' | 'tag2' }>
|
|
543
|
+
*
|
|
544
|
+
* // Create a specific Meta type for a component
|
|
545
|
+
* type Meta = ExtendMeta<typeof Component, Meta<typeof Component>, { tagType: 'tag1' | 'tag2' }>
|
|
546
|
+
* ```
|
|
547
|
+
*/
|
|
548
|
+
type ExtendMeta<TCmpOrArgs, M extends Meta<TCmpOrArgs>, E extends {
|
|
549
|
+
tag: string;
|
|
550
|
+
}> = Omit<M, 'tags'> & {
|
|
551
|
+
tags?: Array<E['tag'] | (string & {})> | undefined;
|
|
552
|
+
};
|
|
553
|
+
/**
|
|
554
|
+
* Extends the Storybook StoryObj type with custom tag types
|
|
555
|
+
* @template TMetaOrCmpOrArgs - The meta, component or args type
|
|
556
|
+
* @template S - The base StoryObj type
|
|
557
|
+
* @template E - The extension type containing tagType
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
* ```ts
|
|
561
|
+
* // Create a generic StoryObj type for a project
|
|
562
|
+
* type StoryObj<TMetaOrCmpOrArgs = Args> = ExtendStoryObj<TMetaOrCmpOrArgs, StoryObj<TMetaOrCmpOrArgs>, { tagType: 'tag1' | 'tag2' }>
|
|
563
|
+
*
|
|
564
|
+
* // Create a specific StoryObj type for a component
|
|
565
|
+
* type StoryObj = ExtendStoryObj<typeof Component, StoryObj<typeof Component>, { tagType: 'tag1' | 'tag2' }>
|
|
566
|
+
* ```
|
|
567
|
+
*/
|
|
568
|
+
type ExtendStoryObj<TMetaOrCmpOrArgs, S extends StoryObj<TMetaOrCmpOrArgs>, E extends {
|
|
569
|
+
tag: string;
|
|
570
|
+
}> = Omit<S, 'tags'> & {
|
|
571
|
+
tags?: Array<E['tag'] | (string & {})> | undefined;
|
|
572
|
+
};
|
|
573
|
+
//#endregion
|
|
574
|
+
export { ActionsParam, BackgroundsParam, DocsParam, ExtendMeta, ExtendStoryObj, GlobalApiBackgroundsParam, GlobalApiViewportParam, LayoutParam, ShowHtml, ShowHtmlProps, SourceProps, StorySortParam, StorybookBuiltInParams, TestParam, Viewport, ViewportParam, defineActionsParam, defineBackgroundsParam, defineDocsParam, defineLayoutParam, defineParameters, defineTestParam, defineViewportParam, showDocSource, whenRunningInTest };
|