@openpkg-ts/ui 0.5.2 → 0.6.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.
@@ -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 */
@@ -308,9 +310,9 @@ interface NestedParameterToggleProps {
308
310
  className?: string;
309
311
  }
310
312
  /**
311
- * "Show/Hide Child Attributes" toggle button (Scalar/Clerk-style).
312
- * When collapsed: standalone rounded pill.
313
- * When expanded: top of a unified bordered container (rounded-t, no bottom border).
313
+ * "Show/Hide Child Attributes" toggle button (Stripe-style).
314
+ * When collapsed: inline-block rounded pill button.
315
+ * When expanded: full-width top of unified bordered container.
314
316
  */
315
317
  declare function NestedParameterToggle({ expanded, onToggle, className }: NestedParameterToggleProps): ReactNode11;
316
318
  import { ReactNode as ReactNode12 } from "react";
@@ -1309,7 +1309,7 @@ function APIReferenceLayout({
1309
1309
  rightWidth = "42%"
1310
1310
  }) {
1311
1311
  return /* @__PURE__ */ jsxs12("div", {
1312
- className: cn("openpkg-api-layout", "max-w-[1600px] mx-auto", "flex flex-col", "lg:grid", className),
1312
+ className: cn("openpkg-api-layout", "max-w-[1600px] mx-auto", "flex flex-col", "lg:grid lg:items-start", className),
1313
1313
  style: {
1314
1314
  "--openpkg-left-width": leftWidth,
1315
1315
  "--openpkg-right-width": rightWidth
@@ -1896,7 +1896,7 @@ function NestedParameterToggle({
1896
1896
  return /* @__PURE__ */ jsxs20("button", {
1897
1897
  type: "button",
1898
1898
  onClick: onToggle,
1899
- className: cn("openpkg-nested-toggle", "flex items-center gap-2 w-full", "font-sans text-[13px] font-medium", "text-[var(--openpkg-text-secondary)]", "bg-transparent", "border border-[var(--openpkg-border-medium)]", "px-4 py-3", "cursor-pointer", "transition-all duration-150", "hover:text-[var(--openpkg-text-primary)]", expanded ? "rounded-t-lg rounded-b-none border-b-[var(--openpkg-border-subtle)]" : "rounded-lg", className),
1899
+ className: cn("openpkg-nested-toggle", "flex items-center gap-2", "font-sans text-[13px] font-medium", "text-[var(--openpkg-text-secondary)]", "bg-transparent", "border border-[var(--openpkg-border-medium)]", "px-2 py-1.5", "cursor-pointer", "transition-[width,border-radius,border-color,color] duration-200 ease-out", "hover:text-[var(--openpkg-text-primary)]", expanded ? "w-full rounded-t-md rounded-b-none border-b-[var(--openpkg-border-subtle)]" : "w-fit rounded-md", className),
1900
1900
  "aria-expanded": expanded,
1901
1901
  children: [
1902
1902
  /* @__PURE__ */ jsx38("span", {
@@ -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.1",
4
4
  "description": "UI primitives and components for OpenPkg documentation",
5
5
  "homepage": "https://github.com/ryanwaits/openpkg-ts#readme",
6
6
  "repository": {