@storybook/nextjs 9.2.0-alpha.3 → 10.0.0-beta.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 +3 -1
- package/dist/_browser-chunks/chunk-I5RFHXDS.js +40 -0
- package/dist/_browser-chunks/chunk-JOMP7DUK.js +261 -0
- package/dist/_browser-chunks/chunk-L5NVL7MD.js +37 -0
- package/dist/_browser-chunks/react-18-G7Q4PNHD.js +71 -0
- package/dist/_node-chunks/chunk-24UYJEDD.js +74 -0
- package/dist/_node-chunks/chunk-EZEBG77A.js +88 -0
- package/dist/_node-chunks/chunk-WCSGFZKZ.js +17 -0
- package/dist/_node-chunks/chunk-YMVPQWBH.js +167 -0
- package/dist/_node-chunks/configureNextFont-HBRWHAUG.js +36 -0
- package/dist/_node-chunks/loader-KXTZ5PJ5.js +51 -0
- package/dist/_node-chunks/loader-Z4IXWF5M.js +64 -0
- package/dist/_node-chunks/utils-4LRBHVQD.js +31 -0
- package/dist/_node-chunks/webpack-6HAXGE7X.js +38 -0
- package/dist/_node-chunks/webpack-AGNCA7HZ.js +77 -0
- package/dist/_node-chunks/webpack-CXSD35E6.js +30 -0
- package/dist/_node-chunks/webpack-EWT6TRQB.js +26 -0
- package/dist/_node-chunks/webpack-K2R3GUFU.js +29 -0
- package/dist/_node-chunks/webpack-PD7PIB6X.js +43 -0
- package/dist/_node-chunks/webpack-QFTZE3CE.js +27 -0
- package/dist/_node-chunks/webpack-SWQY6JJY.js +107 -0
- package/dist/compatibility/draft-mode.compat.js +7 -1
- package/dist/export-mocks/cache/index.d.ts +309 -1
- package/dist/export-mocks/cache/index.js +22 -1
- package/dist/export-mocks/headers/index.d.ts +309 -1
- package/dist/export-mocks/headers/index.js +77 -1
- package/dist/export-mocks/index.js +20 -1
- package/dist/export-mocks/navigation/index.js +88 -1
- package/dist/export-mocks/router/index.d.ts +2 -2
- package/dist/export-mocks/router/index.js +97 -1
- package/dist/font/webpack/loader/storybook-nextjs-font-loader.js +201 -14
- package/dist/image-context.js +8 -1
- package/dist/images/next-image.js +35 -1
- package/dist/images/next-legacy-image.js +21 -1
- package/dist/index.d.ts +53 -8
- package/dist/index.js +20237 -45
- package/dist/next-image-loader-stub.js +33 -1
- package/dist/node/index.d.ts +27 -6
- package/dist/node/index.js +23 -1
- package/dist/preset.js +830 -1
- package/dist/preview.d.ts +3 -18
- package/dist/preview.d.tsx +18 -0
- package/dist/preview.js +11 -1
- package/dist/rsc/server-only.js +7 -1
- package/dist/swc/next-swc-loader-patch.js +136 -1
- package/package.json +41 -122
- package/preset.js +1 -1
- package/template/cli/js/Configure.mdx +11 -11
- package/template/cli/ts/Configure.mdx +11 -11
- package/dist/chunk-2TZKD6A5.mjs +0 -20
- package/dist/chunk-ETFXNGLC.mjs +0 -3
- package/dist/chunk-L66KIASX.mjs +0 -3
- package/dist/chunk-NQ32RFK2.mjs +0 -6
- package/dist/compatibility/draft-mode.compat.d.ts +0 -1
- package/dist/compatibility/draft-mode.compat.mjs +0 -2
- package/dist/export-mocks/cache/index.mjs +0 -10
- package/dist/export-mocks/headers/index.mjs +0 -12
- package/dist/export-mocks/index.d.ts +0 -7
- package/dist/export-mocks/index.mjs +0 -11
- package/dist/export-mocks/navigation/index.mjs +0 -11
- package/dist/export-mocks/router/index.mjs +0 -10
- package/dist/font/webpack/loader/storybook-nextjs-font-loader.d.ts +0 -3
- package/dist/font/webpack/loader/storybook-nextjs-font-loader.mjs +0 -56
- package/dist/image-context.d.ts +0 -13
- package/dist/image-context.mjs +0 -6
- package/dist/images/decorator.d.ts +0 -6
- package/dist/images/decorator.js +0 -1
- package/dist/images/decorator.mjs +0 -2
- package/dist/images/next-image.d.ts +0 -28
- package/dist/images/next-image.mjs +0 -9
- package/dist/images/next-legacy-image.d.ts +0 -6
- package/dist/images/next-legacy-image.mjs +0 -9
- package/dist/index.d-ff220430.d.ts +0 -310
- package/dist/index.mjs +0 -58
- package/dist/next-image-loader-stub.d.ts +0 -10
- package/dist/next-image-loader-stub.mjs +0 -7
- package/dist/node/index.mjs +0 -5
- package/dist/preset.d.ts +0 -14
- package/dist/preview.mjs +0 -3
- package/dist/react-18-WSPZ3BUV.mjs +0 -7
- package/dist/rsc/server-only.d.ts +0 -3
- package/dist/rsc/server-only.mjs +0 -5
- package/dist/swc/next-swc-loader-patch.d.ts +0 -21
- package/dist/swc/next-swc-loader-patch.mjs +0 -8
- package/dist/types-f6ea2c09.d.ts +0 -54
|
@@ -1,23 +1,167 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_e3twfmexlgl from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_e3twfmexlgl from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_e3twfmexlgl from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_e3twfmexlgl.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_e3twfmexlgl.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_e3twfmexlgl.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
import {
|
|
13
|
+
__name
|
|
14
|
+
} from "../../../_node-chunks/chunk-WCSGFZKZ.js";
|
|
15
|
+
|
|
16
|
+
// src/font/webpack/loader/storybook-nextjs-font-loader.ts
|
|
17
|
+
import { sep } from "node:path";
|
|
18
|
+
|
|
19
|
+
// src/font/webpack/loader/google/get-font-face-declarations.ts
|
|
20
|
+
import {
|
|
21
|
+
GoogleFontsDownloadError,
|
|
22
|
+
GoogleFontsLoadingError
|
|
23
|
+
} from "storybook/internal/server-errors";
|
|
24
|
+
import { fetchCSSFromGoogleFonts } from "next/dist/compiled/@next/font/dist/google/fetch-css-from-google-fonts.js";
|
|
25
|
+
import { getFontAxes } from "next/dist/compiled/@next/font/dist/google/get-font-axes.js";
|
|
26
|
+
import { getGoogleFontsUrl } from "next/dist/compiled/@next/font/dist/google/get-google-fonts-url.js";
|
|
27
|
+
import { validateGoogleFontFunctionCall } from "next/dist/compiled/@next/font/dist/google/validate-google-font-function-call.js";
|
|
28
|
+
import loaderUtils from "next/dist/compiled/loader-utils3/index.js";
|
|
29
|
+
var cssCache = /* @__PURE__ */ new Map();
|
|
30
|
+
async function getFontFaceDeclarations(options) {
|
|
31
|
+
const { fontFamily, weights, styles, selectedVariableAxes, display, variable } = validateGoogleFontFunctionCall(options.fontFamily, options.props);
|
|
32
|
+
const fontAxes = getFontAxes(fontFamily, weights, styles, selectedVariableAxes);
|
|
33
|
+
const url = getGoogleFontsUrl(fontFamily, fontAxes, display);
|
|
34
|
+
try {
|
|
35
|
+
const hasCachedCSS = cssCache.has(url);
|
|
36
|
+
const fontFaceCSS = hasCachedCSS ? cssCache.get(url) : await fetchCSSFromGoogleFonts(url, fontFamily, true).catch(() => null);
|
|
37
|
+
if (!hasCachedCSS) {
|
|
38
|
+
cssCache.set(url, fontFaceCSS);
|
|
39
|
+
} else {
|
|
40
|
+
cssCache.delete(url);
|
|
41
|
+
}
|
|
42
|
+
if (fontFaceCSS === null) {
|
|
43
|
+
throw new GoogleFontsDownloadError({
|
|
44
|
+
fontFamily,
|
|
45
|
+
url
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
id: loaderUtils.getHashDigest(url, "md5", "hex", 6),
|
|
50
|
+
fontFamily,
|
|
51
|
+
fontFaceCSS,
|
|
52
|
+
weights,
|
|
53
|
+
styles,
|
|
54
|
+
variable
|
|
55
|
+
};
|
|
56
|
+
} catch (error) {
|
|
57
|
+
throw new GoogleFontsLoadingError({ error, url });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
__name(getFontFaceDeclarations, "getFontFaceDeclarations");
|
|
61
|
+
|
|
62
|
+
// src/font/webpack/loader/local/get-font-face-declarations.ts
|
|
63
|
+
import { dirname, join } from "node:path";
|
|
64
|
+
import { getProjectRoot } from "storybook/internal/common";
|
|
65
|
+
import { validateLocalFontFunctionCall } from "next/dist/compiled/@next/font/dist/local/validate-local-font-function-call.js";
|
|
66
|
+
import loaderUtils2 from "next/dist/compiled/loader-utils3/index.js";
|
|
67
|
+
async function getFontFaceDeclarations2(options, rootContext, swcMode) {
|
|
68
|
+
const localFontSrc = options.props.src;
|
|
69
|
+
const parentFolder = swcMode ? dirname(join(getProjectRoot(), options.filename)).replace(rootContext, "") : dirname(options.filename).replace(rootContext, "");
|
|
70
|
+
const {
|
|
71
|
+
weight,
|
|
72
|
+
style,
|
|
73
|
+
variable,
|
|
74
|
+
declarations = []
|
|
75
|
+
} = validateLocalFontFunctionCall("", options.props);
|
|
76
|
+
const id = `font-${loaderUtils2.getHashDigest(
|
|
77
|
+
Buffer.from(JSON.stringify(localFontSrc)),
|
|
78
|
+
"md5",
|
|
79
|
+
"hex",
|
|
80
|
+
6
|
|
81
|
+
)}`;
|
|
82
|
+
const fontDeclarations = declarations.map(({ prop, value }) => `${prop}: ${value};`).join("\n");
|
|
83
|
+
const getFontFaceCSS = /* @__PURE__ */ __name(() => {
|
|
84
|
+
if (typeof localFontSrc === "string") {
|
|
85
|
+
const localFontPath = join(parentFolder, localFontSrc).replaceAll("\\", "/");
|
|
86
|
+
return `@font-face {
|
|
3
87
|
font-family: ${id};
|
|
4
88
|
src: url(.${localFontPath});
|
|
5
89
|
${fontDeclarations}
|
|
6
|
-
}
|
|
90
|
+
}`;
|
|
91
|
+
}
|
|
92
|
+
return localFontSrc.map((font) => {
|
|
93
|
+
const localFontPath = join(parentFolder, font.path).replaceAll("\\", "/");
|
|
94
|
+
return `@font-face {
|
|
7
95
|
font-family: ${id};
|
|
8
96
|
src: url(.${localFontPath});
|
|
9
|
-
${font.weight
|
|
10
|
-
${font.style
|
|
97
|
+
${font.weight ? `font-weight: ${font.weight};` : ""}
|
|
98
|
+
${font.style ? `font-style: ${font.style};` : ""}
|
|
11
99
|
${fontDeclarations}
|
|
12
|
-
}
|
|
100
|
+
}`;
|
|
101
|
+
}).join("");
|
|
102
|
+
}, "getFontFaceCSS");
|
|
103
|
+
return {
|
|
104
|
+
id,
|
|
105
|
+
fontFamily: id,
|
|
106
|
+
fontFaceCSS: getFontFaceCSS(),
|
|
107
|
+
weights: weight ? [weight] : [],
|
|
108
|
+
styles: style ? [style] : [],
|
|
109
|
+
variable
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
__name(getFontFaceDeclarations2, "getFontFaceDeclarations");
|
|
113
|
+
|
|
114
|
+
// src/font/webpack/loader/utils/get-css-meta.ts
|
|
115
|
+
function getCSSMeta(options) {
|
|
116
|
+
const className = getClassName(options);
|
|
117
|
+
const style = getStylesObj(options);
|
|
118
|
+
const variableClassName = `__variable_${className}`;
|
|
119
|
+
const classNamesCSS = `
|
|
13
120
|
.${className} {
|
|
14
121
|
font-family: ${options.fontFamily};
|
|
15
|
-
${isNextCSSPropertyValid(options.styles)
|
|
16
|
-
${isNextCSSPropertyValid(options.weights)
|
|
122
|
+
${isNextCSSPropertyValid(options.styles) ? `font-style: ${options.styles[0]};` : ""}
|
|
123
|
+
${isNextCSSPropertyValid(options.weights) ? `font-weight: ${options.weights[0]};` : ""}
|
|
17
124
|
}
|
|
18
125
|
|
|
19
|
-
${options.variable
|
|
20
|
-
|
|
126
|
+
${options.variable ? `.${variableClassName} { ${options.variable}: '${options.fontFamily}'; }` : ""}
|
|
127
|
+
`;
|
|
128
|
+
const fontFaceCSS = `${changeFontDisplayToSwap(options.fontFaceCSS)}`;
|
|
129
|
+
return {
|
|
130
|
+
className,
|
|
131
|
+
fontFaceCSS,
|
|
132
|
+
classNamesCSS,
|
|
133
|
+
style,
|
|
134
|
+
...options.variable ? { variableClassName } : {}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
__name(getCSSMeta, "getCSSMeta");
|
|
138
|
+
function getClassName({ styles, weights, fontFamily }) {
|
|
139
|
+
const font = fontFamily.replaceAll(" ", "-").toLowerCase();
|
|
140
|
+
const style = isNextCSSPropertyValid(styles) ? styles[0] : null;
|
|
141
|
+
const weight = isNextCSSPropertyValid(weights) ? weights[0] : null;
|
|
142
|
+
return `${font}${style ? `-${style}` : ""}${weight ? `-${weight}` : ""}`;
|
|
143
|
+
}
|
|
144
|
+
__name(getClassName, "getClassName");
|
|
145
|
+
function getStylesObj({ styles, weights, fontFamily }) {
|
|
146
|
+
return {
|
|
147
|
+
fontFamily,
|
|
148
|
+
...isNextCSSPropertyValid(styles) ? { fontStyle: styles[0] } : {},
|
|
149
|
+
...isNextCSSPropertyValid(weights) ? { fontWeight: weights[0] } : {}
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
__name(getStylesObj, "getStylesObj");
|
|
153
|
+
function isNextCSSPropertyValid(prop) {
|
|
154
|
+
return prop.length === 1 && prop[0] !== "variable";
|
|
155
|
+
}
|
|
156
|
+
__name(isNextCSSPropertyValid, "isNextCSSPropertyValid");
|
|
157
|
+
function changeFontDisplayToSwap(css) {
|
|
158
|
+
return css.replaceAll("font-display: optional;", "font-display: block;");
|
|
159
|
+
}
|
|
160
|
+
__name(changeFontDisplayToSwap, "changeFontDisplayToSwap");
|
|
161
|
+
|
|
162
|
+
// src/font/webpack/loader/utils/set-font-declarations-in-head.ts
|
|
163
|
+
function setFontDeclarationsInHead({ id, fontFaceCSS, classNamesCSS }) {
|
|
164
|
+
return `
|
|
21
165
|
if (!document.getElementById('id-${id}')) {
|
|
22
166
|
const fontDeclarations = \`${fontFaceCSS}\`;
|
|
23
167
|
const style = document.createElement('style');
|
|
@@ -32,12 +176,55 @@
|
|
|
32
176
|
document.head.appendChild(classNamesStyle);
|
|
33
177
|
|
|
34
178
|
}
|
|
35
|
-
|
|
36
|
-
|
|
179
|
+
`;
|
|
180
|
+
}
|
|
181
|
+
__name(setFontDeclarationsInHead, "setFontDeclarationsInHead");
|
|
182
|
+
|
|
183
|
+
// src/font/webpack/loader/storybook-nextjs-font-loader.ts
|
|
184
|
+
async function storybookNextjsFontLoader() {
|
|
185
|
+
const loaderOptions = this.getOptions();
|
|
186
|
+
let swcMode = false;
|
|
187
|
+
let options;
|
|
188
|
+
if (Object.keys(loaderOptions).length > 0) {
|
|
189
|
+
options = loaderOptions;
|
|
190
|
+
} else {
|
|
191
|
+
const importQuery = JSON.parse(this.resourceQuery.slice(1));
|
|
192
|
+
swcMode = true;
|
|
193
|
+
options = {
|
|
194
|
+
filename: importQuery.path,
|
|
195
|
+
fontFamily: importQuery.import,
|
|
196
|
+
props: importQuery.arguments[0],
|
|
197
|
+
source: this.context.replace(this.rootContext, "")
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
const rootCtx = this.rootContext;
|
|
201
|
+
let fontFaceDeclaration;
|
|
202
|
+
const pathSep = sep;
|
|
203
|
+
if (options.source.endsWith(`next${pathSep}font${pathSep}google`) || options.source.endsWith(`@next${pathSep}font${pathSep}google`)) {
|
|
204
|
+
fontFaceDeclaration = await getFontFaceDeclarations(options);
|
|
205
|
+
}
|
|
206
|
+
if (options.source.endsWith(`next${pathSep}font${pathSep}local`) || options.source.endsWith(`@next${pathSep}font${pathSep}local`)) {
|
|
207
|
+
fontFaceDeclaration = await getFontFaceDeclarations2(options, rootCtx, swcMode);
|
|
208
|
+
}
|
|
209
|
+
if (typeof fontFaceDeclaration !== "undefined") {
|
|
210
|
+
const cssMeta = getCSSMeta(fontFaceDeclaration);
|
|
211
|
+
return `
|
|
212
|
+
${setFontDeclarationsInHead({
|
|
213
|
+
fontFaceCSS: cssMeta.fontFaceCSS,
|
|
214
|
+
id: fontFaceDeclaration.id,
|
|
215
|
+
classNamesCSS: cssMeta.classNamesCSS
|
|
216
|
+
})}
|
|
37
217
|
|
|
38
218
|
module.exports = {
|
|
39
219
|
className: "${cssMeta.className}",
|
|
40
220
|
style: ${JSON.stringify(cssMeta.style)}
|
|
41
|
-
${cssMeta.variableClassName
|
|
221
|
+
${cssMeta.variableClassName ? `, variable: "${cssMeta.variableClassName}"` : ""}
|
|
42
222
|
}
|
|
43
|
-
|
|
223
|
+
`;
|
|
224
|
+
}
|
|
225
|
+
return `module.exports = {}`;
|
|
226
|
+
}
|
|
227
|
+
__name(storybookNextjsFontLoader, "storybookNextjsFontLoader");
|
|
228
|
+
export {
|
|
229
|
+
storybookNextjsFontLoader as default
|
|
230
|
+
};
|
package/dist/image-context.js
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import "./_browser-chunks/chunk-L5NVL7MD.js";
|
|
2
|
+
|
|
3
|
+
// src/image-context.ts
|
|
4
|
+
import { createContext } from "react";
|
|
5
|
+
var ImageContext = createContext({});
|
|
6
|
+
export {
|
|
7
|
+
ImageContext
|
|
8
|
+
};
|
|
@@ -1 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
defaultLoader
|
|
3
|
+
} from "../_browser-chunks/chunk-I5RFHXDS.js";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "../_browser-chunks/chunk-L5NVL7MD.js";
|
|
7
|
+
|
|
8
|
+
// src/images/next-image.tsx
|
|
9
|
+
import React from "react";
|
|
10
|
+
import { ImageContext as ImageContextValue } from "@storybook/nextjs/image-context";
|
|
11
|
+
import * as NextImageNamespace from "sb-original/next/image";
|
|
12
|
+
var OriginalNextImage = NextImageNamespace.default;
|
|
13
|
+
var { getImageProps: originalGetImageProps } = NextImageNamespace;
|
|
14
|
+
var ImageContext = ImageContextValue;
|
|
15
|
+
var MockedNextImage = React.forwardRef(
|
|
16
|
+
({ loader, ...props }, ref) => {
|
|
17
|
+
const imageParameters = React.useContext(ImageContext);
|
|
18
|
+
return React.createElement(
|
|
19
|
+
OriginalNextImage,
|
|
20
|
+
{
|
|
21
|
+
ref,
|
|
22
|
+
...imageParameters,
|
|
23
|
+
...props,
|
|
24
|
+
loader: loader ?? defaultLoader
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
);
|
|
29
|
+
MockedNextImage.displayName = "NextImage";
|
|
30
|
+
var getImageProps = /* @__PURE__ */ __name((props) => originalGetImageProps?.({ loader: defaultLoader, ...props }), "getImageProps");
|
|
31
|
+
var next_image_default = MockedNextImage;
|
|
32
|
+
export {
|
|
33
|
+
next_image_default as default,
|
|
34
|
+
getImageProps
|
|
35
|
+
};
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
import {
|
|
2
|
+
defaultLoader
|
|
3
|
+
} from "../_browser-chunks/chunk-I5RFHXDS.js";
|
|
4
|
+
import {
|
|
5
|
+
__name
|
|
6
|
+
} from "../_browser-chunks/chunk-L5NVL7MD.js";
|
|
7
|
+
|
|
8
|
+
// src/images/next-legacy-image.tsx
|
|
9
|
+
import React from "react";
|
|
10
|
+
import { ImageContext as ImageContextValue } from "@storybook/nextjs/image-context";
|
|
11
|
+
import OriginalNextLegacyImage from "sb-original/next/legacy/image";
|
|
12
|
+
var ImageContext = ImageContextValue;
|
|
13
|
+
function NextLegacyImage({ loader, ...props }) {
|
|
14
|
+
const imageParameters = React.useContext(ImageContext);
|
|
15
|
+
return React.createElement(OriginalNextLegacyImage, { ...imageParameters, ...props, loader: loader ?? defaultLoader });
|
|
16
|
+
}
|
|
17
|
+
__name(NextLegacyImage, "NextLegacyImage");
|
|
18
|
+
var next_legacy_image_default = NextLegacyImage;
|
|
19
|
+
export {
|
|
20
|
+
next_legacy_image_default as default
|
|
21
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,58 @@
|
|
|
1
1
|
import { PreviewAddon, InferTypes, AddonTypes } from 'storybook/internal/csf';
|
|
2
|
-
import { NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, Args, StoryAnnotationsOrFn, ProjectAnnotations, ComposedStoryFn, Store_CSFExports, StoriesWithPartialProps } from 'storybook/internal/types';
|
|
2
|
+
import { CompatibleString, NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, Args, StoryAnnotationsOrFn, ProjectAnnotations, ComposedStoryFn, Store_CSFExports, StoriesWithPartialProps } from 'storybook/internal/types';
|
|
3
3
|
import { ReactRenderer, Meta, ReactTypes, ReactPreview } from '@storybook/react';
|
|
4
4
|
export * from '@storybook/react';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import '
|
|
8
|
-
import '
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
import { BuilderOptions, StorybookConfigWebpack, TypescriptOptions } from '@storybook/builder-webpack5';
|
|
6
|
+
import { ReactOptions, StorybookConfig as StorybookConfig$1, TypescriptOptions as TypescriptOptions$1 } from '@storybook/preset-react-webpack';
|
|
7
|
+
import * as NextImage from 'next/image';
|
|
8
|
+
import { NextRouter } from 'next/router';
|
|
9
|
+
|
|
10
|
+
type FrameworkName = CompatibleString<'@storybook/nextjs'>;
|
|
11
|
+
type BuilderName = CompatibleString<'@storybook/builder-webpack5'>;
|
|
12
|
+
type FrameworkOptions = ReactOptions & {
|
|
13
|
+
nextConfigPath?: string;
|
|
14
|
+
image?: Partial<NextImage.ImageProps>;
|
|
15
|
+
builder?: BuilderOptions;
|
|
16
|
+
};
|
|
17
|
+
type StorybookConfigFramework = {
|
|
18
|
+
framework: FrameworkName | {
|
|
19
|
+
name: FrameworkName;
|
|
20
|
+
options: FrameworkOptions;
|
|
21
|
+
};
|
|
22
|
+
core?: StorybookConfig$1['core'] & {
|
|
23
|
+
builder?: BuilderName | {
|
|
24
|
+
name: BuilderName;
|
|
25
|
+
options: BuilderOptions;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
typescript?: Partial<TypescriptOptions & TypescriptOptions$1> & StorybookConfig$1['typescript'];
|
|
29
|
+
};
|
|
30
|
+
/** The interface for Storybook configuration in `main.ts` files. */
|
|
31
|
+
type StorybookConfig = Omit<StorybookConfig$1, keyof StorybookConfigWebpack | keyof StorybookConfigFramework> & StorybookConfigWebpack & StorybookConfigFramework;
|
|
32
|
+
interface NextJsParameters {
|
|
33
|
+
/**
|
|
34
|
+
* Next.js framework configuration
|
|
35
|
+
*
|
|
36
|
+
* @see https://storybook.js.org/docs/get-started/frameworks/nextjs
|
|
37
|
+
*/
|
|
38
|
+
nextjs?: {
|
|
39
|
+
/**
|
|
40
|
+
* Enable App Directory features If your story imports components that use next/navigation, you
|
|
41
|
+
* need to set this parameter to true
|
|
42
|
+
*/
|
|
43
|
+
appDirectory?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Next.js navigation configuration when using `next/navigation`. Please note that it can only
|
|
46
|
+
* be used in components/pages in the app directory.
|
|
47
|
+
*/
|
|
48
|
+
navigation?: Partial<NextRouter>;
|
|
49
|
+
/** Next.js router configuration */
|
|
50
|
+
router?: Partial<NextRouter>;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
interface NextJsTypes {
|
|
54
|
+
parameters: NextJsParameters;
|
|
55
|
+
}
|
|
11
56
|
|
|
12
57
|
/**
|
|
13
58
|
* Function that sets the globalConfig of your storybook. The global config is the preview module of
|
|
@@ -93,4 +138,4 @@ declare function definePreview<Addons extends PreviewAddon<never>[]>(preview: {
|
|
|
93
138
|
interface NextPreview<T extends AddonTypes> extends ReactPreview<NextJsTypes & T> {
|
|
94
139
|
}
|
|
95
140
|
|
|
96
|
-
export { NextJsTypes, composeStories, composeStory, definePreview, setProjectAnnotations };
|
|
141
|
+
export { type FrameworkOptions, type NextJsParameters, type NextJsTypes, type StorybookConfig, composeStories, composeStory, definePreview, setProjectAnnotations };
|