@openpkg-ts/ui 0.5.0 → 0.5.2

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;
@@ -288,8 +293,9 @@ interface NestedParameterContainerProps {
288
293
  className?: string;
289
294
  }
290
295
  /**
291
- * Bordered container for nested child parameters (Stripe-style).
292
- * Connects to NestedParameterToggle above (no top border).
296
+ * Bordered container for nested child parameters (Scalar/Clerk-style).
297
+ * Connects to NestedParameterToggle above shares the same border,
298
+ * so this has no top border and only bottom-rounded corners.
293
299
  */
294
300
  declare function NestedParameterContainer({ children, level, className }: NestedParameterContainerProps): ReactNode10;
295
301
  import { ReactNode as ReactNode11 } from "react";
@@ -298,16 +304,15 @@ interface NestedParameterToggleProps {
298
304
  expanded: boolean;
299
305
  /** Toggle callback */
300
306
  onToggle: () => void;
301
- /** Optional child count to display */
302
- count?: number;
303
307
  /** Custom className */
304
308
  className?: string;
305
309
  }
306
310
  /**
307
- * "Show/Hide child parameters" toggle button (Stripe-style).
308
- * Plus icon rotates 45deg when expanded.
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).
309
314
  */
310
- declare function NestedParameterToggle({ expanded, onToggle, count, className }: NestedParameterToggleProps): ReactNode11;
315
+ declare function NestedParameterToggle({ expanded, onToggle, className }: NestedParameterToggleProps): ReactNode11;
311
316
  import { ReactNode as ReactNode12 } from "react";
