@storybook/react 11.0.0-beta.5 → 11.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4202,7 +4202,7 @@ import { logger as logger2 } from "storybook/internal/node-logger";
4202
4202
 
4203
4203
  // src/componentManifest/componentMeta/componentMetaExtractor.ts
4204
4204
  import { extractComponentJsDocInfo } from "storybook/internal/component-meta";
4205
- var LARGE_SOURCE_THRESHOLD = 30, MAX_UNWRAP_DEPTH = 5, MAX_SERIALIZATION_DEPTH = 5;
4205
+ var LARGE_SOURCE_THRESHOLD = 30, MAX_UNWRAP_DEPTH = 5, MAX_SERIALIZATION_DEPTH = 5, ARRAY_SYMBOL_NAMES = /* @__PURE__ */ new Set(["Array", "ReadonlyArray"]);
4206
4206
  function isLiteralType(type) {
4207
4207
  return type.isStringLiteral() || type.isNumberLiteral();
4208
4208
  }
@@ -4526,10 +4526,29 @@ function serializeType(typescript, checker, type, isRequired, depth = 0, declare
4526
4526
  }))
4527
4527
  };
4528
4528
  if (!isRequired && nonUndefinedTypes.length === 1 && nonUndefinedTypes.length < type.types.length)
4529
- return { name: checker.typeToString(nonUndefinedTypes[0]) };
4529
+ return serializeLeaf(typescript, checker, nonUndefinedTypes[0], depth);
4530
+ let nonNullishTypes = nonUndefinedTypes.filter(
4531
+ (t) => !(t.getFlags() & typescript.TypeFlags.Null)
4532
+ );
4533
+ if (nonNullishTypes.length === 1 && isArrayType(nonNullishTypes[0]))
4534
+ return {
4535
+ name: checker.typeToString(type),
4536
+ element: serializeElement(typescript, checker, nonNullishTypes[0], depth)
4537
+ };
4530
4538
  }
4531
4539
  let constraint = type.getConstraint?.();
4532
- return constraint && constraint !== type ? serializeType(typescript, checker, constraint, isRequired, depth + 1) : { name: checker.typeToString(type) };
4540
+ return constraint && constraint !== type ? serializeType(typescript, checker, constraint, isRequired, depth + 1) : serializeLeaf(typescript, checker, type, depth);
4541
+ }
4542
+ function isArrayType(type) {
4543
+ return ARRAY_SYMBOL_NAMES.has(type.getSymbol()?.getName() ?? "");
4544
+ }
4545
+ function serializeLeaf(typescript, checker, type, depth) {
4546
+ let name = checker.typeToString(type);
4547
+ return isArrayType(type) ? { name, element: serializeElement(typescript, checker, type, depth) } : { name };
4548
+ }
4549
+ function serializeElement(typescript, checker, arrayType, depth) {
4550
+ let [element] = checker.getTypeArguments(arrayType);
4551
+ return serializeType(typescript, checker, element, !0, depth + 1);
4533
4552
  }
4534
4553
  function unwrapToFunction(typescript, node, depth = 0, checker) {
4535
4554
  if (!(depth > MAX_UNWRAP_DEPTH)) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ComponentMetaManager,
3
3
  loadDocgenTypeScript
4
- } from "./chunk-2DC27WWN.js";
4
+ } from "./chunk-2I5WCK5H.js";
5
5
 
6
6
  // src/componentManifest/componentMetaManagerSingleton.ts
7
7
  import { logger } from "storybook/internal/node-logger";
@@ -3,7 +3,7 @@ import {
3
3
  isExtractable,
4
4
  posix,
5
5
  resolveStoryFileComponents
6
- } from "./chunk-2DC27WWN.js";
6
+ } from "./chunk-2I5WCK5H.js";
7
7
  import {
8
8
  extractArgTypes
9
9
  } from "./chunk-SC3QXTHH.js";
