@storybook/react 10.0.0-beta.0 → 10.0.0-beta.10

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.
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  entry_preview_exports
3
- } from "./chunk-XNNKYNNU.js";
3
+ } from "./chunk-4WKCOEYI.js";
4
4
  import {
5
5
  entry_preview_argtypes_exports
6
- } from "./chunk-V6XFC4HM.js";
6
+ } from "./chunk-2SCDRHCG.js";
7
7
  import {
8
8
  entry_preview_docs_exports
9
9
  } from "./chunk-HBQ5Y6GW.js";
@@ -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 = {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  argTypesEnhancers,
3
3
  parameters
4
- } from "./_browser-chunks/chunk-V6XFC4HM.js";
4
+ } from "./_browser-chunks/chunk-2SCDRHCG.js";
5
5
  import "./_browser-chunks/chunk-VVH2AMAL.js";
6
6
  import "./_browser-chunks/chunk-L5NVL7MD.js";
7
7
  export {
@@ -5,7 +5,7 @@ import {
5
5
  parameters,
6
6
  render,
7
7
  renderToCanvas
8
- } from "./_browser-chunks/chunk-XNNKYNNU.js";
8
+ } from "./_browser-chunks/chunk-4WKCOEYI.js";
9
9
  import {
10
10
  applyDecorators
11
11
  } from "./_browser-chunks/chunk-BUAOEMNB.js";
package/dist/index.d.ts CHANGED
@@ -501,6 +501,7 @@ declare function composeStories<TModule extends Store_CSFExports<ReactRenderer,
501
501
  declare function __definePreview<Addons extends PreviewAddon<never>[]>(input: {
502
502
  addons: Addons;
503
503
  } & ProjectAnnotations<ReactTypes & InferTypes<Addons>>): ReactPreview<ReactTypes & InferTypes<Addons>>;
504
+ /** @ts-expect-error We cannot implement the meta faithfully here, but that is okay. */
504
505
  interface ReactPreview<T extends AddonTypes> extends Preview$1<ReactTypes & T> {
505
506
  meta<TArgs extends Args, Decorators extends DecoratorFunction<ReactTypes & T, any>, TMetaArgs extends Partial<TArgs>>(meta: {
506
507
  render?: ArgsStoryFn<ReactTypes & T, TArgs>;
@@ -514,13 +515,17 @@ interface ReactPreview<T extends AddonTypes> extends Preview$1<ReactTypes & T> {
514
515
  }>;
515
516
  }
516
517
  type DecoratorsArgs<TRenderer extends Renderer, Decorators> = UnionToIntersection<Decorators extends DecoratorFunction<TRenderer, infer TArgs> ? TArgs : unknown>;
517
- interface ReactMeta<T extends ReactTypes, MetaInput extends ComponentAnnotations<T>> extends Meta$1<T, MetaInput> {
518
+ interface ReactMeta<T extends ReactTypes, MetaInput extends ComponentAnnotations<T>>
519
+ /** @ts-expect-error hard */
520
+ extends Meta$1<T, MetaInput> {
518
521
  story<TInput extends (() => ReactTypes['storyResult']) | (StoryAnnotations<T, T['args']> & {
519
522
  render: () => ReactTypes['storyResult'];
520
523
  })>(story?: TInput): ReactStory<T, TInput extends () => ReactTypes['storyResult'] ? {
521
524
  render: TInput;
522
525
  } : TInput>;
523
- 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>;
526
+ story<TInput extends Simplify<StoryAnnotations<T, AddMocks<T['args'], MetaInput['args']>, SetOptional<T['args'], keyof T['args'] & keyof MetaInput['args']>>>>(story?: TInput
527
+ /** @ts-expect-error hard */
528
+ ): ReactStory<T, TInput>;
524
529
  }
525
530
  interface ReactStory<T extends ReactTypes, TInput extends StoryAnnotations<T, T['args']>> extends Story<T, TInput> {
526
531
  Component: ComponentType<Partial<T['args']>>;
package/dist/index.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  __definePreview
3
- } from "./_browser-chunks/chunk-I3XJ5JHI.js";
3
+ } from "./_browser-chunks/chunk-352EX3YB.js";
4
4
  import {
5
5
  entry_preview_exports,
6
6
  renderToCanvas
7
- } from "./_browser-chunks/chunk-XNNKYNNU.js";
7
+ } from "./_browser-chunks/chunk-4WKCOEYI.js";
8
8
  import {
9
9
  entry_preview_argtypes_exports
10
- } from "./_browser-chunks/chunk-V6XFC4HM.js";
10
+ } from "./_browser-chunks/chunk-2SCDRHCG.js";
11
11
  import "./_browser-chunks/chunk-HBQ5Y6GW.js";
12
12
  import "./_browser-chunks/chunk-BUAOEMNB.js";
13
13
  import "./_browser-chunks/chunk-VVH2AMAL.js";
package/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_bo25dn6kq5p from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_bo25dn6kq5p from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_bo25dn6kq5p from "node:module";
1
+ import CJS_COMPAT_NODE_URL_c0z5ylw0h8o from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_c0z5ylw0h8o from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_c0z5ylw0h8o from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_bo25dn6kq5p.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_bo25dn6kq5p.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_bo25dn6kq5p.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_c0z5ylw0h8o.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_c0z5ylw0h8o.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_c0z5ylw0h8o.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 = "") {