312
317
  interface APIParameterSchema {
313
318
  /** Type name */
@@ -346,10 +351,10 @@ interface APIParameterItemProps {
346
351
  className?: string;
347
352
  }
348
353
  /**
349
- * Single parameter row in Stripe-style documentation.
350
- * Displays name, type, badges, description, and optional nested content.
354
+ * Single parameter row (Scalar/Clerk-style).
355
+ * Displays name, type, required badge (orange text), description, and optional nested content.
351
356
  */
352
- declare function APIParameterItem({ name, parentPath, type, required, optional, expandable, description, children, anchorId, showAnchor, className }: APIParameterItemProps): ReactNode12;
357
+ declare function APIParameterItem({ name, parentPath, type, required, optional, description, children, anchorId, className }: APIParameterItemProps): ReactNode12;
353
358
  import * as React8 from "react";
354
359
  interface ParameterListProps {
355
360
  /** Title above the list (e.g., "Body parameters") */
@@ -664,7 +669,11 @@ type TypeColor = "string" | "number" | "boolean" | "null" | "undefined" | "objec
664
669
  * Type coloring for syntax display.
665
670
  * Follows Stripe-style: consistent colors for primitives vs complex types.
666
671
  */
667
- declare const typeBadgeVariants: unknown;
672
+ declare const typeBadgeVariants: (props?: {
673
+ typeColor?: TypeColor | null;
674
+ class?: string;
675
+ className?: string;
676
+ }) => string;
668
677
  interface TypeBadgeProps extends React13.HTMLAttributes<HTMLSpanElement> {
669
678
  /** Type string to display */
670
679
  type: string;
@@ -1814,7 +1814,6 @@ import { formatSchema } from "@openpkg-ts/sdk/browser";
1814
1814
  import { useState as useState10 } from "react";
1815
1815
 
1816
1816
  // src/docskit/api/parameter-item.tsx
1817
- import { Link } from "lucide-react";
1818
1817
  import { jsx as jsx36, jsxs as jsxs19 } from "react/jsx-runtime";
1819
1818
 
1820
1819
  function APIParameterItem({
@@ -1823,35 +1822,18 @@ function APIParameterItem({
1823
1822
  type,
1824
1823
  required,
1825
1824
  optional,
1826
- expandable: expandable2,
1827
1825
  description,
1828
1826
  children,
1829
1827
  anchorId,
1830
- showAnchor = false,
1831
1828
  className
1832
1829
  }) {
1833
- const handleAnchorClick = () => {
1834
- if (anchorId && typeof window !== "undefined") {
1835
- window.location.hash = anchorId;
1836
- navigator.clipboard?.writeText(window.location.href);
1837
- }
1838
- };
1839
1830
  return /* @__PURE__ */ jsxs19("div", {
1840
1831
  id: anchorId,
1841
1832
  className: cn("openpkg-param", "py-5 border-b border-[var(--openpkg-border-subtle)]", "last:border-b-0", className),
1842
1833
  children: [
1843
1834
  /* @__PURE__ */ jsxs19("div", {
1844
- className: "openpkg-param-header flex items-center gap-2.5 mb-2 flex-wrap",
1835
+ className: "openpkg-param-header flex items-baseline gap-2 mb-1 flex-wrap",
1845
1836
  children: [
1846
- showAnchor && /* @__PURE__ */ jsx36("button", {
1847
- type: "button",
1848
- onClick: handleAnchorClick,
1849
- className: cn("openpkg-anchor-link", "flex items-center justify-center w-4 h-4", "opacity-0 group-hover:opacity-100 hover:opacity-100", "text-[var(--openpkg-text-muted)]", "hover:text-[var(--openpkg-accent-blue)]", "cursor-pointer transition-opacity"),
1850
- "aria-label": "Copy link",
1851
- children: /* @__PURE__ */ jsx36(Link, {
1852
- size: 14
1853
- })
1854
- }),
1855
1837
  /* @__PURE__ */ jsxs19("span", {
1856
1838
  className: "openpkg-param-name font-mono text-sm font-semibold",
1857
1839
  children: [
@@ -1865,21 +1847,17 @@ function APIParameterItem({
1865
1847
  })
1866
1848
  ]
1867
1849
  }),
1868
- required && /* @__PURE__ */ jsx36("span", {
1869
- className: cn("openpkg-param-badge", "text-[11px] font-medium uppercase tracking-wide", "px-2 py-0.5 rounded", "bg-[var(--openpkg-bg-badge)]", "text-[var(--openpkg-text-muted)]"),
1870
- children: "Required"
1871
- }),
1872
- optional && /* @__PURE__ */ jsx36("span", {
1873
- className: cn("openpkg-param-badge", "text-[11px] font-medium uppercase tracking-wide", "px-2 py-0.5 rounded", "bg-[var(--openpkg-bg-badge)]", "text-[var(--openpkg-text-muted)]"),
1874
- children: "Optional"
1875
- }),
1876
- expandable2 && /* @__PURE__ */ jsx36("span", {
1877
- className: cn("openpkg-badge-expandable", "text-[10px] font-medium", "px-2 py-0.5 rounded", "text-[var(--openpkg-accent-purple)]", "bg-[color-mix(in_srgb,var(--openpkg-accent-purple)_12%,transparent)]"),
1878
- children: "Expandable"
1879
- }),
1880
1850
  /* @__PURE__ */ jsx36("span", {
1881
1851
  className: "openpkg-param-type text-[13px] text-[var(--openpkg-text-muted)]",
1882
1852
  children: type
1853
+ }),
1854
+ required && /* @__PURE__ */ jsx36("span", {
1855
+ className: "openpkg-param-badge text-[13px] font-medium text-[var(--openpkg-accent-orange,#d4a553)]",
1856
+ children: "required"
1857
+ }),
1858
+ optional && /* @__PURE__ */ jsx36("span", {
1859
+ className: "openpkg-param-badge text-[13px] text-[var(--openpkg-text-muted)]",
1860
+ children: "optional"
1883
1861
  })
1884
1862
  ]
1885
1863
  }),
@@ -1901,37 +1879,34 @@ function NestedParameterContainer({
1901
1879
  className
1902
1880
  }) {
1903
1881
  return /* @__PURE__ */ jsx37("div", {
1904
- className: cn("openpkg-nested-container", "border border-t-0", level === 0 ? "border-[var(--openpkg-border-medium)]" : "border-[var(--openpkg-border-subtle)]", "rounded-b-lg", "px-5", "mb-2", "[&>.openpkg-param]:py-5", "[&>.openpkg-param]:border-b", "[&>.openpkg-param]:border-[var(--openpkg-border-subtle)]", "[&>.openpkg-param:last-child]:border-b-0", className),
1882
+ className: cn("openpkg-nested-container", "border border-t-0 border-[var(--openpkg-border-medium)]", "rounded-b-lg", "px-5", "[&>.openpkg-expandable-param]:py-4", "[&>.openpkg-expandable-param]:border-b", "[&>.openpkg-expandable-param]:border-[var(--openpkg-border-subtle)]", "[&>.openpkg-expandable-param:last-child]:border-b-0", "[&>.openpkg-expandable-param:last-child]:pb-4", "[&>.openpkg-expandable-param_.openpkg-param]:py-0", "[&>.openpkg-expandable-param_.openpkg-param]:border-b-0", className),
1905
1883
  "data-level": level,
1906
1884
  children
1907
1885
  });
1908
1886
  }
1909
1887
 
1910
1888
  // src/docskit/api/nested-parameter-toggle.tsx
1911
- import { Plus } from "lucide-react";
1912
1889
  import { jsx as jsx38, jsxs as jsxs20 } from "react/jsx-runtime";
1913
1890
 
1914
1891
  function NestedParameterToggle({
1915
1892
  expanded,
1916
1893
  onToggle,
1917
- count,
1918
1894
  className
1919
1895
  }) {
1920
1896
  return /* @__PURE__ */ jsxs20("button", {
1921
1897
  type: "button",
1922
1898
  onClick: onToggle,
1923
- className: cn("openpkg-nested-toggle", "inline-flex items-center gap-2", "font-sans text-[13px] font-medium", "text-[var(--openpkg-text-secondary)]", "bg-transparent", "border border-[var(--openpkg-border-medium)]", "rounded-lg", "px-4 py-2.5", "mt-3", "cursor-pointer", "transition-all duration-150", "hover:border-[var(--openpkg-text-muted)]", "hover:text-[var(--openpkg-text-primary)]", expanded && "rounded-b-none border-b-transparent mb-0", className),
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),
1924
1900
  "aria-expanded": expanded,
1925
1901
  children: [
1926
- /* @__PURE__ */ jsx38(Plus, {
1927
- size: 12,
1928
- className: cn("transition-transform duration-200", expanded && "rotate-45")
1902
+ /* @__PURE__ */ jsx38("span", {
1903
+ className: "text-[13px]",
1904
+ children: expanded ? "×" : "+"
1929
1905
  }),
1930
1906
  /* @__PURE__ */ jsxs20("span", {
1931
1907
  children: [
1932
1908
  expanded ? "Hide" : "Show",
1933
- " child parameters",
1934
- count !== undefined && ` (${count})`
1909
+ " Child Attributes"
1935
1910
  ]
1936
1911
  })
1937
1912
  ]
@@ -1939,7 +1914,7 @@ function NestedParameterToggle({
1939
1914
  }
1940
1915
 
1941
1916
  // src/docskit/api/expandable-parameter.tsx
1942
- import { jsx as jsx39, jsxs as jsxs21, Fragment as Fragment3 } from "react/jsx-runtime";
1917
+ import { jsx as jsx39, jsxs as jsxs21 } from "react/jsx-runtime";
1943
1918
 
1944
1919
  function ExpandableParameter({
1945
1920
  parameter,
@@ -1971,20 +1946,18 @@ function ExpandableParameter({
1971
1946
  parentPath,
1972
1947
  type: hasChildren ? "object" : type,
1973
1948
  required: isRequired,
1974
- expandable: hasChildren,
1975
1949
  description: parameter.description,
1976
1950
  anchorId: parentPath ? `${parentPath}${parameter.name}` : parameter.name,
1977
- showAnchor: level > 0,
1978
1951
  children: [
1979
1952
  enumValues.length > 0 && !nestedParams.length && /* @__PURE__ */ jsx39(EnumValuesSection, {
1980
1953
  values: enumValues
1981
1954
  }),
1982
- nestedParams.length > 0 && /* @__PURE__ */ jsxs21(Fragment3, {
1955
+ nestedParams.length > 0 && /* @__PURE__ */ jsxs21("div", {
1956
+ className: "mt-3 mb-1",
1983
1957
  children: [
1984
1958
  /* @__PURE__ */ jsx39(NestedParameterToggle, {
1985
1959
  expanded,
1986
- onToggle: handleToggle,
1987
- count: nestedParams.length
1960
+ onToggle: handleToggle
1988
1961
  }),
1989
1962
  expanded && /* @__PURE__ */ jsx39(NestedParameterContainer, {
1990
1963
  level,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openpkg-ts/ui",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
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) */