@openpkg-ts/ui 0.5.1 → 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.
@@ -1,7 +1,12 @@
1
1
  import * as React from "react";
2
2
  type KindBadgeKind = "function" | "class" | "interface" | "type" | "enum" | "variable" | "namespace" | "module" | "reference" | "external";
3
3
  type KindBadgeSize = "sm" | "md";
4
- declare const kindBadgeVariants: unknown;
4
+ declare const kindBadgeVariants: (props?: {
5
+ kind?: KindBadgeKind | null;
6
+ size?: KindBadgeSize | null;
7
+ class?: string;
8
+ className?: string;
9
+ }) => string;
5
10
  interface KindBadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
6
11
  kind?: KindBadgeKind | null;
7
12
  size?: KindBadgeSize | null;
@@ -10,7 +15,12 @@ interface KindBadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
10
15
  declare const KindBadge: React.ForwardRefExoticComponent<KindBadgeProps & React.RefAttributes<HTMLSpanElement>>;
11
16
  type StatusBadgeStatus = "success" | "warning" | "error" | "neutral";
12
17
  type StatusBadgeSize = "sm" | "md";
13
- declare const statusBadgeVariants: unknown;
18
+ declare const statusBadgeVariants: (props?: {
19
+ status?: StatusBadgeStatus | null;
20
+ size?: StatusBadgeSize | null;
21
+ class?: string;
22
+ className?: string;
23
+ }) => string;
14
24
  interface StatusBadgeProps extends React.HTMLAttributes<HTMLSpanElement> {
15
25
  status?: StatusBadgeStatus | null;
16
26
  size?: StatusBadgeSize | null;
@@ -145,7 +145,12 @@ declare function CollapsiblePanel({ title, children, defaultExpanded, expanded:
145
145
  import * as React6 from "react";
146
146
  type HttpMethod = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
147
147
  type EndpointBadgeSize = "sm" | "md";
148
- declare const endpointBadgeVariants: unknown;
148
+ declare const endpointBadgeVariants: (props?: {
149
+ method?: HttpMethod | null;
150
+ size?: EndpointBadgeSize | null;
151
+ class?: string;
152
+ className?: string;
153
+ }) => string;
149
154
  interface EndpointBadgeProps extends React6.HTMLAttributes<HTMLSpanElement> {
150
155
  method: HttpMethod;
151
156
  size?: EndpointBadgeSize | null;
@@ -233,7 +238,7 @@ interface ExampleSectionProps {
233
238
  * Integrates with SyncScrollProvider for synchronized scrolling.
234
239
  */
235
240
  declare function ExampleSection({ id, examples, dataSource, response, notes, className }: ExampleSectionProps): ReactNode7;
236
- import { SpecSignatureParameter } from "@openpkg-ts/spec";
241
+ import { SpecSchema, SpecSignatureParameter } from "@openpkg-ts/spec";
237
242
  import { ReactNode as ReactNode8 } from "react";
238
243
  interface ExpandableParameterProps {
239
244
  /** Parameter from spec */
@@ -250,12 +255,14 @@ interface ExpandableParameterProps {
250
255
  level?: number;
251
256
  /** Custom className */
252
257
  className?: string;
258
+ /** Callback to resolve $ref schemas */
259
+ resolveRef?: (ref: string) => SpecSchema | undefined;
253
260
  }
254
261
  /**
255
262
  * Compound component combining APIParameterItem + NestedParameterToggle + NestedParameterContainer.
256
263
  * Automatically extracts nested object properties and enum values from spec schema.
257
264
  */
258
- 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;
259
266
  import { ReactNode as ReactNode9 } from "react";
260
267
  interface MethodSectionProps {
261
268
  /** Section ID for scroll sync */
@@ -664,7 +671,11 @@ type TypeColor = "string" | "number" | "boolean" | "null" | "undefined" | "objec
664
671
  * Type coloring for syntax display.
665
672
  * Follows Stripe-style: consistent colors for primitives vs complex types.
666
673
  */
667
- declare const typeBadgeVariants: unknown;
674
+ declare const typeBadgeVariants: (props?: {
675
+ typeColor?: TypeColor | null;
676
+ class?: string;
677
+ className?: string;
678
+ }) => string;
668
679
  interface TypeBadgeProps extends React13.HTMLAttributes<HTMLSpanElement> {
669
680
  /** Type string to display */
670
681
  type: string;
@@ -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.1",
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": {
@@ -6,8 +6,40 @@
6
6
  * Usage: @import '@openpkg-ts/ui/styles/docskit.css';
7
7
  */
8
8
 
9
- /* CodeHike custom theme (dark) */
9
+ /* CodeHike custom theme (light default) */
10
10
  :root {
11
+ --ch-0: light;
12
+ --ch-1: #999999;
13
+ --ch-2: #c9555a;
14
+ --ch-3: #3a3a3a;
15
+ --ch-4: #3a3a3a;
16
+ --ch-5: #7c3aed;
17
+ --ch-6: #b8860b;
18
+ --ch-7: #c9555a;
19
+ --ch-8: #b8860b;
20
+ --ch-9: #c9555a;
21
+ --ch-10: #ebebeb;
22
+ --ch-11: #fde8e8;
23
+ --ch-12: #e8f5e8;
24
+ --ch-13: #fdf0d5;
25
+ --ch-14: #e8e8e8;
26
+ --ch-15: #999999;
27
+ --ch-16: #f5f5f5;
28
+ --ch-17: #d0d0d080;
29
+ --ch-18: #fdff0033;
30
+ --ch-19: #c9555a;
31
+ --ch-20: #d0d0e0;
32
+ --ch-21: #c9555a;
33
+ --ch-22: #ebebeb;
34
+ --ch-23: #e0e0e0;
35
+ --ch-24: #b0b0b0;
36
+ --ch-25: #b0b0b033;
37
+ --ch-26: #f5f5f5e6;
38
+ }
39
+
40
+ /* CodeHike custom theme (dark) — explicit class or data attribute */
41
+ .dark,
42
+ [data-theme="dark"] {
11
43
  --ch-0: dark;
12
44
  --ch-1: #5c5c5c;
13
45
  --ch-2: #c9555a;
@@ -37,36 +69,37 @@
37
69
  --ch-26: #1a1a1ae6;
38
70
  }
39
71
 
40
- /* CodeHike custom theme (light) */
41
- .light,
42
- [data-theme="light"] {
43
- --ch-0: light;
44
- --ch-1: #999999;
45
- --ch-2: #c9555a;
46
- --ch-3: #3a3a3a;
47
- --ch-4: #3a3a3a;
48
- --ch-5: #7c3aed;
49
- --ch-6: #b8860b;
50
- --ch-7: #c9555a;
51
- --ch-8: #b8860b;
52
- --ch-9: #c9555a;
53
- --ch-10: #ebebeb;
54
- --ch-11: #fde8e8;
55
- --ch-12: #e8f5e8;
56
- --ch-13: #fdf0d5;
57
- --ch-14: #e8e8e8;
58
- --ch-15: #999999;
59
- --ch-16: #f5f5f5;
60
- --ch-17: #d0d0d080;
61
- --ch-18: #fdff0033;
62
- --ch-19: #c9555a;
63
- --ch-20: #d0d0e0;
64
- --ch-21: #c9555a;
65
- --ch-22: #ebebeb;
66
- --ch-23: #e0e0e0;
67
- --ch-24: #b0b0b0;
68
- --ch-25: #b0b0b033;
69
- --ch-26: #f5f5f5e6;
72
+ /* CodeHike dark theme system preference */
73
+ @media (prefers-color-scheme: dark) {
74
+ :root:not(.light):not([data-theme="light"]) {
75
+ --ch-0: dark;
76
+ --ch-1: #5c5c5c;
77
+ --ch-2: #c9555a;
78
+ --ch-3: #d4d4d4;
79
+ --ch-4: #d4d4d4;
80
+ --ch-5: #c4a7e7;
81
+ --ch-6: #d4a553;
82
+ --ch-7: #c9555a;
83
+ --ch-8: #d4a553;
84
+ --ch-9: #c9555a;
85
+ --ch-10: #2a2a2a;
86
+ --ch-11: #3a1515;
87
+ --ch-12: #1a2a1a;
88
+ --ch-13: #3a2a15;
89
+ --ch-14: #1e1e1e;
90
+ --ch-15: #5c5c5c;
91
+ --ch-16: #1a1a1a;
92
+ --ch-17: #3a3a3a1a;
93
+ --ch-18: #ffffff0b;
94
+ --ch-19: #c9555a;
95
+ --ch-20: #3a3a5a;
96
+ --ch-21: #c9555a;
97
+ --ch-22: #141414;
98
+ --ch-23: #2a2a2a;
99
+ --ch-24: #4a4a4a;
100
+ --ch-25: #4a4a4a66;
101
+ --ch-26: #1a1a1ae6;
102
+ }
70
103
  }
71
104
 
72
105
  /* openpkg-code-* Tailwind v4 color theme (maps to --ch-* vars) */