@openpkg-ts/ui 0.5.2 → 0.6.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.
@@ -238,7 +238,7 @@ interface ExampleSectionProps {
238
238
  * Integrates with SyncScrollProvider for synchronized scrolling.
239
239
  */
240
240
  declare function ExampleSection({ id, examples, dataSource, response, notes, className }: ExampleSectionProps): ReactNode7;
241
- import { SpecSignatureParameter } from "@openpkg-ts/spec";
241
+ import { SpecSchema, SpecSignatureParameter } from "@openpkg-ts/spec";
242
242
  import { ReactNode as ReactNode8 } from "react";
243
243
  interface ExpandableParameterProps {
244
244
  /** Parameter from spec */
@@ -255,12 +255,14 @@ interface ExpandableParameterProps {
255
255
  level?: number;
256
256
  /** Custom className */
257
257
  className?: string;
258
+ /** Callback to resolve $ref schemas */
259
+ resolveRef?: (ref: string) => SpecSchema | undefined;
258
260
  }
259
261
  /**
260
262
  * Compound component combining APIParameterItem + NestedParameterToggle + NestedParameterContainer.
261
263
  * Automatically extracts nested object properties and enum values from spec schema.
262
264
  */
263
- declare function ExpandableParameter({ parameter, parentPath, defaultExpanded, expanded: controlledExpanded, onExpandedChange, level, className }: ExpandableParameterProps): ReactNode8;
265
+ declare function ExpandableParameter({ parameter, parentPath, defaultExpanded, expanded: controlledExpanded, onExpandedChange, level, className, resolveRef }: ExpandableParameterProps): ReactNode8;
264
266
  import { ReactNode as ReactNode9 } from "react";
265
267
  interface MethodSectionProps {
266
268
  /** Section ID for scroll sync */
@@ -1923,7 +1923,8 @@ function ExpandableParameter({
1923
1923
  expanded: controlledExpanded,
1924
1924
  onExpandedChange,
1925
1925
  level = 0,
1926
- className
1926
+ className,
1927
+ resolveRef
1927
1928
  }) {
1928
1929
  const [internalExpanded, setInternalExpanded] = useState10(defaultExpanded);
1929
1930
  const isControlled = controlledExpanded !== undefined;
@@ -1936,7 +1937,7 @@ function ExpandableParameter({
1936
1937
  setInternalExpanded(newValue);
1937
1938
  }
1938
1939
  };
1939
- const { nestedParams, enumValues, hasChildren } = extractSchemaInfo(parameter.schema);
1940
+ const { nestedParams, enumValues, hasChildren } = extractSchemaInfo(parameter.schema, resolveRef);
1940
1941
  const type = formatSchema(parameter.schema);
1941
1942
  const isRequired = parameter.required !== false;
1942
1943
  return /* @__PURE__ */ jsx39("div", {
@@ -1964,7 +1965,8 @@ function ExpandableParameter({
1964
1965
  children: nestedParams.map((nested) => /* @__PURE__ */ jsx39(ExpandableParameter, {
1965
1966
  parameter: nested,
1966
1967
  parentPath: `${parameter.name}.`,
1967
- level: level + 1
1968
+ level: level + 1,
1969
+ resolveRef
1968
1970
  }, nested.name))
1969
1971
  })
1970
1972
  ]
@@ -1973,7 +1975,7 @@ function ExpandableParameter({
1973
1975
  })
1974
1976
  });
1975
1977
  }
1976
- function extractSchemaInfo(schema) {
1978
+ function extractSchemaInfo(schema, resolveRef) {
1977
1979
  const result = {
1978
1980
  nestedParams: [],
1979
1981
  enumValues: [],
@@ -1981,7 +1983,13 @@ function extractSchemaInfo(schema) {
1981
1983
  };
1982
1984
  if (!schema || typeof schema !== "object")
1983
1985
  return result;
1984
- const s = schema;
1986
+ let s = schema;
1987
+ if (s.$ref && typeof s.$ref === "string" && resolveRef) {
1988
+ const resolved = resolveRef(s.$ref);
1989
+ if (resolved && typeof resolved === "object") {
1990
+ s = resolved;
1991
+ }
1992
+ }
1985
1993
  if (s.type === "object" && s.properties && typeof s.properties === "object") {
1986
1994
  const props = s.properties;
1987
1995
  const required = Array.isArray(s.required) ? s.required : [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpkg-ts/ui",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
4
4
  "description": "UI primitives and components for OpenPkg documentation",
5
5
  "homepage": "https://github.com/ryanwaits/openpkg-ts#readme",
6
6
  "repository": {