@storybook/react 9.2.0-alpha.3 → 10.0.0-beta.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/README.md +2 -0
- package/dist/_browser-chunks/chunk-BUAOEMNB.js +14 -0
- package/dist/_browser-chunks/chunk-HBQ5Y6GW.js +209 -0
- package/dist/_browser-chunks/chunk-I3XJ5JHI.js +43 -0
- package/dist/_browser-chunks/chunk-L5NVL7MD.js +37 -0
- package/dist/_browser-chunks/chunk-V6XFC4HM.js +18819 -0
- package/dist/_browser-chunks/chunk-VVH2AMAL.js +1075 -0
- package/dist/_browser-chunks/chunk-XNNKYNNU.js +2187 -0
- package/dist/entry-preview-argtypes.js +10 -45
- package/dist/entry-preview-docs.js +13 -17
- package/dist/entry-preview-rsc.js +11 -1
- package/dist/entry-preview.js +21 -1
- package/dist/index.d.ts +447 -10
- package/dist/index.js +79 -46
- package/dist/playwright.js +7 -1
- package/dist/preset.js +203 -1
- package/dist/preview.d.ts +3 -202
- package/dist/preview.d.tsx +420 -0
- package/dist/preview.js +12 -46
- package/package.json +20 -54
- package/preset.js +1 -1
- package/preview.js +1 -0
- package/dist/chunk-6BNVLEVL.mjs +0 -22
- package/dist/chunk-6PSAWJ36.mjs +0 -12
- package/dist/chunk-JQQVJC7C.mjs +0 -36
- package/dist/chunk-MNKU3DTE.mjs +0 -9
- package/dist/chunk-OZUYIFQK.mjs +0 -8
- package/dist/chunk-XLZBPYSH.mjs +0 -6
- package/dist/chunk-XP5HYGXS.mjs +0 -3
- package/dist/entry-preview-argtypes.d.ts +0 -16
- package/dist/entry-preview-argtypes.mjs +0 -3
- package/dist/entry-preview-docs.d.ts +0 -18
- package/dist/entry-preview-docs.mjs +0 -4
- package/dist/entry-preview-rsc.d.ts +0 -7
- package/dist/entry-preview-rsc.mjs +0 -5
- package/dist/entry-preview.d.ts +0 -21
- package/dist/entry-preview.mjs +0 -3
- package/dist/index.mjs +0 -14
- package/dist/playwright.mjs +0 -2
- package/dist/preset.d.ts +0 -19
- package/dist/preview.mjs +0 -7
- package/dist/public-types-d899d203.d.ts +0 -230
- package/dist/types-7abe74eb.d.ts +0 -28
package/dist/playwright.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import "./_browser-chunks/chunk-L5NVL7MD.js";
|
|
2
|
+
|
|
3
|
+
// src/playwright.ts
|
|
4
|
+
import { createPlaywrightTest } from "storybook/preview-api";
|
|
5
|
+
export {
|
|
6
|
+
createPlaywrightTest as createTest
|
|
7
|
+
};
|
package/dist/preset.js
CHANGED
|
@@ -1 +1,203 @@
|
|
|
1
|
-
|
|
1
|
+
import CJS_COMPAT_NODE_URL_hykl0zy5zul from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_hykl0zy5zul from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_hykl0zy5zul from "node:module";
|
|
4
|
+
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_hykl0zy5zul.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_hykl0zy5zul.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_hykl0zy5zul.createRequire(import.meta.url);
|
|
8
|
+
|
|
9
|
+
// ------------------------------------------------------------
|
|
10
|
+
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
+
// ------------------------------------------------------------
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
14
|
+
|
|
15
|
+
// src/preset.ts
|
|
16
|
+
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
17
|
+
|
|
18
|
+
// ../../core/src/shared/utils/module.ts
|
|
19
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
20
|
+
|
|
21
|
+
// ../../node_modules/pathe/dist/shared/pathe.ff20891b.mjs
|
|
22
|
+
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
23
|
+
function normalizeWindowsPath(input = "") {
|
|
24
|
+
if (!input) {
|
|
25
|
+
return input;
|
|
26
|
+
}
|
|
27
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
28
|
+
}
|
|
29
|
+
__name(normalizeWindowsPath, "normalizeWindowsPath");
|
|
30
|
+
var _UNC_REGEX = /^[/\\]{2}/;
|
|
31
|
+
var _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
32
|
+
var _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
33
|
+
var normalize = /* @__PURE__ */ __name(function(path2) {
|
|
34
|
+
if (path2.length === 0) {
|
|
35
|
+
return ".";
|
|
36
|
+
}
|
|
37
|
+
path2 = normalizeWindowsPath(path2);
|
|
38
|
+
const isUNCPath = path2.match(_UNC_REGEX);
|
|
39
|
+
const isPathAbsolute = isAbsolute(path2);
|
|
40
|
+
const trailingSeparator = path2[path2.length - 1] === "/";
|
|
41
|
+
path2 = normalizeString(path2, !isPathAbsolute);
|
|
42
|
+
if (path2.length === 0) {
|
|
43
|
+
if (isPathAbsolute) {
|
|
44
|
+
return "/";
|
|
45
|
+
}
|
|
46
|
+
return trailingSeparator ? "./" : ".";
|
|
47
|
+
}
|
|
48
|
+
if (trailingSeparator) {
|
|
49
|
+
path2 += "/";
|
|
50
|
+
}
|
|
51
|
+
if (_DRIVE_LETTER_RE.test(path2)) {
|
|
52
|
+
path2 += "/";
|
|
53
|
+
}
|
|
54
|
+
if (isUNCPath) {
|
|
55
|
+
if (!isPathAbsolute) {
|
|
56
|
+
return `//./${path2}`;
|
|
57
|
+
}
|
|
58
|
+
return `//${path2}`;
|
|
59
|
+
}
|
|
60
|
+
return isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2;
|
|
61
|
+
}, "normalize");
|
|
62
|
+
var join = /* @__PURE__ */ __name(function(...arguments_) {
|
|
63
|
+
if (arguments_.length === 0) {
|
|
64
|
+
return ".";
|
|
65
|
+
}
|
|
66
|
+
let joined;
|
|
67
|
+
for (const argument of arguments_) {
|
|
68
|
+
if (argument && argument.length > 0) {
|
|
69
|
+
if (joined === void 0) {
|
|
70
|
+
joined = argument;
|
|
71
|
+
} else {
|
|
72
|
+
joined += `/${argument}`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (joined === void 0) {
|
|
77
|
+
return ".";
|
|
78
|
+
}
|
|
79
|
+
return normalize(joined.replace(/\/\/+/g, "/"));
|
|
80
|
+
}, "join");
|
|
81
|
+
function normalizeString(path2, allowAboveRoot) {
|
|
82
|
+
let res = "";
|
|
83
|
+
let lastSegmentLength = 0;
|
|
84
|
+
let lastSlash = -1;
|
|
85
|
+
let dots = 0;
|
|
86
|
+
let char = null;
|
|
87
|
+
for (let index = 0; index <= path2.length; ++index) {
|
|
88
|
+
if (index < path2.length) {
|
|
89
|
+
char = path2[index];
|
|
90
|
+
} else if (char === "/") {
|
|
91
|
+
break;
|
|
92
|
+
} else {
|
|
93
|
+
char = "/";
|
|
94
|
+
}
|
|
95
|
+
if (char === "/") {
|
|
96
|
+
if (lastSlash === index - 1 || dots === 1) ;
|
|
97
|
+
else if (dots === 2) {
|
|
98
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
99
|
+
if (res.length > 2) {
|
|
100
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
101
|
+
if (lastSlashIndex === -1) {
|
|
102
|
+
res = "";
|
|
103
|
+
lastSegmentLength = 0;
|
|
104
|
+
} else {
|
|
105
|
+
res = res.slice(0, lastSlashIndex);
|
|
106
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
107
|
+
}
|
|
108
|
+
lastSlash = index;
|
|
109
|
+
dots = 0;
|
|
110
|
+
continue;
|
|
111
|
+
} else if (res.length > 0) {
|
|
112
|
+
res = "";
|
|
113
|
+
lastSegmentLength = 0;
|
|
114
|
+
lastSlash = index;
|
|
115
|
+
dots = 0;
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (allowAboveRoot) {
|
|
120
|
+
res += res.length > 0 ? "/.." : "..";
|
|
121
|
+
lastSegmentLength = 2;
|
|
122
|
+
}
|
|
123
|
+
} else {
|
|
124
|
+
if (res.length > 0) {
|
|
125
|
+
res += `/${path2.slice(lastSlash + 1, index)}`;
|
|
126
|
+
} else {
|
|
127
|
+
res = path2.slice(lastSlash + 1, index);
|
|
128
|
+
}
|
|
129
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
130
|
+
}
|
|
131
|
+
lastSlash = index;
|
|
132
|
+
dots = 0;
|
|
133
|
+
} else if (char === "." && dots !== -1) {
|
|
134
|
+
++dots;
|
|
135
|
+
} else {
|
|
136
|
+
dots = -1;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return res;
|
|
140
|
+
}
|
|
141
|
+
__name(normalizeString, "normalizeString");
|
|
142
|
+
var isAbsolute = /* @__PURE__ */ __name(function(p) {
|
|
143
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
144
|
+
}, "isAbsolute");
|
|
145
|
+
var dirname = /* @__PURE__ */ __name(function(p) {
|
|
146
|
+
const segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
|
|
147
|
+
if (segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0])) {
|
|
148
|
+
segments[0] += "/";
|
|
149
|
+
}
|
|
150
|
+
return segments.join("/") || (isAbsolute(p) ? "/" : ".");
|
|
151
|
+
}, "dirname");
|
|
152
|
+
|
|
153
|
+
// ../../core/src/shared/utils/module.ts
|
|
154
|
+
var importMetaResolve = /* @__PURE__ */ __name((...args) => {
|
|
155
|
+
if (typeof import.meta.resolve !== "function" && process.env.VITEST === "true") {
|
|
156
|
+
console.warn(
|
|
157
|
+
"importMetaResolve from within Storybook is being used in a Vitest test, but it shouldn't be. Please report this at https://github.com/storybookjs/storybook/issues/new?template=bug_report.yml"
|
|
158
|
+
);
|
|
159
|
+
return pathToFileURL(args[0]).href;
|
|
160
|
+
}
|
|
161
|
+
return import.meta.resolve(...args);
|
|
162
|
+
}, "importMetaResolve");
|
|
163
|
+
var resolvePackageDir = /* @__PURE__ */ __name((pkg, parent) => {
|
|
164
|
+
return dirname(fileURLToPath(importMetaResolve(join(pkg, "package.json"), parent)));
|
|
165
|
+
}, "resolvePackageDir");
|
|
166
|
+
|
|
167
|
+
// src/preset.ts
|
|
168
|
+
var addons = [
|
|
169
|
+
import.meta.resolve("@storybook/react-dom-shim/preset")
|
|
170
|
+
];
|
|
171
|
+
var previewAnnotations = /* @__PURE__ */ __name(async (input = [], options) => {
|
|
172
|
+
const [docsConfig, features] = await Promise.all([
|
|
173
|
+
options.presets.apply("docs", {}, options),
|
|
174
|
+
options.presets.apply("features", {}, options)
|
|
175
|
+
]);
|
|
176
|
+
const docsEnabled = Object.keys(docsConfig).length > 0;
|
|
177
|
+
const experimentalRSC = features?.experimentalRSC;
|
|
178
|
+
const result = [];
|
|
179
|
+
return result.concat(input).concat([
|
|
180
|
+
fileURLToPath2(import.meta.resolve("@storybook/react/entry-preview")),
|
|
181
|
+
fileURLToPath2(import.meta.resolve("@storybook/react/entry-preview-argtypes"))
|
|
182
|
+
]).concat(
|
|
183
|
+
docsEnabled ? [fileURLToPath2(import.meta.resolve("@storybook/react/entry-preview-docs"))] : []
|
|
184
|
+
).concat(
|
|
185
|
+
experimentalRSC ? [fileURLToPath2(import.meta.resolve("@storybook/react/entry-preview-rsc"))] : []
|
|
186
|
+
);
|
|
187
|
+
}, "previewAnnotations");
|
|
188
|
+
var resolvedReact = /* @__PURE__ */ __name(async (existing) => {
|
|
189
|
+
try {
|
|
190
|
+
return {
|
|
191
|
+
...existing,
|
|
192
|
+
react: resolvePackageDir("react"),
|
|
193
|
+
reactDom: resolvePackageDir("react-dom")
|
|
194
|
+
};
|
|
195
|
+
} catch (e) {
|
|
196
|
+
return existing;
|
|
197
|
+
}
|
|
198
|
+
}, "resolvedReact");
|
|
199
|
+
export {
|
|
200
|
+
addons,
|
|
201
|
+
previewAnnotations,
|
|
202
|
+
resolvedReact
|
|
203
|
+
};
|
package/dist/preview.d.ts
CHANGED
|
@@ -1,202 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import { c as Simplify, A as AddMocks, d as SetOptional } from './public-types-d899d203.js';
|
|
5
|
-
import { a as ReactTypes } from './types-7abe74eb.js';
|
|
6
|
-
import 'react-dom/client';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
Remove any index signatures from the given object type, so that only explicitly defined properties remain.
|
|
10
|
-
|
|
11
|
-
Use-cases:
|
|
12
|
-
- Remove overly permissive signatures from third-party types.
|
|
13
|
-
|
|
14
|
-
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
15
|
-
|
|
16
|
-
It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
|
|
17
|
-
|
|
18
|
-
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
19
|
-
|
|
20
|
-
```
|
|
21
|
-
const indexed: Record<string, unknown> = {}; // Allowed
|
|
22
|
-
|
|
23
|
-
const keyed: Record<'foo', unknown> = {}; // Error
|
|
24
|
-
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
|
|
28
|
-
|
|
29
|
-
```
|
|
30
|
-
type Indexed = {} extends Record<string, unknown>
|
|
31
|
-
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
32
|
-
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
33
|
-
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
34
|
-
|
|
35
|
-
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
36
|
-
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
37
|
-
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
38
|
-
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
import type {RemoveIndexSignature} from 'type-fest';
|
|
45
|
-
|
|
46
|
-
type RemoveIndexSignature<ObjectType> = {
|
|
47
|
-
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
48
|
-
]: ObjectType[KeyType]; // ...to its original value, i.e. `RemoveIndexSignature<Foo> == Foo`.
|
|
49
|
-
};
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
53
|
-
|
|
54
|
-
```
|
|
55
|
-
import type {RemoveIndexSignature} from 'type-fest';
|
|
56
|
-
|
|
57
|
-
type RemoveIndexSignature<ObjectType> = {
|
|
58
|
-
[KeyType in keyof ObjectType
|
|
59
|
-
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
60
|
-
as {} extends Record<KeyType, unknown>
|
|
61
|
-
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
62
|
-
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
63
|
-
]: ObjectType[KeyType];
|
|
64
|
-
};
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
|
|
68
|
-
|
|
69
|
-
```
|
|
70
|
-
import type {RemoveIndexSignature} from 'type-fest';
|
|
71
|
-
|
|
72
|
-
type RemoveIndexSignature<ObjectType> = {
|
|
73
|
-
[KeyType in keyof ObjectType
|
|
74
|
-
as {} extends Record<KeyType, unknown>
|
|
75
|
-
? never // => Remove this `KeyType`.
|
|
76
|
-
: KeyType // => Keep this `KeyType` as it is.
|
|
77
|
-
]: ObjectType[KeyType];
|
|
78
|
-
};
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
@example
|
|
82
|
-
```
|
|
83
|
-
import type {RemoveIndexSignature} from 'type-fest';
|
|
84
|
-
|
|
85
|
-
interface Example {
|
|
86
|
-
// These index signatures will be removed.
|
|
87
|
-
[x: string]: any
|
|
88
|
-
[x: number]: any
|
|
89
|
-
[x: symbol]: any
|
|
90
|
-
[x: `head-${string}`]: string
|
|
91
|
-
[x: `${string}-tail`]: string
|
|
92
|
-
[x: `head-${string}-tail`]: string
|
|
93
|
-
[x: `${bigint}`]: string
|
|
94
|
-
[x: `embedded-${number}`]: string
|
|
95
|
-
|
|
96
|
-
// These explicitly defined keys will remain.
|
|
97
|
-
foo: 'bar';
|
|
98
|
-
qux?: 'baz';
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
type ExampleWithoutIndexSignatures = RemoveIndexSignature<Example>;
|
|
102
|
-
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
@category Object
|
|
106
|
-
*/
|
|
107
|
-
type RemoveIndexSignature<ObjectType> = {
|
|
108
|
-
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
|
109
|
-
? never
|
|
110
|
-
: KeyType]: ObjectType[KeyType];
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
Convert a union type to an intersection type using [distributive conditional types](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
115
|
-
|
|
116
|
-
Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
|
|
117
|
-
|
|
118
|
-
@example
|
|
119
|
-
```
|
|
120
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
121
|
-
|
|
122
|
-
type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
|
|
123
|
-
|
|
124
|
-
type Intersection = UnionToIntersection<Union>;
|
|
125
|
-
//=> {the(): void; great(arg: string): void; escape: boolean};
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
A more applicable example which could make its way into your library code follows.
|
|
129
|
-
|
|
130
|
-
@example
|
|
131
|
-
```
|
|
132
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
133
|
-
|
|
134
|
-
class CommandOne {
|
|
135
|
-
commands: {
|
|
136
|
-
a1: () => undefined,
|
|
137
|
-
b1: () => undefined,
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
class CommandTwo {
|
|
142
|
-
commands: {
|
|
143
|
-
a2: (argA: string) => undefined,
|
|
144
|
-
b2: (argB: string) => undefined,
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
|
|
149
|
-
type Union = typeof union;
|
|
150
|
-
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
|
|
151
|
-
|
|
152
|
-
type Intersection = UnionToIntersection<Union>;
|
|
153
|
-
//=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
@category Type
|
|
157
|
-
*/
|
|
158
|
-
type UnionToIntersection<Union> = (
|
|
159
|
-
// `extends unknown` is always going to be the case and is used to convert the
|
|
160
|
-
// `Union` into a [distributive conditional
|
|
161
|
-
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
162
|
-
Union extends unknown
|
|
163
|
-
// The union type is used as the only argument to a function since the union
|
|
164
|
-
// of function arguments is an intersection.
|
|
165
|
-
? (distributedUnion: Union) => void
|
|
166
|
-
// This won't happen.
|
|
167
|
-
: never
|
|
168
|
-
// Infer the `Intersection` type since TypeScript represents the positional
|
|
169
|
-
// arguments of unions of functions as an intersection of the union.
|
|
170
|
-
) extends ((mergedIntersection: infer Intersection) => void)
|
|
171
|
-
? Intersection
|
|
172
|
-
: never;
|
|
173
|
-
|
|
174
|
-
declare function __definePreview<Addons extends PreviewAddon<never>[]>(input: {
|
|
175
|
-
addons: Addons;
|
|
176
|
-
} & ProjectAnnotations<ReactTypes & InferTypes<Addons>>): ReactPreview<ReactTypes & InferTypes<Addons>>;
|
|
177
|
-
interface ReactPreview<T extends AddonTypes> extends Preview<ReactTypes & T> {
|
|
178
|
-
meta<TArgs extends Args, Decorators extends DecoratorFunction<ReactTypes & T, any>, TMetaArgs extends Partial<TArgs>>(meta: {
|
|
179
|
-
render?: ArgsStoryFn<ReactTypes & T, TArgs>;
|
|
180
|
-
component?: ComponentType<TArgs>;
|
|
181
|
-
decorators?: Decorators | Decorators[];
|
|
182
|
-
args?: TMetaArgs;
|
|
183
|
-
} & Omit<ComponentAnnotations<ReactTypes & T, TArgs>, 'decorators' | 'component' | 'args' | 'render'>): ReactMeta<ReactTypes & T & {
|
|
184
|
-
args: Simplify<TArgs & Simplify<RemoveIndexSignature<DecoratorsArgs<ReactTypes & T, Decorators>>>>;
|
|
185
|
-
}, {
|
|
186
|
-
args: Partial<TArgs> extends TMetaArgs ? {} : TMetaArgs;
|
|
187
|
-
}>;
|
|
188
|
-
}
|
|
189
|
-
type DecoratorsArgs<TRenderer extends Renderer, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
|
|
190
|
-
interface ReactMeta<T extends ReactTypes, MetaInput extends ComponentAnnotations<T>> extends Meta<T, MetaInput> {
|
|
191
|
-
story<TInput extends (() => ReactTypes['storyResult']) | (StoryAnnotations<T, T['args']> & {
|
|
192
|
-
render: () => ReactTypes['storyResult'];
|
|
193
|
-
})>(story?: TInput): ReactStory<T, TInput extends () => ReactTypes['storyResult'] ? {
|
|
194
|
-
render: TInput;
|
|
195
|
-
} : TInput>;
|
|
196
|
-
story<TInput extends Simplify<StoryAnnotations<T, AddMocks<T['args'], MetaInput['args']>, SetOptional<T['args'], keyof T['args'] & keyof MetaInput['args']>>>>(story?: TInput): ReactStory<T, TInput>;
|
|
197
|
-
}
|
|
198
|
-
interface ReactStory<T extends ReactTypes, TInput extends StoryAnnotations<T, T['args']>> extends Story<T, TInput> {
|
|
199
|
-
Component: ComponentType<Partial<T['args']>>;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export { ReactPreview, ReactStory, __definePreview };
|
|
1
|
+
// auto generated file from file:///home/runner/work/storybook/storybook/scripts/build/utils/generate-type-mappers.ts, do not edit
|
|
2
|
+
export * from '../src/preview.tsx';
|
|
3
|
+
export type * from '../src/preview.tsx';
|