@@ -15,16 +15,27 @@ var REACT_ATTRIBUTE_INTERFACES = /* @__PURE__ */ new Set(["Attributes", "RefAttr
15
15
  function isReactAttribute(prop) {
16
16
  return !!prop.parent && REACT_ATTRIBUTE_INTERFACES.has(prop.parent.name) && /(^|[\\/])node_modules[\\/]/.test(prop.parent.fileName);
17
17
  }
18
+ function toDocgenType({ element, ...type }) {
19
+ return element ? { name: "array", raw: type.name, value: toDocgenType(element) } : type;
20
+ }
18
21
  function extractArgTypesFromComponentMeta(componentMeta) {
19
22
  if (!componentMeta)
20
23
  return;
21
24
  let props = Object.fromEntries(
22
25
  Object.entries(componentMeta.props).filter(([, prop]) => !isReactAttribute(prop)).map(([name, prop]) => [
23
26
  name,
24
- prop.defaultValue ? { ...prop, defaultValue: { ...prop.defaultValue, computed: !1 } } : prop
27
+ {
28
+ ...prop,
29
+ type: toDocgenType(prop.type),
30
+ defaultValue: prop.defaultValue && { ...prop.defaultValue, computed: !1 }
31
+ }
25
32
  ])
26
- );
27
- return extractArgTypes({ __docgenInfo: { ...componentMeta, props } }) ?? void 0;
33
+ ), argTypes = extractArgTypes({ __docgenInfo: { ...componentMeta, props } }) ?? void 0;
34
+ for (let [name, prop] of Object.entries(componentMeta.props)) {
35
+ let table = argTypes?.[name]?.table;
36
+ prop.type.element && table && (table.type = { summary: prop.type.name });
37
+ }
38
+ return argTypes;
28
39
  }
29
40
  function addArgTypesFromComponentMeta(payload) {
30
41
  let argTypes = extractArgTypesFromComponentMeta(payload.reactComponentMeta), subcomponents = payload.subcomponents ? Object.fromEntries(
@@ -1,4 +1,4 @@
1
- import { createRequire as CJS_COMPAT_CREATE_REQUIRE_h7kvzawybx6 } from "node:module";var require = CJS_COMPAT_CREATE_REQUIRE_h7kvzawybx6(import.meta.url);
1
+ import { createRequire as CJS_COMPAT_CREATE_REQUIRE_irrednmjp7d } from "node:module";var require = CJS_COMPAT_CREATE_REQUIRE_irrednmjp7d(import.meta.url);
2
2
  var __create = Object.create;
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  getSharedComponentMetaManager
3
- } from "./chunk-2NYPPHY3.js";
3
+ } from "./chunk-ITCF7APG.js";
4
4
  import {
5
5
  extractArgTypesFromComponentMeta
6
- } from "./chunk-WSXDRG6X.js";
7
- import "./chunk-2DC27WWN.js";
6
+ } from "./chunk-LZBEMUVF.js";
7
+ import "./chunk-2I5WCK5H.js";
8
8
  import "./chunk-MYBSMCSW.js";
9
9
  import "./chunk-CJ2XYAXX.js";
10
10
  import "./chunk-SC3QXTHH.js";
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  buildDocgenPayloads
3
- } from "../_node-chunks/chunk-WSXDRG6X.js";
3
+ } from "../_node-chunks/chunk-LZBEMUVF.js";
4
4
  import {
5
5
  ComponentMetaManager,
6
6
  loadDocgenTypeScript
7
- } from "../_node-chunks/chunk-2DC27WWN.js";
7
+ } from "../_node-chunks/chunk-2I5WCK5H.js";
8
8
  import "../_node-chunks/chunk-MYBSMCSW.js";
9
9
  import "../_node-chunks/chunk-CJ2XYAXX.js";
10
10
  import "../_node-chunks/chunk-SC3QXTHH.js";
package/dist/preset.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  } from "./_node-chunks/chunk-HRHJMJC7.js";
4
4
  import {
5
5
  getSharedComponentMetaManager
6
- } from "./_node-chunks/chunk-2NYPPHY3.js";
6
+ } from "./_node-chunks/chunk-ITCF7APG.js";
7
7
  import {
8
8
  buildReactComponentDocgenFromResolved,
9
9
  buildStoryDocsFromResolved,
@@ -13,7 +13,7 @@ import {
13
13
  join,
14
14
  posix,
15
15
  resolveStoryFileComponents
16
- } from "./_node-chunks/chunk-2DC27WWN.js";
16
+ } from "./_node-chunks/chunk-2I5WCK5H.js";
17
17
  import {
18
18
  REACT_DOCGEN_TYPESCRIPT_APIS
19
19
  } from "./_node-chunks/chunk-MYBSMCSW.js";
@@ -379,7 +379,7 @@ async function internal_getArgTypesData(_input, options) {
379
379
  return null;
380
380
  let absoluteComponentFilePath = path2.isAbsolute(componentFilePath) ? componentFilePath : join3(getProjectRoot(), componentFilePath);
381
381
  if ((await presets?.apply("features", {}))?.docgenServer) {
382
- let { extractArgTypesFromComponentFile } = await import("./_node-chunks/extractArgTypesFromComponentFile-E3P24DW4.js");
382
+ let { extractArgTypesFromComponentFile } = await import("./_node-chunks/extractArgTypesFromComponentFile-BBV3XDO4.js");
383
383
  return extractArgTypesFromComponentFile({
384
384
  componentFilePath: absoluteComponentFilePath,
385
385
  componentExportName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react",
3
- "version": "11.0.0-beta.5",
3
+ "version": "11.0.0-rc.0",
4
4
  "description": "Storybook React renderer",
5
5
  "keywords": [
6
6
  "storybook"
@@ -56,7 +56,7 @@
56
56
  "@storybook/global": "^5.0.0"
57
57
  },
58
58
  "devDependencies": {
59
- "@storybook/component-meta-typescript": "11.0.0-beta.5",
59
+ "@storybook/component-meta-typescript": "11.0.0-rc.0",
60
60
  "@types/babel-plugin-react-docgen": "^4.2.3",
61
61
  "@types/escodegen": "^0.0.6",
62
62
  "@types/estree": "^1.0.6",
@@ -90,7 +90,7 @@
90
90
  "react-docgen": "^8.0.2",
91
91
  "react-docgen-typescript": "^2.2.2",
92
92
  "react-dom": "^18.0.0 || ^19.0.0",
93
- "storybook": "^11.0.0-beta.5",
93
+ "storybook": "^11.0.0-rc.0",
94
94
  "typescript": "^5.9.0 || ^6.0.0 || ^7.0.0"
95
95
  },
96
96
  "peerDependenciesMeta": {