@storybook/react 10.0.0-beta.6 → 10.0.0-beta.8
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/dist/_browser-chunks/{chunk-EH3IDVCQ.js → chunk-352EX3YB.js} +1 -1
- package/dist/_browser-chunks/{chunk-XNNKYNNU.js → chunk-4WKCOEYI.js} +9 -0
- package/dist/entry-preview.js +1 -1
- package/dist/index.js +2 -2
- package/dist/preset.js +314 -6
- package/dist/preview.d.ts +425 -3
- package/dist/preview.js +2 -2
- package/package.json +3 -3
- package/dist/preview.d.tsx +0 -425
|
@@ -1937,6 +1937,7 @@ __export(entry_preview_exports, {
|
|
|
1937
1937
|
});
|
|
1938
1938
|
var import_semver = __toESM(require_semver2(), 1);
|
|
1939
1939
|
import * as React4 from "react";
|
|
1940
|
+
import { global as global2 } from "@storybook/global";
|
|
1940
1941
|
import { configure } from "storybook/test";
|
|
1941
1942
|
|
|
1942
1943
|
// src/act-compat.ts
|
|
@@ -2120,6 +2121,14 @@ var decorators = [
|
|
|
2120
2121
|
throw new Error("React Server Components require React >= 18.3");
|
|
2121
2122
|
}
|
|
2122
2123
|
return React4.createElement(React4.Suspense, null, story());
|
|
2124
|
+
},
|
|
2125
|
+
(story, context) => {
|
|
2126
|
+
if (context.tags?.includes("test-fn") && !global2.FEATURES?.experimentalTestSyntax) {
|
|
2127
|
+
throw new Error(
|
|
2128
|
+
"To use the experimental test function, you must enable the experimentalTestSyntax feature flag. See https://storybook.js.org/docs/10/api/main-config/main-config-features#experimentalTestSyntax"
|
|
2129
|
+
);
|
|
2130
|
+
}
|
|
2131
|
+
return story();
|
|
2123
2132
|
}
|
|
2124
2133
|
];
|
|
2125
2134
|
var parameters = {
|
package/dist/entry-preview.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__definePreview
|
|
3
|
-
} from "./_browser-chunks/chunk-
|
|
3
|
+
} from "./_browser-chunks/chunk-352EX3YB.js";
|
|
4
4
|
import {
|
|
5
5
|
entry_preview_exports,
|
|
6
6
|
renderToCanvas
|
|
7
|
-
} from "./_browser-chunks/chunk-
|
|
7
|
+
} from "./_browser-chunks/chunk-4WKCOEYI.js";
|
|
8
8
|
import {
|
|
9
9
|
entry_preview_argtypes_exports
|
|
10
10
|
} from "./_browser-chunks/chunk-2SCDRHCG.js";
|
package/dist/preset.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_q1lvh4oqay from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_q1lvh4oqay from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_q1lvh4oqay from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_q1lvh4oqay.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_q1lvh4oqay.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_q1lvh4oqay.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -18,6 +18,314 @@ import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
|
18
18
|
// ../../core/src/shared/utils/module.ts
|
|
19
19
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
20
20
|
|
|
21
|
+
// ../../node_modules/exsolve/dist/index.mjs
|
|
22
|
+
import assert from "node:assert";
|
|
23
|
+
import v8 from "node:v8";
|
|
24
|
+
import { format, inspect } from "node:util";
|
|
25
|
+
var own$1 = {}.hasOwnProperty;
|
|
26
|
+
var classRegExp = /^([A-Z][a-z\d]*)+$/;
|
|
27
|
+
var kTypes = /* @__PURE__ */ new Set([
|
|
28
|
+
"string",
|
|
29
|
+
"function",
|
|
30
|
+
"number",
|
|
31
|
+
"object",
|
|
32
|
+
// Accept 'Function' and 'Object' as alternative to the lower cased version.
|
|
33
|
+
"Function",
|
|
34
|
+
"Object",
|
|
35
|
+
"boolean",
|
|
36
|
+
"bigint",
|
|
37
|
+
"symbol"
|
|
38
|
+
]);
|
|
39
|
+
var messages = /* @__PURE__ */ new Map();
|
|
40
|
+
var nodeInternalPrefix = "__node_internal_";
|
|
41
|
+
var userStackTraceLimit;
|
|
42
|
+
function formatList(array, type = "and") {
|
|
43
|
+
return array.length < 3 ? array.join(` ${type} `) : `${array.slice(0, -1).join(", ")}, ${type} ${array.at(-1)}`;
|
|
44
|
+
}
|
|
45
|
+
__name(formatList, "formatList");
|
|
46
|
+
function createError(sym, value, constructor) {
|
|
47
|
+
messages.set(sym, value);
|
|
48
|
+
return makeNodeErrorWithCode(constructor, sym);
|
|
49
|
+
}
|
|
50
|
+
__name(createError, "createError");
|
|
51
|
+
function makeNodeErrorWithCode(Base, key) {
|
|
52
|
+
return /* @__PURE__ */ __name(function NodeError(...parameters) {
|
|
53
|
+
const limit = Error.stackTraceLimit;
|
|
54
|
+
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0;
|
|
55
|
+
const error = new Base();
|
|
56
|
+
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit;
|
|
57
|
+
const message = getMessage(key, parameters, error);
|
|
58
|
+
Object.defineProperties(error, {
|
|
59
|
+
// Note: no need to implement `kIsNodeError` symbol, would be hard,
|
|
60
|
+
// probably.
|
|
61
|
+
message: {
|
|
62
|
+
value: message,
|
|
63
|
+
enumerable: false,
|
|
64
|
+
writable: true,
|
|
65
|
+
configurable: true
|
|
66
|
+
},
|
|
67
|
+
toString: {
|
|
68
|
+
/** @this {Error} */
|
|
69
|
+
value() {
|
|
70
|
+
return `${this.name} [${key}]: ${this.message}`;
|
|
71
|
+
},
|
|
72
|
+
enumerable: false,
|
|
73
|
+
writable: true,
|
|
74
|
+
configurable: true
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
captureLargerStackTrace(error);
|
|
78
|
+
error.code = key;
|
|
79
|
+
return error;
|
|
80
|
+
}, "NodeError");
|
|
81
|
+
}
|
|
82
|
+
__name(makeNodeErrorWithCode, "makeNodeErrorWithCode");
|
|
83
|
+
function isErrorStackTraceLimitWritable() {
|
|
84
|
+
try {
|
|
85
|
+
if (v8.startupSnapshot.isBuildingSnapshot()) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
} catch {
|
|
89
|
+
}
|
|
90
|
+
const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
91
|
+
if (desc === void 0) {
|
|
92
|
+
return Object.isExtensible(Error);
|
|
93
|
+
}
|
|
94
|
+
return own$1.call(desc, "writable") && desc.writable !== void 0 ? desc.writable : desc.set !== void 0;
|
|
95
|
+
}
|
|
96
|
+
__name(isErrorStackTraceLimitWritable, "isErrorStackTraceLimitWritable");
|
|
97
|
+
function hideStackFrames(wrappedFunction) {
|
|
98
|
+
const hidden = nodeInternalPrefix + wrappedFunction.name;
|
|
99
|
+
Object.defineProperty(wrappedFunction, "name", { value: hidden });
|
|
100
|
+
return wrappedFunction;
|
|
101
|
+
}
|
|
102
|
+
__name(hideStackFrames, "hideStackFrames");
|
|
103
|
+
var captureLargerStackTrace = hideStackFrames(function(error) {
|
|
104
|
+
const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable();
|
|
105
|
+
if (stackTraceLimitIsWritable) {
|
|
106
|
+
userStackTraceLimit = Error.stackTraceLimit;
|
|
107
|
+
Error.stackTraceLimit = Number.POSITIVE_INFINITY;
|
|
108
|
+
}
|
|
109
|
+
Error.captureStackTrace(error);
|
|
110
|
+
if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit;
|
|
111
|
+
return error;
|
|
112
|
+
});
|
|
113
|
+
function getMessage(key, parameters, self) {
|
|
114
|
+
const message = messages.get(key);
|
|
115
|
+
assert(message !== void 0, "expected `message` to be found");
|
|
116
|
+
if (typeof message === "function") {
|
|
117
|
+
assert(
|
|
118
|
+
message.length <= parameters.length,
|
|
119
|
+
// Default options do not count.
|
|
120
|
+
`Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${message.length}).`
|
|
121
|
+
);
|
|
122
|
+
return Reflect.apply(message, self, parameters);
|
|
123
|
+
}
|
|
124
|
+
const regex = /%[dfijoOs]/g;
|
|
125
|
+
let expectedLength = 0;
|
|
126
|
+
while (regex.exec(message) !== null) expectedLength++;
|
|
127
|
+
assert(
|
|
128
|
+
expectedLength === parameters.length,
|
|
129
|
+
`Code: ${key}; The provided arguments length (${parameters.length}) does not match the required ones (${expectedLength}).`
|
|
130
|
+
);
|
|
131
|
+
if (parameters.length === 0) return message;
|
|
132
|
+
parameters.unshift(message);
|
|
133
|
+
return Reflect.apply(format, null, parameters);
|
|
134
|
+
}
|
|
135
|
+
__name(getMessage, "getMessage");
|
|
136
|
+
function determineSpecificType(value) {
|
|
137
|
+
if (value === null || value === void 0) {
|
|
138
|
+
return String(value);
|
|
139
|
+
}
|
|
140
|
+
if (typeof value === "function" && value.name) {
|
|
141
|
+
return `function ${value.name}`;
|
|
142
|
+
}
|
|
143
|
+
if (typeof value === "object") {
|
|
144
|
+
if (value.constructor && value.constructor.name) {
|
|
145
|
+
return `an instance of ${value.constructor.name}`;
|
|
146
|
+
}
|
|
147
|
+
return `${inspect(value, { depth: -1 })}`;
|
|
148
|
+
}
|
|
149
|
+
let inspected = inspect(value, { colors: false });
|
|
150
|
+
if (inspected.length > 28) {
|
|
151
|
+
inspected = `${inspected.slice(0, 25)}...`;
|
|
152
|
+
}
|
|
153
|
+
return `type ${typeof value} (${inspected})`;
|
|
154
|
+
}
|
|
155
|
+
__name(determineSpecificType, "determineSpecificType");
|
|
156
|
+
createError(
|
|
157
|
+
"ERR_INVALID_ARG_TYPE",
|
|
158
|
+
(name, expected, actual) => {
|
|
159
|
+
assert(typeof name === "string", "'name' must be a string");
|
|
160
|
+
if (!Array.isArray(expected)) {
|
|
161
|
+
expected = [expected];
|
|
162
|
+
}
|
|
163
|
+
let message = "The ";
|
|
164
|
+
if (name.endsWith(" argument")) {
|
|
165
|
+
message += `${name} `;
|
|
166
|
+
} else {
|
|
167
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
168
|
+
message += `"${name}" ${type} `;
|
|
169
|
+
}
|
|
170
|
+
message += "must be ";
|
|
171
|
+
const types = [];
|
|
172
|
+
const instances = [];
|
|
173
|
+
const other = [];
|
|
174
|
+
for (const value of expected) {
|
|
175
|
+
assert(
|
|
176
|
+
typeof value === "string",
|
|
177
|
+
"All expected entries have to be of type string"
|
|
178
|
+
);
|
|
179
|
+
if (kTypes.has(value)) {
|
|
180
|
+
types.push(value.toLowerCase());
|
|
181
|
+
} else if (classRegExp.exec(value) === null) {
|
|
182
|
+
assert(
|
|
183
|
+
value !== "object",
|
|
184
|
+
'The value "object" should be written as "Object"'
|
|
185
|
+
);
|
|
186
|
+
other.push(value);
|
|
187
|
+
} else {
|
|
188
|
+
instances.push(value);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (instances.length > 0) {
|
|
192
|
+
const pos = types.indexOf("object");
|
|
193
|
+
if (pos !== -1) {
|
|
194
|
+
types.slice(pos, 1);
|
|
195
|
+
instances.push("Object");
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
if (types.length > 0) {
|
|
199
|
+
message += `${types.length > 1 ? "one of type" : "of type"} ${formatList(
|
|
200
|
+
types,
|
|
201
|
+
"or"
|
|
202
|
+
)}`;
|
|
203
|
+
if (instances.length > 0 || other.length > 0) message += " or ";
|
|
204
|
+
}
|
|
205
|
+
if (instances.length > 0) {
|
|
206
|
+
message += `an instance of ${formatList(instances, "or")}`;
|
|
207
|
+
if (other.length > 0) message += " or ";
|
|
208
|
+
}
|
|
209
|
+
if (other.length > 0) {
|
|
210
|
+
if (other.length > 1) {
|
|
211
|
+
message += `one of ${formatList(other, "or")}`;
|
|
212
|
+
} else {
|
|
213
|
+
if (other[0]?.toLowerCase() !== other[0]) message += "an ";
|
|
214
|
+
message += `${other[0]}`;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
message += `. Received ${determineSpecificType(actual)}`;
|
|
218
|
+
return message;
|
|
219
|
+
},
|
|
220
|
+
TypeError
|
|
221
|
+
);
|
|
222
|
+
var ERR_INVALID_MODULE_SPECIFIER = createError(
|
|
223
|
+
"ERR_INVALID_MODULE_SPECIFIER",
|
|
224
|
+
/**
|
|
225
|
+
* @param {string} request
|
|
226
|
+
* @param {string} reason
|
|
227
|
+
* @param {string} [base]
|
|
228
|
+
*/
|
|
229
|
+
(request, reason, base) => {
|
|
230
|
+
return `Invalid module "${request}" ${reason}${base ? ` imported from ${base}` : ""}`;
|
|
231
|
+
},
|
|
232
|
+
TypeError
|
|
233
|
+
);
|
|
234
|
+
var ERR_INVALID_PACKAGE_CONFIG = createError(
|
|
235
|
+
"ERR_INVALID_PACKAGE_CONFIG",
|
|
236
|
+
(path2, base, message) => {
|
|
237
|
+
return `Invalid package config ${path2}${base ? ` while importing ${base}` : ""}${message ? `. ${message}` : ""}`;
|
|
238
|
+
},
|
|
239
|
+
Error
|
|
240
|
+
);
|
|
241
|
+
var ERR_INVALID_PACKAGE_TARGET = createError(
|
|
242
|
+
"ERR_INVALID_PACKAGE_TARGET",
|
|
243
|
+
(packagePath, key, target, isImport = false, base) => {
|
|
244
|
+
const relatedError = typeof target === "string" && !isImport && target.length > 0 && !target.startsWith("./");
|
|
245
|
+
if (key === ".") {
|
|
246
|
+
assert(isImport === false);
|
|
247
|
+
return `Invalid "exports" main target ${JSON.stringify(target)} defined in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
248
|
+
}
|
|
249
|
+
return `Invalid "${isImport ? "imports" : "exports"}" target ${JSON.stringify(
|
|
250
|
+
target
|
|
251
|
+
)} defined for '${key}' in the package config ${packagePath}package.json${base ? ` imported from ${base}` : ""}${relatedError ? '; targets must start with "./"' : ""}`;
|
|
252
|
+
},
|
|
253
|
+
Error
|
|
254
|
+
);
|
|
255
|
+
var ERR_MODULE_NOT_FOUND = createError(
|
|
256
|
+
"ERR_MODULE_NOT_FOUND",
|
|
257
|
+
(path2, base, exactUrl = false) => {
|
|
258
|
+
return `Cannot find ${exactUrl ? "module" : "package"} '${path2}' imported from ${base}`;
|
|
259
|
+
},
|
|
260
|
+
Error
|
|
261
|
+
);
|
|
262
|
+
createError(
|
|
263
|
+
"ERR_NETWORK_IMPORT_DISALLOWED",
|
|
264
|
+
"import of '%s' by %s is not supported: %s",
|
|
265
|
+
Error
|
|
266
|
+
);
|
|
267
|
+
var ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
|
|
268
|
+
"ERR_PACKAGE_IMPORT_NOT_DEFINED",
|
|
269
|
+
(specifier, packagePath, base) => {
|
|
270
|
+
return `Package import specifier "${specifier}" is not defined${packagePath ? ` in package ${packagePath || ""}package.json` : ""} imported from ${base}`;
|
|
271
|
+
},
|
|
272
|
+
TypeError
|
|
273
|
+
);
|
|
274
|
+
var ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
|
|
275
|
+
"ERR_PACKAGE_PATH_NOT_EXPORTED",
|
|
276
|
+
/**
|
|
277
|
+
* @param {string} packagePath
|
|
278
|
+
* @param {string} subpath
|
|
279
|
+
* @param {string} [base]
|
|
280
|
+
*/
|
|
281
|
+
(packagePath, subpath, base) => {
|
|
282
|
+
if (subpath === ".")
|
|
283
|
+
return `No "exports" main defined in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
284
|
+
return `Package subpath '${subpath}' is not defined by "exports" in ${packagePath}package.json${base ? ` imported from ${base}` : ""}`;
|
|
285
|
+
},
|
|
286
|
+
Error
|
|
287
|
+
);
|
|
288
|
+
var ERR_UNSUPPORTED_DIR_IMPORT = createError(
|
|
289
|
+
"ERR_UNSUPPORTED_DIR_IMPORT",
|
|
290
|
+
"Directory import '%s' is not supported resolving ES modules imported from %s",
|
|
291
|
+
Error
|
|
292
|
+
);
|
|
293
|
+
var ERR_UNSUPPORTED_RESOLVE_REQUEST = createError(
|
|
294
|
+
"ERR_UNSUPPORTED_RESOLVE_REQUEST",
|
|
295
|
+
'Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.',
|
|
296
|
+
TypeError
|
|
297
|
+
);
|
|
298
|
+
var ERR_UNKNOWN_FILE_EXTENSION = createError(
|
|
299
|
+
"ERR_UNKNOWN_FILE_EXTENSION",
|
|
300
|
+
(extension, path2) => {
|
|
301
|
+
return `Unknown file extension "${extension}" for ${path2}`;
|
|
302
|
+
},
|
|
303
|
+
TypeError
|
|
304
|
+
);
|
|
305
|
+
createError(
|
|
306
|
+
"ERR_INVALID_ARG_VALUE",
|
|
307
|
+
(name, value, reason = "is invalid") => {
|
|
308
|
+
let inspected = inspect(value);
|
|
309
|
+
if (inspected.length > 128) {
|
|
310
|
+
inspected = `${inspected.slice(0, 128)}...`;
|
|
311
|
+
}
|
|
312
|
+
const type = name.includes(".") ? "property" : "argument";
|
|
313
|
+
return `The ${type} '${name}' ${reason}. Received ${inspected}`;
|
|
314
|
+
},
|
|
315
|
+
TypeError
|
|
316
|
+
// Note: extra classes have been shaken out.
|
|
317
|
+
// , RangeError
|
|
318
|
+
);
|
|
319
|
+
var hasOwnProperty$1 = {}.hasOwnProperty;
|
|
320
|
+
var hasOwnProperty = {}.hasOwnProperty;
|
|
321
|
+
var RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
|
|
322
|
+
var own = {}.hasOwnProperty;
|
|
323
|
+
var isWindows = (() => process.platform === "win32")();
|
|
324
|
+
var globalCache = (() => (
|
|
325
|
+
// eslint-disable-next-line unicorn/no-unreadable-iife
|
|
326
|
+
globalThis["__EXSOLVE_CACHE__"] ||= /* @__PURE__ */ new Map()
|
|
327
|
+
))();
|
|
328
|
+
|
|
21
329
|
// ../../node_modules/pathe/dist/shared/pathe.ff20891b.mjs
|
|
22
330
|
var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
23
331
|
function normalizeWindowsPath(input = "") {
|
package/dist/preview.d.ts
CHANGED
|
@@ -1,3 +1,425 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ComponentType, JSX } from 'react';
|
|
2
|
+
import { PreviewAddon, InferTypes, AddonTypes, Preview, Meta, Story } from 'storybook/internal/csf';
|
|
3
|
+
import { WebRenderer, Canvas, ProjectAnnotations, Args, DecoratorFunction, ArgsStoryFn, ComponentAnnotations, StoryAnnotations, Renderer } from 'storybook/internal/types';
|
|
4
|
+
import { RootOptions } from 'react-dom/client';
|
|
5
|
+
|
|
6
|
+
declare global {
|
|
7
|
+
interface SymbolConstructor {
|
|
8
|
+
readonly observable: symbol;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
Returns a boolean for whether the two given types are equal.
|
|
14
|
+
|
|
15
|
+
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
16
|
+
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
17
|
+
*/
|
|
18
|
+
type IsEqual<T, U> =
|
|
19
|
+
(<G>() => G extends T ? 1 : 2) extends
|
|
20
|
+
(<G>() => G extends U ? 1 : 2)
|
|
21
|
+
? true
|
|
22
|
+
: false;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
Filter out keys from an object.
|
|
26
|
+
|
|
27
|
+
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
28
|
+
Returns `never` if `Key` extends `Exclude`.
|
|
29
|
+
Returns `Key` otherwise.
|
|
30
|
+
|
|
31
|
+
@example
|
|
32
|
+
```
|
|
33
|
+
type Filtered = Filter<'foo', 'foo'>;
|
|
34
|
+
//=> never
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
@example
|
|
38
|
+
```
|
|
39
|
+
type Filtered = Filter<'bar', string>;
|
|
40
|
+
//=> never
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
@example
|
|
44
|
+
```
|
|
45
|
+
type Filtered = Filter<'bar', 'foo'>;
|
|
46
|
+
//=> 'bar'
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
@see {Except}
|
|
50
|
+
*/
|
|
51
|
+
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
Create a type from an object type without certain keys.
|
|
55
|
+
|
|
56
|
+
This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
|
|
57
|
+
|
|
58
|
+
This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
|
|
59
|
+
|
|
60
|
+
@example
|
|
61
|
+
```
|
|
62
|
+
import type {Except} from 'type-fest';
|
|
63
|
+
|
|
64
|
+
type Foo = {
|
|
65
|
+
a: number;
|
|
66
|
+
b: string;
|
|
67
|
+
c: boolean;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
type FooWithoutA = Except<Foo, 'a' | 'c'>;
|
|
71
|
+
//=> {b: string};
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
@category Object
|
|
75
|
+
*/
|
|
76
|
+
type Except<ObjectType, KeysType extends keyof ObjectType> = {
|
|
77
|
+
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
@see Simplify
|
|
82
|
+
*/
|
|
83
|
+
interface SimplifyOptions {
|
|
84
|
+
/**
|
|
85
|
+
Do the simplification recursively.
|
|
86
|
+
|
|
87
|
+
@default false
|
|
88
|
+
*/
|
|
89
|
+
deep?: boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Flatten a type without worrying about the result.
|
|
93
|
+
type Flatten<
|
|
94
|
+
AnyType,
|
|
95
|
+
Options extends SimplifyOptions = {},
|
|
96
|
+
> = Options['deep'] extends true
|
|
97
|
+
? {[KeyType in keyof AnyType]: Simplify<AnyType[KeyType], Options>}
|
|
98
|
+
: {[KeyType in keyof AnyType]: AnyType[KeyType]};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
102
|
+
|
|
103
|
+
@example
|
|
104
|
+
```
|
|
105
|
+
import type {Simplify} from 'type-fest';
|
|
106
|
+
|
|
107
|
+
type PositionProps = {
|
|
108
|
+
top: number;
|
|
109
|
+
left: number;
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
type SizeProps = {
|
|
113
|
+
width: number;
|
|
114
|
+
height: number;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
118
|
+
type Props = Simplify<PositionProps & SizeProps>;
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
122
|
+
|
|
123
|
+
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
124
|
+
|
|
125
|
+
@example
|
|
126
|
+
```
|
|
127
|
+
import type {Simplify} from 'type-fest';
|
|
128
|
+
|
|
129
|
+
interface SomeInterface {
|
|
130
|
+
foo: number;
|
|
131
|
+
bar?: string;
|
|
132
|
+
baz: number | undefined;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
type SomeType = {
|
|
136
|
+
foo: number;
|
|
137
|
+
bar?: string;
|
|
138
|
+
baz: number | undefined;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
142
|
+
const someType: SomeType = literal;
|
|
143
|
+
const someInterface: SomeInterface = literal;
|
|
144
|
+
|
|
145
|
+
function fn(object: Record<string, unknown>): void {}
|
|
146
|
+
|
|
147
|
+
fn(literal); // Good: literal object type is sealed
|
|
148
|
+
fn(someType); // Good: type is sealed
|
|
149
|
+
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
150
|
+
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
154
|
+
|
|
155
|
+
@category Object
|
|
156
|
+
*/
|
|
157
|
+
type Simplify<
|
|
158
|
+
AnyType,
|
|
159
|
+
Options extends SimplifyOptions = {},
|
|
160
|
+
> = Flatten<AnyType> extends AnyType
|
|
161
|
+
? Flatten<AnyType, Options>
|
|
162
|
+
: AnyType;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
Remove any index signatures from the given object type, so that only explicitly defined properties remain.
|
|
166
|
+
|
|
167
|
+
Use-cases:
|
|
168
|
+
- Remove overly permissive signatures from third-party types.
|
|
169
|
+
|
|
170
|
+
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
171
|
+
|
|
172
|
+
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>`.
|
|
173
|
+
|
|
174
|
+
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
const indexed: Record<string, unknown> = {}; // Allowed
|
|
178
|
+
|
|
179
|
+
const keyed: Record<'foo', unknown> = {}; // Error
|
|
180
|
+
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
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:
|
|
184
|
+
|
|
185
|
+
```
|
|
186
|
+
type Indexed = {} extends Record<string, unknown>
|
|
187
|
+
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
188
|
+
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
189
|
+
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
190
|
+
|
|
191
|
+
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
192
|
+
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
193
|
+
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
194
|
+
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
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`...
|
|
198
|
+
|
|
199
|
+
```
|
|
200
|
+
import type {RemoveIndexSignature} from 'type-fest';
|
|
201
|
+
|
|
202
|
+
type RemoveIndexSignature<ObjectType> = {
|
|
203
|
+
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
204
|
+
]: ObjectType[KeyType]; // ...to its original value, i.e. `RemoveIndexSignature<Foo> == Foo`.
|
|
205
|
+
};
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
import type {RemoveIndexSignature} from 'type-fest';
|
|
212
|
+
|
|
213
|
+
type RemoveIndexSignature<ObjectType> = {
|
|
214
|
+
[KeyType in keyof ObjectType
|
|
215
|
+
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
216
|
+
as {} extends Record<KeyType, unknown>
|
|
217
|
+
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
218
|
+
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
219
|
+
]: ObjectType[KeyType];
|
|
220
|
+
};
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
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.
|
|
224
|
+
|
|
225
|
+
```
|
|
226
|
+
import type {RemoveIndexSignature} from 'type-fest';
|
|
227
|
+
|
|
228
|
+
type RemoveIndexSignature<ObjectType> = {
|
|
229
|
+
[KeyType in keyof ObjectType
|
|
230
|
+
as {} extends Record<KeyType, unknown>
|
|
231
|
+
? never // => Remove this `KeyType`.
|
|
232
|
+
: KeyType // => Keep this `KeyType` as it is.
|
|
233
|
+
]: ObjectType[KeyType];
|
|
234
|
+
};
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
@example
|
|
238
|
+
```
|
|
239
|
+
import type {RemoveIndexSignature} from 'type-fest';
|
|
240
|
+
|
|
241
|
+
interface Example {
|
|
242
|
+
// These index signatures will be removed.
|
|
243
|
+
[x: string]: any
|
|
244
|
+
[x: number]: any
|
|
245
|
+
[x: symbol]: any
|
|
246
|
+
[x: `head-${string}`]: string
|
|
247
|
+
[x: `${string}-tail`]: string
|
|
248
|
+
[x: `head-${string}-tail`]: string
|
|
249
|
+
[x: `${bigint}`]: string
|
|
250
|
+
[x: `embedded-${number}`]: string
|
|
251
|
+
|
|
252
|
+
// These explicitly defined keys will remain.
|
|
253
|
+
foo: 'bar';
|
|
254
|
+
qux?: 'baz';
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
type ExampleWithoutIndexSignatures = RemoveIndexSignature<Example>;
|
|
258
|
+
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
@category Object
|
|
262
|
+
*/
|
|
263
|
+
type RemoveIndexSignature<ObjectType> = {
|
|
264
|
+
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
|
265
|
+
? never
|
|
266
|
+
: KeyType]: ObjectType[KeyType];
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
/**
|
|
270
|
+
Create a type that makes the given keys optional. The remaining keys are kept as is. The sister of the `SetRequired` type.
|
|
271
|
+
|
|
272
|
+
Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are optional.
|
|
273
|
+
|
|
274
|
+
@example
|
|
275
|
+
```
|
|
276
|
+
import type {SetOptional} from 'type-fest';
|
|
277
|
+
|
|
278
|
+
type Foo = {
|
|
279
|
+
a: number;
|
|
280
|
+
b?: string;
|
|
281
|
+
c: boolean;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
|
|
285
|
+
// type SomeOptional = {
|
|
286
|
+
// a: number;
|
|
287
|
+
// b?: string; // Was already optional and still is.
|
|
288
|
+
// c?: boolean; // Is now optional.
|
|
289
|
+
// }
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
@category Object
|
|
293
|
+
*/
|
|
294
|
+
type SetOptional<BaseType, Keys extends keyof BaseType> =
|
|
295
|
+
Simplify<
|
|
296
|
+
// Pick just the keys that are readonly from the base type.
|
|
297
|
+
Except<BaseType, Keys> &
|
|
298
|
+
// Pick the keys that should be mutable from the base type and make them mutable.
|
|
299
|
+
Partial<Pick<BaseType, Keys>>
|
|
300
|
+
>;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
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).
|
|
304
|
+
|
|
305
|
+
Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
|
|
306
|
+
|
|
307
|
+
@example
|
|
308
|
+
```
|
|
309
|
+
import type {UnionToIntersection} from 'type-fest';
|
|
310
|
+
|
|
311
|
+
type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
|
|
312
|
+
|
|
313
|
+
type Intersection = UnionToIntersection<Union>;
|
|
314
|
+
//=> {the(): void; great(arg: string): void; escape: boolean};
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
A more applicable example which could make its way into your library code follows.
|
|
318
|
+
|
|
319
|
+
@example
|
|
320
|
+
```
|
|
321
|
+
import type {UnionToIntersection} from 'type-fest';
|
|
322
|
+
|
|
323
|
+
class CommandOne {
|
|
324
|
+
commands: {
|
|
325
|
+
a1: () => undefined,
|
|
326
|
+
b1: () => undefined,
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
class CommandTwo {
|
|
331
|
+
commands: {
|
|
332
|
+
a2: (argA: string) => undefined,
|
|
333
|
+
b2: (argB: string) => undefined,
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
|
|
338
|
+
type Union = typeof union;
|
|
339
|
+
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
|
|
340
|
+
|
|
341
|
+
type Intersection = UnionToIntersection<Union>;
|
|
342
|
+
//=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
@category Type
|
|
346
|
+
*/
|
|
347
|
+
type UnionToIntersection<Union> = (
|
|
348
|
+
// `extends unknown` is always going to be the case and is used to convert the
|
|
349
|
+
// `Union` into a [distributive conditional
|
|
350
|
+
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
351
|
+
Union extends unknown
|
|
352
|
+
// The union type is used as the only argument to a function since the union
|
|
353
|
+
// of function arguments is an intersection.
|
|
354
|
+
? (distributedUnion: Union) => void
|
|
355
|
+
// This won't happen.
|
|
356
|
+
: never
|
|
357
|
+
// Infer the `Intersection` type since TypeScript represents the positional
|
|
358
|
+
// arguments of unions of functions as an intersection of the union.
|
|
359
|
+
) extends ((mergedIntersection: infer Intersection) => void)
|
|
360
|
+
? Intersection
|
|
361
|
+
: never;
|
|
362
|
+
|
|
363
|
+
interface ReactRenderer extends WebRenderer {
|
|
364
|
+
component: ComponentType<this['T']>;
|
|
365
|
+
storyResult: StoryFnReactReturnType;
|
|
366
|
+
mount: (ui?: JSX.Element) => Promise<Canvas>;
|
|
367
|
+
}
|
|
368
|
+
interface ReactParameters {
|
|
369
|
+
/** React renderer configuration */
|
|
370
|
+
react?: {
|
|
371
|
+
/**
|
|
372
|
+
* Whether to enable React Server Components
|
|
373
|
+
*
|
|
374
|
+
* @see https://storybook.js.org/docs/get-started/frameworks/nextjs#react-server-components-rsc
|
|
375
|
+
*/
|
|
376
|
+
rsc?: boolean;
|
|
377
|
+
/** Options passed to React root creation */
|
|
378
|
+
rootOptions?: RootOptions;
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
interface ReactTypes extends ReactRenderer {
|
|
382
|
+
parameters: ReactParameters;
|
|
383
|
+
}
|
|
384
|
+
type StoryFnReactReturnType = JSX.Element;
|
|
385
|
+
|
|
386
|
+
type AddMocks<TArgs, DefaultArgs> = Simplify<{
|
|
387
|
+
[T in keyof TArgs]: T extends keyof DefaultArgs ? DefaultArgs[T] extends (...args: any) => any & {
|
|
388
|
+
mock: {};
|
|
389
|
+
} ? DefaultArgs[T] : TArgs[T] : TArgs[T];
|
|
390
|
+
}>;
|
|
391
|
+
|
|
392
|
+
declare function __definePreview<Addons extends PreviewAddon<never>[]>(input: {
|
|
393
|
+
addons: Addons;
|
|
394
|
+
} & ProjectAnnotations<ReactTypes & InferTypes<Addons>>): ReactPreview<ReactTypes & InferTypes<Addons>>;
|
|
395
|
+
/** @ts-expect-error We cannot implement the meta faithfully here, but that is okay. */
|
|
396
|
+
interface ReactPreview<T extends AddonTypes> extends Preview<ReactTypes & T> {
|
|
397
|
+
meta<TArgs extends Args, Decorators extends DecoratorFunction<ReactTypes & T, any>, TMetaArgs extends Partial<TArgs>>(meta: {
|
|
398
|
+
render?: ArgsStoryFn<ReactTypes & T, TArgs>;
|
|
399
|
+
component?: ComponentType<TArgs>;
|
|
400
|
+
decorators?: Decorators | Decorators[];
|
|
401
|
+
args?: TMetaArgs;
|
|
402
|
+
} & Omit<ComponentAnnotations<ReactTypes & T, TArgs>, 'decorators' | 'component' | 'args' | 'render'>): ReactMeta<ReactTypes & T & {
|
|
403
|
+
args: Simplify<TArgs & Simplify<RemoveIndexSignature<DecoratorsArgs<ReactTypes & T, Decorators>>>>;
|
|
404
|
+
}, {
|
|
405
|
+
args: Partial<TArgs> extends TMetaArgs ? {} : TMetaArgs;
|
|
406
|
+
}>;
|
|
407
|
+
}
|
|
408
|
+
type DecoratorsArgs<TRenderer extends Renderer, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
|
|
409
|
+
interface ReactMeta<T extends ReactTypes, MetaInput extends ComponentAnnotations<T>>
|
|
410
|
+
/** @ts-expect-error hard */
|
|
411
|
+
extends Meta<T, MetaInput> {
|
|
412
|
+
story<TInput extends (() => ReactTypes['storyResult']) | (StoryAnnotations<T, T['args']> & {
|
|
413
|
+
render: () => ReactTypes['storyResult'];
|
|
414
|
+
})>(story?: TInput): ReactStory<T, TInput extends () => ReactTypes['storyResult'] ? {
|
|
415
|
+
render: TInput;
|
|
416
|
+
} : TInput>;
|
|
417
|
+
story<TInput extends Simplify<StoryAnnotations<T, AddMocks<T['args'], MetaInput['args']>, SetOptional<T['args'], keyof T['args'] & keyof MetaInput['args']>>>>(story?: TInput
|
|
418
|
+
/** @ts-expect-error hard */
|
|
419
|
+
): ReactStory<T, TInput>;
|
|
420
|
+
}
|
|
421
|
+
interface ReactStory<T extends ReactTypes, TInput extends StoryAnnotations<T, T['args']>> extends Story<T, TInput> {
|
|
422
|
+
Component: ComponentType<Partial<T['args']>>;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
export { type ReactPreview, type ReactStory, __definePreview };
|
package/dist/preview.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__definePreview
|
|
3
|
-
} from "./_browser-chunks/chunk-
|
|
4
|
-
import "./_browser-chunks/chunk-
|
|
3
|
+
} from "./_browser-chunks/chunk-352EX3YB.js";
|
|
4
|
+
import "./_browser-chunks/chunk-4WKCOEYI.js";
|
|
5
5
|
import "./_browser-chunks/chunk-2SCDRHCG.js";
|
|
6
6
|
import "./_browser-chunks/chunk-HBQ5Y6GW.js";
|
|
7
7
|
import "./_browser-chunks/chunk-BUAOEMNB.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react",
|
|
3
|
-
"version": "10.0.0-beta.
|
|
3
|
+
"version": "10.0.0-beta.8",
|
|
4
4
|
"description": "Storybook React renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@storybook/global": "^5.0.0",
|
|
57
|
-
"@storybook/react-dom-shim": "10.0.0-beta.
|
|
57
|
+
"@storybook/react-dom-shim": "10.0.0-beta.8"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@types/babel-plugin-react-docgen": "^4.2.3",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"peerDependencies": {
|
|
81
81
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
82
82
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
83
|
-
"storybook": "^10.0.0-beta.
|
|
83
|
+
"storybook": "^10.0.0-beta.8",
|
|
84
84
|
"typescript": ">= 4.9.x"
|
|
85
85
|
},
|
|
86
86
|
"peerDependenciesMeta": {
|
package/dist/preview.d.tsx
DELETED
|
@@ -1,425 +0,0 @@
|
|
|
1
|
-
import { ComponentType, JSX } from 'react';
|
|
2
|
-
import { PreviewAddon, InferTypes, AddonTypes, Preview, Meta, Story } from 'storybook/internal/csf';
|
|
3
|
-
import { WebRenderer, Canvas, ProjectAnnotations, Args, DecoratorFunction, ArgsStoryFn, ComponentAnnotations, StoryAnnotations, Renderer } from 'storybook/internal/types';
|
|
4
|
-
import { RootOptions } from 'react-dom/client';
|
|
5
|
-
|
|
6
|
-
declare global {
|
|
7
|
-
interface SymbolConstructor {
|
|
8
|
-
readonly observable: symbol;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
Returns a boolean for whether the two given types are equal.
|
|
14
|
-
|
|
15
|
-
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
16
|
-
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
17
|
-
*/
|
|
18
|
-
type IsEqual<T, U> =
|
|
19
|
-
(<G>() => G extends T ? 1 : 2) extends
|
|
20
|
-
(<G>() => G extends U ? 1 : 2)
|
|
21
|
-
? true
|
|
22
|
-
: false;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
Filter out keys from an object.
|
|
26
|
-
|
|
27
|
-
Returns `never` if `Exclude` is strictly equal to `Key`.
|
|
28
|
-
Returns `never` if `Key` extends `Exclude`.
|
|
29
|
-
Returns `Key` otherwise.
|
|
30
|
-
|
|
31
|
-
@example
|
|
32
|
-
```
|
|
33
|
-
type Filtered = Filter<'foo', 'foo'>;
|
|
34
|
-
//=> never
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
@example
|
|
38
|
-
```
|
|
39
|
-
type Filtered = Filter<'bar', string>;
|
|
40
|
-
//=> never
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
@example
|
|
44
|
-
```
|
|
45
|
-
type Filtered = Filter<'bar', 'foo'>;
|
|
46
|
-
//=> 'bar'
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
@see {Except}
|
|
50
|
-
*/
|
|
51
|
-
type Filter<KeyType, ExcludeType> = IsEqual<KeyType, ExcludeType> extends true ? never : (KeyType extends ExcludeType ? never : KeyType);
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
Create a type from an object type without certain keys.
|
|
55
|
-
|
|
56
|
-
This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
|
|
57
|
-
|
|
58
|
-
This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
|
|
59
|
-
|
|
60
|
-
@example
|
|
61
|
-
```
|
|
62
|
-
import type {Except} from 'type-fest';
|
|
63
|
-
|
|
64
|
-
type Foo = {
|
|
65
|
-
a: number;
|
|
66
|
-
b: string;
|
|
67
|
-
c: boolean;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
type FooWithoutA = Except<Foo, 'a' | 'c'>;
|
|
71
|
-
//=> {b: string};
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
@category Object
|
|
75
|
-
*/
|
|
76
|
-
type Except<ObjectType, KeysType extends keyof ObjectType> = {
|
|
77
|
-
[KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType];
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
@see Simplify
|
|
82
|
-
*/
|
|
83
|
-
interface SimplifyOptions {
|
|
84
|
-
/**
|
|
85
|
-
Do the simplification recursively.
|
|
86
|
-
|
|
87
|
-
@default false
|
|
88
|
-
*/
|
|
89
|
-
deep?: boolean;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Flatten a type without worrying about the result.
|
|
93
|
-
type Flatten<
|
|
94
|
-
AnyType,
|
|
95
|
-
Options extends SimplifyOptions = {},
|
|
96
|
-
> = Options['deep'] extends true
|
|
97
|
-
? {[KeyType in keyof AnyType]: Simplify<AnyType[KeyType], Options>}
|
|
98
|
-
: {[KeyType in keyof AnyType]: AnyType[KeyType]};
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
102
|
-
|
|
103
|
-
@example
|
|
104
|
-
```
|
|
105
|
-
import type {Simplify} from 'type-fest';
|
|
106
|
-
|
|
107
|
-
type PositionProps = {
|
|
108
|
-
top: number;
|
|
109
|
-
left: number;
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
type SizeProps = {
|
|
113
|
-
width: number;
|
|
114
|
-
height: number;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
118
|
-
type Props = Simplify<PositionProps & SizeProps>;
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
122
|
-
|
|
123
|
-
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
124
|
-
|
|
125
|
-
@example
|
|
126
|
-
```
|
|
127
|
-
import type {Simplify} from 'type-fest';
|
|
128
|
-
|
|
129
|
-
interface SomeInterface {
|
|
130
|
-
foo: number;
|
|
131
|
-
bar?: string;
|
|
132
|
-
baz: number | undefined;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
type SomeType = {
|
|
136
|
-
foo: number;
|
|
137
|
-
bar?: string;
|
|
138
|
-
baz: number | undefined;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
142
|
-
const someType: SomeType = literal;
|
|
143
|
-
const someInterface: SomeInterface = literal;
|
|
144
|
-
|
|
145
|
-
function fn(object: Record<string, unknown>): void {}
|
|
146
|
-
|
|
147
|
-
fn(literal); // Good: literal object type is sealed
|
|
148
|
-
fn(someType); // Good: type is sealed
|
|
149
|
-
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
150
|
-
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
151
|
-
```
|
|
152
|
-
|
|
153
|
-
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
154
|
-
|
|
155
|
-
@category Object
|
|
156
|
-
*/
|
|
157
|
-
type Simplify<
|
|
158
|
-
AnyType,
|
|
159
|
-
Options extends SimplifyOptions = {},
|
|
160
|
-
> = Flatten<AnyType> extends AnyType
|
|
161
|
-
? Flatten<AnyType, Options>
|
|
162
|
-
: AnyType;
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
Remove any index signatures from the given object type, so that only explicitly defined properties remain.
|
|
166
|
-
|
|
167
|
-
Use-cases:
|
|
168
|
-
- Remove overly permissive signatures from third-party types.
|
|
169
|
-
|
|
170
|
-
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
171
|
-
|
|
172
|
-
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>`.
|
|
173
|
-
|
|
174
|
-
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
175
|
-
|
|
176
|
-
```
|
|
177
|
-
const indexed: Record<string, unknown> = {}; // Allowed
|
|
178
|
-
|
|
179
|
-
const keyed: Record<'foo', unknown> = {}; // Error
|
|
180
|
-
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
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:
|
|
184
|
-
|
|
185
|
-
```
|
|
186
|
-
type Indexed = {} extends Record<string, unknown>
|
|
187
|
-
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
188
|
-
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
189
|
-
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
190
|
-
|
|
191
|
-
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
192
|
-
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
|
193
|
-
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
|
194
|
-
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
|
195
|
-
```
|
|
196
|
-
|
|
197
|
-
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`...
|
|
198
|
-
|
|
199
|
-
```
|
|
200
|
-
import type {RemoveIndexSignature} from 'type-fest';
|
|
201
|
-
|
|
202
|
-
type RemoveIndexSignature<ObjectType> = {
|
|
203
|
-
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
204
|
-
]: ObjectType[KeyType]; // ...to its original value, i.e. `RemoveIndexSignature<Foo> == Foo`.
|
|
205
|
-
};
|
|
206
|
-
```
|
|
207
|
-
|
|
208
|
-
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
209
|
-
|
|
210
|
-
```
|
|
211
|
-
import type {RemoveIndexSignature} from 'type-fest';
|
|
212
|
-
|
|
213
|
-
type RemoveIndexSignature<ObjectType> = {
|
|
214
|
-
[KeyType in keyof ObjectType
|
|
215
|
-
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
216
|
-
as {} extends Record<KeyType, unknown>
|
|
217
|
-
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
218
|
-
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
219
|
-
]: ObjectType[KeyType];
|
|
220
|
-
};
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
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.
|
|
224
|
-
|
|
225
|
-
```
|
|
226
|
-
import type {RemoveIndexSignature} from 'type-fest';
|
|
227
|
-
|
|
228
|
-
type RemoveIndexSignature<ObjectType> = {
|
|
229
|
-
[KeyType in keyof ObjectType
|
|
230
|
-
as {} extends Record<KeyType, unknown>
|
|
231
|
-
? never // => Remove this `KeyType`.
|
|
232
|
-
: KeyType // => Keep this `KeyType` as it is.
|
|
233
|
-
]: ObjectType[KeyType];
|
|
234
|
-
};
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
@example
|
|
238
|
-
```
|
|
239
|
-
import type {RemoveIndexSignature} from 'type-fest';
|
|
240
|
-
|
|
241
|
-
interface Example {
|
|
242
|
-
// These index signatures will be removed.
|
|
243
|
-
[x: string]: any
|
|
244
|
-
[x: number]: any
|
|
245
|
-
[x: symbol]: any
|
|
246
|
-
[x: `head-${string}`]: string
|
|
247
|
-
[x: `${string}-tail`]: string
|
|
248
|
-
[x: `head-${string}-tail`]: string
|
|
249
|
-
[x: `${bigint}`]: string
|
|
250
|
-
[x: `embedded-${number}`]: string
|
|
251
|
-
|
|
252
|
-
// These explicitly defined keys will remain.
|
|
253
|
-
foo: 'bar';
|
|
254
|
-
qux?: 'baz';
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
type ExampleWithoutIndexSignatures = RemoveIndexSignature<Example>;
|
|
258
|
-
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
@category Object
|
|
262
|
-
*/
|
|
263
|
-
type RemoveIndexSignature<ObjectType> = {
|
|
264
|
-
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
|
265
|
-
? never
|
|
266
|
-
: KeyType]: ObjectType[KeyType];
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
Create a type that makes the given keys optional. The remaining keys are kept as is. The sister of the `SetRequired` type.
|
|
271
|
-
|
|
272
|
-
Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are optional.
|
|
273
|
-
|
|
274
|
-
@example
|
|
275
|
-
```
|
|
276
|
-
import type {SetOptional} from 'type-fest';
|
|
277
|
-
|
|
278
|
-
type Foo = {
|
|
279
|
-
a: number;
|
|
280
|
-
b?: string;
|
|
281
|
-
c: boolean;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
|
|
285
|
-
// type SomeOptional = {
|
|
286
|
-
// a: number;
|
|
287
|
-
// b?: string; // Was already optional and still is.
|
|
288
|
-
// c?: boolean; // Is now optional.
|
|
289
|
-
// }
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
@category Object
|
|
293
|
-
*/
|
|
294
|
-
type SetOptional<BaseType, Keys extends keyof BaseType> =
|
|
295
|
-
Simplify<
|
|
296
|
-
// Pick just the keys that are readonly from the base type.
|
|
297
|
-
Except<BaseType, Keys> &
|
|
298
|
-
// Pick the keys that should be mutable from the base type and make them mutable.
|
|
299
|
-
Partial<Pick<BaseType, Keys>>
|
|
300
|
-
>;
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
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).
|
|
304
|
-
|
|
305
|
-
Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
|
|
306
|
-
|
|
307
|
-
@example
|
|
308
|
-
```
|
|
309
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
310
|
-
|
|
311
|
-
type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
|
|
312
|
-
|
|
313
|
-
type Intersection = UnionToIntersection<Union>;
|
|
314
|
-
//=> {the(): void; great(arg: string): void; escape: boolean};
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
A more applicable example which could make its way into your library code follows.
|
|
318
|
-
|
|
319
|
-
@example
|
|
320
|
-
```
|
|
321
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
322
|
-
|
|
323
|
-
class CommandOne {
|
|
324
|
-
commands: {
|
|
325
|
-
a1: () => undefined,
|
|
326
|
-
b1: () => undefined,
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
class CommandTwo {
|
|
331
|
-
commands: {
|
|
332
|
-
a2: (argA: string) => undefined,
|
|
333
|
-
b2: (argB: string) => undefined,
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
const union = [new CommandOne(), new CommandTwo()].map(instance => instance.commands);
|
|
338
|
-
type Union = typeof union;
|
|
339
|
-
//=> {a1(): void; b1(): void} | {a2(argA: string): void; b2(argB: string): void}
|
|
340
|
-
|
|
341
|
-
type Intersection = UnionToIntersection<Union>;
|
|
342
|
-
//=> {a1(): void; b1(): void; a2(argA: string): void; b2(argB: string): void}
|
|
343
|
-
```
|
|
344
|
-
|
|
345
|
-
@category Type
|
|
346
|
-
*/
|
|
347
|
-
type UnionToIntersection<Union> = (
|
|
348
|
-
// `extends unknown` is always going to be the case and is used to convert the
|
|
349
|
-
// `Union` into a [distributive conditional
|
|
350
|
-
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
351
|
-
Union extends unknown
|
|
352
|
-
// The union type is used as the only argument to a function since the union
|
|
353
|
-
// of function arguments is an intersection.
|
|
354
|
-
? (distributedUnion: Union) => void
|
|
355
|
-
// This won't happen.
|
|
356
|
-
: never
|
|
357
|
-
// Infer the `Intersection` type since TypeScript represents the positional
|
|
358
|
-
// arguments of unions of functions as an intersection of the union.
|
|
359
|
-
) extends ((mergedIntersection: infer Intersection) => void)
|
|
360
|
-
? Intersection
|
|
361
|
-
: never;
|
|
362
|
-
|
|
363
|
-
interface ReactRenderer extends WebRenderer {
|
|
364
|
-
component: ComponentType<this['T']>;
|
|
365
|
-
storyResult: StoryFnReactReturnType;
|
|
366
|
-
mount: (ui?: JSX.Element) => Promise<Canvas>;
|
|
367
|
-
}
|
|
368
|
-
interface ReactParameters {
|
|
369
|
-
/** React renderer configuration */
|
|
370
|
-
react?: {
|
|
371
|
-
/**
|
|
372
|
-
* Whether to enable React Server Components
|
|
373
|
-
*
|
|
374
|
-
* @see https://storybook.js.org/docs/get-started/frameworks/nextjs#react-server-components-rsc
|
|
375
|
-
*/
|
|
376
|
-
rsc?: boolean;
|
|
377
|
-
/** Options passed to React root creation */
|
|
378
|
-
rootOptions?: RootOptions;
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
interface ReactTypes extends ReactRenderer {
|
|
382
|
-
parameters: ReactParameters;
|
|
383
|
-
}
|
|
384
|
-
type StoryFnReactReturnType = JSX.Element;
|
|
385
|
-
|
|
386
|
-
type AddMocks<TArgs, DefaultArgs> = Simplify<{
|
|
387
|
-
[T in keyof TArgs]: T extends keyof DefaultArgs ? DefaultArgs[T] extends (...args: any) => any & {
|
|
388
|
-
mock: {};
|
|
389
|
-
} ? DefaultArgs[T] : TArgs[T] : TArgs[T];
|
|
390
|
-
}>;
|
|
391
|
-
|
|
392
|
-
declare function __definePreview<Addons extends PreviewAddon<never>[]>(input: {
|
|
393
|
-
addons: Addons;
|
|
394
|
-
} & ProjectAnnotations<ReactTypes & InferTypes<Addons>>): ReactPreview<ReactTypes & InferTypes<Addons>>;
|
|
395
|
-
/** @ts-expect-error We cannot implement the meta faithfully here, but that is okay. */
|
|
396
|
-
interface ReactPreview<T extends AddonTypes> extends Preview<ReactTypes & T> {
|
|
397
|
-
meta<TArgs extends Args, Decorators extends DecoratorFunction<ReactTypes & T, any>, TMetaArgs extends Partial<TArgs>>(meta: {
|
|
398
|
-
render?: ArgsStoryFn<ReactTypes & T, TArgs>;
|
|
399
|
-
component?: ComponentType<TArgs>;
|
|
400
|
-
decorators?: Decorators | Decorators[];
|
|
401
|
-
args?: TMetaArgs;
|
|
402
|
-
} & Omit<ComponentAnnotations<ReactTypes & T, TArgs>, 'decorators' | 'component' | 'args' | 'render'>): ReactMeta<ReactTypes & T & {
|
|
403
|
-
args: Simplify<TArgs & Simplify<RemoveIndexSignature<DecoratorsArgs<ReactTypes & T, Decorators>>>>;
|
|
404
|
-
}, {
|
|
405
|
-
args: Partial<TArgs> extends TMetaArgs ? {} : TMetaArgs;
|
|
406
|
-
}>;
|
|
407
|
-
}
|
|
408
|
-
type DecoratorsArgs<TRenderer extends Renderer, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
|
|
409
|
-
interface ReactMeta<T extends ReactTypes, MetaInput extends ComponentAnnotations<T>>
|
|
410
|
-
/** @ts-expect-error hard */
|
|
411
|
-
extends Meta<T, MetaInput> {
|
|
412
|
-
story<TInput extends (() => ReactTypes['storyResult']) | (StoryAnnotations<T, T['args']> & {
|
|
413
|
-
render: () => ReactTypes['storyResult'];
|
|
414
|
-
})>(story?: TInput): ReactStory<T, TInput extends () => ReactTypes['storyResult'] ? {
|
|
415
|
-
render: TInput;
|
|
416
|
-
} : TInput>;
|
|
417
|
-
story<TInput extends Simplify<StoryAnnotations<T, AddMocks<T['args'], MetaInput['args']>, SetOptional<T['args'], keyof T['args'] & keyof MetaInput['args']>>>>(story?: TInput
|
|
418
|
-
/** @ts-expect-error hard */
|
|
419
|
-
): ReactStory<T, TInput>;
|
|
420
|
-
}
|
|
421
|
-
interface ReactStory<T extends ReactTypes, TInput extends StoryAnnotations<T, T['args']>> extends Story<T, TInput> {
|
|
422
|
-
Component: ComponentType<Partial<T['args']>>;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
export { type ReactPreview, type ReactStory, __definePreview };
|