@openpkg-ts/react 0.2.4 → 0.3.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.
- package/README.md +152 -2
- package/dist/index.js +1 -1
- package/dist/shared/{chunk-j3c78zxw.js → chunk-kpvq09pv.js} +32 -6
- package/dist/styled.d.ts +610 -79
- package/dist/styled.js +1879 -251
- package/package.json +8 -4
package/dist/styled.js
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
getExampleLanguage,
|
|
18
18
|
getExampleTitle,
|
|
19
19
|
groupMembersByKind
|
|
20
|
-
} from "./shared/chunk-
|
|
20
|
+
} from "./shared/chunk-kpvq09pv.js";
|
|
21
21
|
|
|
22
22
|
// ../../node_modules/@swc/helpers/cjs/_interop_require_wildcard.cjs
|
|
23
23
|
var require__interop_require_wildcard = __commonJS((exports) => {
|
|
@@ -3004,7 +3004,7 @@ var require_link = __commonJS((exports, module) => {
|
|
|
3004
3004
|
}
|
|
3005
3005
|
return (0, _formaturl.formatUrl)(urlObjOrString);
|
|
3006
3006
|
}
|
|
3007
|
-
var
|
|
3007
|
+
var Link2 = /* @__PURE__ */ _react3.default.forwardRef(function LinkComponent(props, forwardedRef) {
|
|
3008
3008
|
let children;
|
|
3009
3009
|
const { href: hrefProp, as: asProp, children: childrenProp, prefetch: prefetchProp = null, passHref, replace, shallow, scroll, locale, onClick, onNavigate, onMouseEnter: onMouseEnterProp, onTouchStart: onTouchStartProp, legacyBehavior = false, ...restProps } = props;
|
|
3010
3010
|
children = childrenProp;
|
|
@@ -3063,7 +3063,7 @@ var require_link = __commonJS((exports, module) => {
|
|
|
3063
3063
|
resetVisible,
|
|
3064
3064
|
setIntersectionRef
|
|
3065
3065
|
]);
|
|
3066
|
-
const
|
|
3066
|
+
const setRef2 = (0, _usemergedref.useMergedRef)(setIntersectionWithResetRef, childRef);
|
|
3067
3067
|
_react3.default.useEffect(() => {
|
|
3068
3068
|
if (false) {}
|
|
3069
3069
|
if (!router) {
|
|
@@ -3085,7 +3085,7 @@ var require_link = __commonJS((exports, module) => {
|
|
|
3085
3085
|
router
|
|
3086
3086
|
]);
|
|
3087
3087
|
const childProps = {
|
|
3088
|
-
ref:
|
|
3088
|
+
ref: setRef2,
|
|
3089
3089
|
onClick(e) {
|
|
3090
3090
|
if (false) {}
|
|
3091
3091
|
if (!legacyBehavior && typeof onClick === "function") {
|
|
@@ -3158,7 +3158,7 @@ var require_link = __commonJS((exports, module) => {
|
|
|
3158
3158
|
var useLinkStatus = () => {
|
|
3159
3159
|
return (0, _react3.useContext)(LinkStatusContext);
|
|
3160
3160
|
};
|
|
3161
|
-
var _default =
|
|
3161
|
+
var _default = Link2;
|
|
3162
3162
|
if ((typeof exports.default === "function" || typeof exports.default === "object" && exports.default !== null) && typeof exports.default.__esModule === "undefined") {
|
|
3163
3163
|
Object.defineProperty(exports.default, "__esModule", { value: true });
|
|
3164
3164
|
Object.assign(exports.default, exports);
|
|
@@ -3167,7 +3167,7 @@ var require_link = __commonJS((exports, module) => {
|
|
|
3167
3167
|
});
|
|
3168
3168
|
|
|
3169
3169
|
// src/adapters/spec-to-docskit.ts
|
|
3170
|
-
import { formatSchema } from "@openpkg-ts/sdk";
|
|
3170
|
+
import { formatSchema } from "@openpkg-ts/sdk/browser";
|
|
3171
3171
|
function specSchemaToAPISchema(schema) {
|
|
3172
3172
|
if (!schema || typeof schema !== "object")
|
|
3173
3173
|
return;
|
|
@@ -3298,16 +3298,1620 @@ import {
|
|
|
3298
3298
|
ImportSection
|
|
3299
3299
|
} from "@openpkg-ts/ui/api";
|
|
3300
3300
|
|
|
3301
|
-
// src/components/styled/
|
|
3302
|
-
import {
|
|
3303
|
-
import { APIParameterItem, APISection, ParameterList } from "@openpkg-ts/ui/docskit";
|
|
3301
|
+
// src/components/styled/APIReferenceLayout.tsx
|
|
3302
|
+
import { cn } from "@openpkg-ts/ui/lib/utils";
|
|
3304
3303
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3305
3304
|
|
|
3305
|
+
function APIReferenceLayout({
|
|
3306
|
+
children,
|
|
3307
|
+
examples,
|
|
3308
|
+
className,
|
|
3309
|
+
leftWidth = "58%",
|
|
3310
|
+
rightWidth = "42%"
|
|
3311
|
+
}) {
|
|
3312
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
3313
|
+
className: cn("openpkg-api-layout", "max-w-[1600px] mx-auto", "flex flex-col", "lg:grid", className),
|
|
3314
|
+
style: {
|
|
3315
|
+
"--openpkg-left-width": leftWidth,
|
|
3316
|
+
"--openpkg-right-width": rightWidth
|
|
3317
|
+
},
|
|
3318
|
+
children: [
|
|
3319
|
+
/* @__PURE__ */ jsx("div", {
|
|
3320
|
+
className: cn("openpkg-api-layout-left", "py-8 px-4", "sm:py-10 sm:px-6", "lg:py-12 lg:px-12 lg:pl-16", "lg:border-r lg:border-[var(--openpkg-border-subtle,#262626)]", "openpkg-animate-fade-in"),
|
|
3321
|
+
style: {
|
|
3322
|
+
gridColumn: "1"
|
|
3323
|
+
},
|
|
3324
|
+
children
|
|
3325
|
+
}),
|
|
3326
|
+
/* @__PURE__ */ jsx("div", {
|
|
3327
|
+
className: cn("openpkg-api-layout-right", "border-t border-[var(--openpkg-border-subtle,#262626)] lg:border-t-0", "py-8 px-4", "sm:py-10 sm:px-6", "lg:sticky lg:top-0 lg:h-screen lg:overflow-y-auto", "lg:py-12 lg:px-12 lg:pl-8", "bg-[var(--openpkg-bg-root,#0c0c0c)]", "openpkg-animate-fade-in"),
|
|
3328
|
+
style: {
|
|
3329
|
+
gridColumn: "2",
|
|
3330
|
+
animationDelay: "100ms"
|
|
3331
|
+
},
|
|
3332
|
+
children: examples
|
|
3333
|
+
}),
|
|
3334
|
+
/* @__PURE__ */ jsx("style", {
|
|
3335
|
+
dangerouslySetInnerHTML: {
|
|
3336
|
+
__html: `
|
|
3337
|
+
@media (min-width: 1024px) {
|
|
3338
|
+
.openpkg-api-layout {
|
|
3339
|
+
grid-template-columns: var(--openpkg-left-width, 58%) var(--openpkg-right-width, 42%);
|
|
3340
|
+
align-items: start;
|
|
3341
|
+
}
|
|
3342
|
+
}
|
|
3343
|
+
`
|
|
3344
|
+
}
|
|
3345
|
+
})
|
|
3346
|
+
]
|
|
3347
|
+
});
|
|
3348
|
+
}
|
|
3349
|
+
// src/components/styled/SyncScrollProvider.tsx
|
|
3350
|
+
import {
|
|
3351
|
+
createContext,
|
|
3352
|
+
useCallback,
|
|
3353
|
+
useContext,
|
|
3354
|
+
useEffect,
|
|
3355
|
+
useMemo,
|
|
3356
|
+
useRef,
|
|
3357
|
+
useState
|
|
3358
|
+
} from "react";
|
|
3359
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
3360
|
+
|
|
3361
|
+
var SyncScrollContext = createContext(null);
|
|
3362
|
+
function SyncScrollProvider({
|
|
3363
|
+
children,
|
|
3364
|
+
rootMargin = "-20% 0px -60% 0px",
|
|
3365
|
+
scrollBehavior = "smooth"
|
|
3366
|
+
}) {
|
|
3367
|
+
const [activeSection, setActiveSection] = useState(null);
|
|
3368
|
+
const sectionsRef = useRef(new Map);
|
|
3369
|
+
const rightColumnRef = useRef(null);
|
|
3370
|
+
const isScrollingRef = useRef(false);
|
|
3371
|
+
const registerSection = useCallback((id, ref) => {
|
|
3372
|
+
sectionsRef.current.set(id, ref);
|
|
3373
|
+
}, []);
|
|
3374
|
+
const unregisterSection = useCallback((id) => {
|
|
3375
|
+
sectionsRef.current.delete(id);
|
|
3376
|
+
}, []);
|
|
3377
|
+
const registerRightColumn = useCallback((ref) => {
|
|
3378
|
+
rightColumnRef.current = ref;
|
|
3379
|
+
}, []);
|
|
3380
|
+
const scrollToSection = useCallback((id) => {
|
|
3381
|
+
const rightColumn = rightColumnRef.current?.current;
|
|
3382
|
+
if (!rightColumn)
|
|
3383
|
+
return;
|
|
3384
|
+
const targetExample = rightColumn.querySelector(`[data-section="${id}"]`);
|
|
3385
|
+
if (targetExample instanceof HTMLElement) {
|
|
3386
|
+
const targetTop = targetExample.offsetTop - 48;
|
|
3387
|
+
rightColumn.scrollTo({ top: targetTop, behavior: scrollBehavior });
|
|
3388
|
+
}
|
|
3389
|
+
}, [scrollBehavior]);
|
|
3390
|
+
useEffect(() => {
|
|
3391
|
+
if (typeof window === "undefined")
|
|
3392
|
+
return;
|
|
3393
|
+
const handleIntersect = (entries) => {
|
|
3394
|
+
if (isScrollingRef.current)
|
|
3395
|
+
return;
|
|
3396
|
+
for (const entry of entries) {
|
|
3397
|
+
if (entry.isIntersecting) {
|
|
3398
|
+
const sectionId = entry.target.getAttribute("data-section");
|
|
3399
|
+
if (sectionId) {
|
|
3400
|
+
setActiveSection(sectionId);
|
|
3401
|
+
scrollToSection(sectionId);
|
|
3402
|
+
}
|
|
3403
|
+
break;
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3406
|
+
};
|
|
3407
|
+
const observer = new IntersectionObserver(handleIntersect, {
|
|
3408
|
+
rootMargin,
|
|
3409
|
+
threshold: 0
|
|
3410
|
+
});
|
|
3411
|
+
for (const [_id, ref] of sectionsRef.current) {
|
|
3412
|
+
if (ref.current) {
|
|
3413
|
+
observer.observe(ref.current);
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
return () => {
|
|
3417
|
+
observer.disconnect();
|
|
3418
|
+
};
|
|
3419
|
+
}, [rootMargin, scrollToSection]);
|
|
3420
|
+
const value = useMemo(() => ({
|
|
3421
|
+
activeSection,
|
|
3422
|
+
registerSection,
|
|
3423
|
+
unregisterSection,
|
|
3424
|
+
scrollToSection,
|
|
3425
|
+
registerRightColumn
|
|
3426
|
+
}), [activeSection, registerSection, unregisterSection, scrollToSection, registerRightColumn]);
|
|
3427
|
+
return /* @__PURE__ */ jsx2(SyncScrollContext.Provider, {
|
|
3428
|
+
value,
|
|
3429
|
+
children
|
|
3430
|
+
});
|
|
3431
|
+
}
|
|
3432
|
+
function useSyncScroll() {
|
|
3433
|
+
const context = useContext(SyncScrollContext);
|
|
3434
|
+
if (!context) {
|
|
3435
|
+
throw new Error("useSyncScroll must be used within SyncScrollProvider");
|
|
3436
|
+
}
|
|
3437
|
+
return context;
|
|
3438
|
+
}
|
|
3439
|
+
function useSyncSection(id) {
|
|
3440
|
+
const { registerSection, unregisterSection } = useSyncScroll();
|
|
3441
|
+
const ref = useRef(null);
|
|
3442
|
+
useEffect(() => {
|
|
3443
|
+
registerSection(id, ref);
|
|
3444
|
+
return () => unregisterSection(id);
|
|
3445
|
+
}, [id, registerSection, unregisterSection]);
|
|
3446
|
+
return ref;
|
|
3447
|
+
}
|
|
3448
|
+
// src/components/styled/MethodSection.tsx
|
|
3449
|
+
import { cn as cn2 } from "@openpkg-ts/ui/lib/utils";
|
|
3450
|
+
import { useEffect as useEffect2, useRef as useRef2 } from "react";
|
|
3451
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
3452
|
+
|
|
3453
|
+
function MethodSection({
|
|
3454
|
+
id,
|
|
3455
|
+
title,
|
|
3456
|
+
signature,
|
|
3457
|
+
description,
|
|
3458
|
+
notes,
|
|
3459
|
+
children,
|
|
3460
|
+
className
|
|
3461
|
+
}) {
|
|
3462
|
+
const ref = useRef2(null);
|
|
3463
|
+
const syncScroll = useSyncScrollSafe();
|
|
3464
|
+
useEffect2(() => {
|
|
3465
|
+
if (syncScroll && ref.current) {
|
|
3466
|
+
syncScroll.registerSection(id, ref);
|
|
3467
|
+
return () => syncScroll.unregisterSection(id);
|
|
3468
|
+
}
|
|
3469
|
+
}, [id, syncScroll]);
|
|
3470
|
+
return /* @__PURE__ */ jsxs2("section", {
|
|
3471
|
+
ref,
|
|
3472
|
+
id,
|
|
3473
|
+
"data-section": id,
|
|
3474
|
+
className: cn2("openpkg-method-section", "mb-20 last:mb-0", className),
|
|
3475
|
+
children: [
|
|
3476
|
+
/* @__PURE__ */ jsx3("h2", {
|
|
3477
|
+
className: cn2("text-2xl font-semibold tracking-tight", "text-[var(--openpkg-text-primary,#ededed)]", "mb-4"),
|
|
3478
|
+
children: title
|
|
3479
|
+
}),
|
|
3480
|
+
signature && /* @__PURE__ */ jsx3("code", {
|
|
3481
|
+
className: cn2("block font-mono text-sm", "text-[var(--openpkg-text-muted,#666666)]", "mb-6"),
|
|
3482
|
+
children: signature
|
|
3483
|
+
}),
|
|
3484
|
+
description && /* @__PURE__ */ jsx3("div", {
|
|
3485
|
+
className: cn2("openpkg-method-description", "text-[15px] leading-relaxed", "text-[var(--openpkg-text-secondary,#a0a0a0)]", "mb-6", "[&_a]:text-[var(--openpkg-accent-link,#6cb6ff)] [&_a]:no-underline [&_a]:font-medium hover:[&_a]:underline", "[&_code]:bg-[var(--openpkg-bg-badge,#262626)] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded [&_code]:font-mono [&_code]:text-[13px]"),
|
|
3486
|
+
children: typeof description === "string" ? /* @__PURE__ */ jsx3("p", {
|
|
3487
|
+
children: description
|
|
3488
|
+
}) : description
|
|
3489
|
+
}),
|
|
3490
|
+
notes && notes.length > 0 && /* @__PURE__ */ jsx3("ul", {
|
|
3491
|
+
className: cn2("openpkg-method-notes", "list-disc list-inside", "text-[15px] leading-relaxed", "text-[var(--openpkg-text-secondary,#a0a0a0)]", "mb-8 space-y-2"),
|
|
3492
|
+
children: notes.map((note, i) => /* @__PURE__ */ jsx3("li", {
|
|
3493
|
+
children: note
|
|
3494
|
+
}, i))
|
|
3495
|
+
}),
|
|
3496
|
+
children && /* @__PURE__ */ jsxs2("div", {
|
|
3497
|
+
className: "openpkg-method-params",
|
|
3498
|
+
children: [
|
|
3499
|
+
/* @__PURE__ */ jsx3("h3", {
|
|
3500
|
+
className: cn2("text-xs font-semibold uppercase tracking-wider", "text-[var(--openpkg-text-muted,#666666)]", "mb-4 pb-2", "border-b border-[var(--openpkg-border-subtle,#262626)]"),
|
|
3501
|
+
children: "Parameters"
|
|
3502
|
+
}),
|
|
3503
|
+
children
|
|
3504
|
+
]
|
|
3505
|
+
})
|
|
3506
|
+
]
|
|
3507
|
+
});
|
|
3508
|
+
}
|
|
3509
|
+
function useSyncScrollSafe() {
|
|
3510
|
+
try {
|
|
3511
|
+
return useSyncScroll();
|
|
3512
|
+
} catch {
|
|
3513
|
+
return null;
|
|
3514
|
+
}
|
|
3515
|
+
}
|
|
3516
|
+
// src/components/styled/APIParameterItem.tsx
|
|
3517
|
+
import { cn as cn3 } from "@openpkg-ts/ui/lib/utils";
|
|
3518
|
+
import { Link } from "lucide-react";
|
|
3519
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
3520
|
+
|
|
3521
|
+
function APIParameterItem({
|
|
3522
|
+
name,
|
|
3523
|
+
parentPath,
|
|
3524
|
+
type,
|
|
3525
|
+
required,
|
|
3526
|
+
optional,
|
|
3527
|
+
expandable,
|
|
3528
|
+
description,
|
|
3529
|
+
children,
|
|
3530
|
+
anchorId,
|
|
3531
|
+
showAnchor = false,
|
|
3532
|
+
className
|
|
3533
|
+
}) {
|
|
3534
|
+
const handleAnchorClick = () => {
|
|
3535
|
+
if (anchorId && typeof window !== "undefined") {
|
|
3536
|
+
window.location.hash = anchorId;
|
|
3537
|
+
navigator.clipboard?.writeText(window.location.href);
|
|
3538
|
+
}
|
|
3539
|
+
};
|
|
3540
|
+
return /* @__PURE__ */ jsxs3("div", {
|
|
3541
|
+
id: anchorId,
|
|
3542
|
+
className: cn3("openpkg-param", "py-5 border-b border-[var(--openpkg-border-subtle,#262626)]", "last:border-b-0", className),
|
|
3543
|
+
children: [
|
|
3544
|
+
/* @__PURE__ */ jsxs3("div", {
|
|
3545
|
+
className: "openpkg-param-header flex items-center gap-2.5 mb-2 flex-wrap",
|
|
3546
|
+
children: [
|
|
3547
|
+
showAnchor && /* @__PURE__ */ jsx4("button", {
|
|
3548
|
+
type: "button",
|
|
3549
|
+
onClick: handleAnchorClick,
|
|
3550
|
+
className: cn3("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,#666666)]", "hover:text-[var(--openpkg-accent-blue,#6cb6ff)]", "cursor-pointer transition-opacity"),
|
|
3551
|
+
"aria-label": "Copy link",
|
|
3552
|
+
children: /* @__PURE__ */ jsx4(Link, {
|
|
3553
|
+
size: 14
|
|
3554
|
+
})
|
|
3555
|
+
}),
|
|
3556
|
+
/* @__PURE__ */ jsxs3("span", {
|
|
3557
|
+
className: "openpkg-param-name font-mono text-sm font-semibold",
|
|
3558
|
+
children: [
|
|
3559
|
+
parentPath && /* @__PURE__ */ jsx4("span", {
|
|
3560
|
+
className: "text-[var(--openpkg-text-muted,#666666)]",
|
|
3561
|
+
children: parentPath
|
|
3562
|
+
}),
|
|
3563
|
+
/* @__PURE__ */ jsx4("span", {
|
|
3564
|
+
className: "text-[var(--openpkg-text-primary,#ededed)]",
|
|
3565
|
+
children: name
|
|
3566
|
+
})
|
|
3567
|
+
]
|
|
3568
|
+
}),
|
|
3569
|
+
required && /* @__PURE__ */ jsx4("span", {
|
|
3570
|
+
className: cn3("openpkg-param-badge", "text-[11px] font-medium uppercase tracking-wide", "px-2 py-0.5 rounded", "bg-[var(--openpkg-bg-badge,#262626)]", "text-[var(--openpkg-text-muted,#666666)]"),
|
|
3571
|
+
children: "Required"
|
|
3572
|
+
}),
|
|
3573
|
+
optional && /* @__PURE__ */ jsx4("span", {
|
|
3574
|
+
className: cn3("openpkg-param-badge", "text-[11px] font-medium uppercase tracking-wide", "px-2 py-0.5 rounded", "bg-[var(--openpkg-bg-badge,#262626)]", "text-[var(--openpkg-text-muted,#666666)]"),
|
|
3575
|
+
children: "Optional"
|
|
3576
|
+
}),
|
|
3577
|
+
expandable && /* @__PURE__ */ jsx4("span", {
|
|
3578
|
+
className: cn3("openpkg-badge-expandable", "text-[10px] font-medium", "px-2 py-0.5 rounded", "text-[var(--openpkg-accent-purple,#c4a7e7)]", "bg-[rgba(196,167,231,0.12)]"),
|
|
3579
|
+
children: "Expandable"
|
|
3580
|
+
}),
|
|
3581
|
+
/* @__PURE__ */ jsx4("span", {
|
|
3582
|
+
className: "openpkg-param-type text-[13px] text-[var(--openpkg-text-muted,#666666)]",
|
|
3583
|
+
children: type
|
|
3584
|
+
})
|
|
3585
|
+
]
|
|
3586
|
+
}),
|
|
3587
|
+
description && /* @__PURE__ */ jsx4("p", {
|
|
3588
|
+
className: cn3("openpkg-param-description", "text-sm text-[var(--openpkg-text-secondary,#a0a0a0)]", "leading-relaxed", "[&_code]:font-mono [&_code]:text-[13px] [&_code]:bg-[var(--openpkg-bg-badge,#262626)] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded"),
|
|
3589
|
+
children: description
|
|
3590
|
+
}),
|
|
3591
|
+
children
|
|
3592
|
+
]
|
|
3593
|
+
});
|
|
3594
|
+
}
|
|
3595
|
+
// src/components/styled/NestedParameterToggle.tsx
|
|
3596
|
+
import { cn as cn4 } from "@openpkg-ts/ui/lib/utils";
|
|
3597
|
+
import { Plus } from "lucide-react";
|
|
3598
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
3599
|
+
|
|
3600
|
+
function NestedParameterToggle({
|
|
3601
|
+
expanded,
|
|
3602
|
+
onToggle,
|
|
3603
|
+
count,
|
|
3604
|
+
className
|
|
3605
|
+
}) {
|
|
3606
|
+
return /* @__PURE__ */ jsxs4("button", {
|
|
3607
|
+
type: "button",
|
|
3608
|
+
onClick: onToggle,
|
|
3609
|
+
className: cn4("openpkg-nested-toggle", "inline-flex items-center gap-2", "font-sans text-[13px] font-medium", "text-[var(--openpkg-text-secondary,#a0a0a0)]", "bg-transparent", "border border-[var(--openpkg-border-medium,#333333)]", "rounded-lg", "px-4 py-2.5", "mt-3", "cursor-pointer", "transition-all duration-150", "hover:border-[var(--openpkg-text-muted,#666666)]", "hover:text-[var(--openpkg-text-primary,#ededed)]", expanded && "rounded-b-none border-b-transparent mb-0", className),
|
|
3610
|
+
"aria-expanded": expanded,
|
|
3611
|
+
children: [
|
|
3612
|
+
/* @__PURE__ */ jsx5(Plus, {
|
|
3613
|
+
size: 12,
|
|
3614
|
+
className: cn4("transition-transform duration-200", expanded && "rotate-45")
|
|
3615
|
+
}),
|
|
3616
|
+
/* @__PURE__ */ jsxs4("span", {
|
|
3617
|
+
children: [
|
|
3618
|
+
expanded ? "Hide" : "Show",
|
|
3619
|
+
" child parameters",
|
|
3620
|
+
count !== undefined && ` (${count})`
|
|
3621
|
+
]
|
|
3622
|
+
})
|
|
3623
|
+
]
|
|
3624
|
+
});
|
|
3625
|
+
}
|
|
3626
|
+
// src/components/styled/NestedParameterContainer.tsx
|
|
3627
|
+
import { cn as cn5 } from "@openpkg-ts/ui/lib/utils";
|
|
3628
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
3629
|
+
|
|
3630
|
+
function NestedParameterContainer({
|
|
3631
|
+
children,
|
|
3632
|
+
level = 0,
|
|
3633
|
+
className
|
|
3634
|
+
}) {
|
|
3635
|
+
return /* @__PURE__ */ jsx6("div", {
|
|
3636
|
+
className: cn5("openpkg-nested-container", "border border-t-0", level === 0 ? "border-[var(--openpkg-border-medium,#333333)]" : "border-[var(--openpkg-border-subtle,#262626)]", "rounded-b-lg", "px-5", "mb-2", "[&>.openpkg-param]:py-5", "[&>.openpkg-param]:border-b", "[&>.openpkg-param]:border-[var(--openpkg-border-subtle,#262626)]", "[&>.openpkg-param:last-child]:border-b-0", className),
|
|
3637
|
+
"data-level": level,
|
|
3638
|
+
children
|
|
3639
|
+
});
|
|
3640
|
+
}
|
|
3641
|
+
// src/components/styled/ExpandableParameter.tsx
|
|
3642
|
+
import { formatSchema as formatSchema2 } from "@openpkg-ts/sdk/browser";
|
|
3643
|
+
import { cn as cn7 } from "@openpkg-ts/ui/lib/utils";
|
|
3644
|
+
import { useState as useState2 } from "react";
|
|
3645
|
+
|
|
3646
|
+
// src/components/styled/EnumValuesSection.tsx
|
|
3647
|
+
import { cn as cn6 } from "@openpkg-ts/ui/lib/utils";
|
|
3648
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
3649
|
+
|
|
3650
|
+
function EnumValuesSection({
|
|
3651
|
+
values,
|
|
3652
|
+
header = "Possible values",
|
|
3653
|
+
className
|
|
3654
|
+
}) {
|
|
3655
|
+
if (values.length === 0)
|
|
3656
|
+
return null;
|
|
3657
|
+
return /* @__PURE__ */ jsxs5("div", {
|
|
3658
|
+
className: cn6("openpkg-enum-section", "mt-3", className),
|
|
3659
|
+
children: [
|
|
3660
|
+
/* @__PURE__ */ jsx7("div", {
|
|
3661
|
+
className: cn6("openpkg-enum-header", "text-[11px] font-medium", "text-[var(--openpkg-text-muted,#666666)]", "mb-2.5 pb-2", "border-b border-[var(--openpkg-border-subtle,#262626)]"),
|
|
3662
|
+
children: header
|
|
3663
|
+
}),
|
|
3664
|
+
/* @__PURE__ */ jsx7("div", {
|
|
3665
|
+
className: "openpkg-enum-values flex flex-col gap-0.5",
|
|
3666
|
+
children: values.map((item) => /* @__PURE__ */ jsxs5("div", {
|
|
3667
|
+
className: cn6("openpkg-enum-value", "py-2.5 px-3", "bg-[rgba(255,255,255,0.015)]", "rounded"),
|
|
3668
|
+
children: [
|
|
3669
|
+
/* @__PURE__ */ jsx7("span", {
|
|
3670
|
+
className: cn6("openpkg-enum-value-name", "font-mono text-xs font-medium", "text-[var(--openpkg-syn-string,#9ccfd8)]", "bg-[rgba(156,207,216,0.1)]", "px-1.5 py-0.5 rounded", "inline-block mb-1"),
|
|
3671
|
+
children: item.value
|
|
3672
|
+
}),
|
|
3673
|
+
item.description && /* @__PURE__ */ jsx7("p", {
|
|
3674
|
+
className: cn6("openpkg-enum-value-description", "text-xs text-[var(--openpkg-text-secondary,#a0a0a0)]", "leading-relaxed", "[&_code]:font-mono [&_code]:text-[11px] [&_code]:bg-[var(--openpkg-bg-badge,#262626)] [&_code]:px-1 [&_code]:py-0.5 [&_code]:rounded"),
|
|
3675
|
+
children: item.description
|
|
3676
|
+
})
|
|
3677
|
+
]
|
|
3678
|
+
}, item.value))
|
|
3679
|
+
})
|
|
3680
|
+
]
|
|
3681
|
+
});
|
|
3682
|
+
}
|
|
3683
|
+
|
|
3684
|
+
// src/components/styled/ExpandableParameter.tsx
|
|
3685
|
+
import { jsx as jsx8, jsxs as jsxs6, Fragment } from "react/jsx-runtime";
|
|
3686
|
+
|
|
3687
|
+
function ExpandableParameter({
|
|
3688
|
+
parameter,
|
|
3689
|
+
parentPath,
|
|
3690
|
+
defaultExpanded = false,
|
|
3691
|
+
expanded: controlledExpanded,
|
|
3692
|
+
onExpandedChange,
|
|
3693
|
+
level = 0,
|
|
3694
|
+
className
|
|
3695
|
+
}) {
|
|
3696
|
+
const [internalExpanded, setInternalExpanded] = useState2(defaultExpanded);
|
|
3697
|
+
const isControlled = controlledExpanded !== undefined;
|
|
3698
|
+
const expanded = isControlled ? controlledExpanded : internalExpanded;
|
|
3699
|
+
const handleToggle = () => {
|
|
3700
|
+
const newValue = !expanded;
|
|
3701
|
+
if (isControlled) {
|
|
3702
|
+
onExpandedChange?.(newValue);
|
|
3703
|
+
} else {
|
|
3704
|
+
setInternalExpanded(newValue);
|
|
3705
|
+
}
|
|
3706
|
+
};
|
|
3707
|
+
const { nestedParams, enumValues, hasChildren } = extractSchemaInfo(parameter.schema);
|
|
3708
|
+
const type = formatSchema2(parameter.schema);
|
|
3709
|
+
const isRequired = parameter.required !== false;
|
|
3710
|
+
return /* @__PURE__ */ jsx8("div", {
|
|
3711
|
+
className: cn7("openpkg-expandable-param", className),
|
|
3712
|
+
children: /* @__PURE__ */ jsxs6(APIParameterItem, {
|
|
3713
|
+
name: parameter.name,
|
|
3714
|
+
parentPath,
|
|
3715
|
+
type: hasChildren ? "object" : type,
|
|
3716
|
+
required: isRequired,
|
|
3717
|
+
expandable: hasChildren,
|
|
3718
|
+
description: parameter.description,
|
|
3719
|
+
anchorId: parentPath ? `${parentPath}${parameter.name}` : parameter.name,
|
|
3720
|
+
showAnchor: level > 0,
|
|
3721
|
+
children: [
|
|
3722
|
+
enumValues.length > 0 && !nestedParams.length && /* @__PURE__ */ jsx8(EnumValuesSection, {
|
|
3723
|
+
values: enumValues
|
|
3724
|
+
}),
|
|
3725
|
+
nestedParams.length > 0 && /* @__PURE__ */ jsxs6(Fragment, {
|
|
3726
|
+
children: [
|
|
3727
|
+
/* @__PURE__ */ jsx8(NestedParameterToggle, {
|
|
3728
|
+
expanded,
|
|
3729
|
+
onToggle: handleToggle,
|
|
3730
|
+
count: nestedParams.length
|
|
3731
|
+
}),
|
|
3732
|
+
expanded && /* @__PURE__ */ jsx8(NestedParameterContainer, {
|
|
3733
|
+
level,
|
|
3734
|
+
children: nestedParams.map((nested) => /* @__PURE__ */ jsx8(ExpandableParameter, {
|
|
3735
|
+
parameter: nested,
|
|
3736
|
+
parentPath: `${parameter.name}.`,
|
|
3737
|
+
level: level + 1
|
|
3738
|
+
}, nested.name))
|
|
3739
|
+
})
|
|
3740
|
+
]
|
|
3741
|
+
})
|
|
3742
|
+
]
|
|
3743
|
+
})
|
|
3744
|
+
});
|
|
3745
|
+
}
|
|
3746
|
+
function extractSchemaInfo(schema) {
|
|
3747
|
+
const result = {
|
|
3748
|
+
nestedParams: [],
|
|
3749
|
+
enumValues: [],
|
|
3750
|
+
hasChildren: false
|
|
3751
|
+
};
|
|
3752
|
+
if (!schema || typeof schema !== "object")
|
|
3753
|
+
return result;
|
|
3754
|
+
const s = schema;
|
|
3755
|
+
if (s.type === "object" && s.properties && typeof s.properties === "object") {
|
|
3756
|
+
const props = s.properties;
|
|
3757
|
+
const required = Array.isArray(s.required) ? s.required : [];
|
|
3758
|
+
for (const [name, propSchema] of Object.entries(props)) {
|
|
3759
|
+
result.nestedParams.push({
|
|
3760
|
+
name,
|
|
3761
|
+
schema: propSchema,
|
|
3762
|
+
required: required.includes(name),
|
|
3763
|
+
description: propSchema?.description
|
|
3764
|
+
});
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3767
|
+
if (Array.isArray(s.enum)) {
|
|
3768
|
+
result.enumValues = s.enum.map((value) => ({
|
|
3769
|
+
value: String(value),
|
|
3770
|
+
description: undefined
|
|
3771
|
+
}));
|
|
3772
|
+
}
|
|
3773
|
+
result.hasChildren = result.nestedParams.length > 0 || result.enumValues.length > 0;
|
|
3774
|
+
return result;
|
|
3775
|
+
}
|
|
3776
|
+
// src/components/styled/ExampleChips.tsx
|
|
3777
|
+
import { cn as cn8 } from "@openpkg-ts/ui/lib/utils";
|
|
3778
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
3779
|
+
|
|
3780
|
+
function ExampleChips({
|
|
3781
|
+
examples,
|
|
3782
|
+
activeId,
|
|
3783
|
+
onSelect,
|
|
3784
|
+
className
|
|
3785
|
+
}) {
|
|
3786
|
+
return /* @__PURE__ */ jsx9("div", {
|
|
3787
|
+
className: cn8("openpkg-example-chips", "flex flex-wrap gap-2 mb-5", className),
|
|
3788
|
+
children: examples.map((example) => {
|
|
3789
|
+
const isActive = example.id === activeId;
|
|
3790
|
+
return /* @__PURE__ */ jsx9("button", {
|
|
3791
|
+
type: "button",
|
|
3792
|
+
onClick: () => onSelect(example.id),
|
|
3793
|
+
className: cn8("openpkg-example-chip", "text-xs font-medium", "px-3 py-1.5", "border rounded-md", "cursor-pointer", "transition-all duration-150", isActive ? [
|
|
3794
|
+
"border-[var(--openpkg-border-chip-active,#666666)]",
|
|
3795
|
+
"text-[var(--openpkg-text-primary,#ededed)]",
|
|
3796
|
+
"bg-[var(--openpkg-bg-tertiary,#1c1c1c)]"
|
|
3797
|
+
] : [
|
|
3798
|
+
"border-[var(--openpkg-border-chip,#333333)]",
|
|
3799
|
+
"text-[var(--openpkg-text-secondary,#a0a0a0)]",
|
|
3800
|
+
"bg-transparent",
|
|
3801
|
+
"hover:border-[var(--openpkg-text-muted,#666666)]",
|
|
3802
|
+
"hover:text-[var(--openpkg-text-primary,#ededed)]"
|
|
3803
|
+
]),
|
|
3804
|
+
"aria-pressed": isActive,
|
|
3805
|
+
children: example.label
|
|
3806
|
+
}, example.id);
|
|
3807
|
+
})
|
|
3808
|
+
});
|
|
3809
|
+
}
|
|
3810
|
+
// src/components/styled/CodePanel.tsx
|
|
3811
|
+
import { cn as cn9 } from "@openpkg-ts/ui/lib/utils";
|
|
3812
|
+
import { useMemo as useMemo2 } from "react";
|
|
3813
|
+
import { jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3814
|
+
|
|
3815
|
+
function CodePanel({
|
|
3816
|
+
code,
|
|
3817
|
+
language = "typescript",
|
|
3818
|
+
showLineNumbers = false,
|
|
3819
|
+
className
|
|
3820
|
+
}) {
|
|
3821
|
+
const lines = useMemo2(() => code.split(`
|
|
3822
|
+
`), [code]);
|
|
3823
|
+
const highlightedLines = useMemo2(() => lines.map((line) => highlightLine(line, language)), [lines, language]);
|
|
3824
|
+
return /* @__PURE__ */ jsx10("div", {
|
|
3825
|
+
className: cn9("openpkg-code-panel", "bg-[var(--openpkg-bg-code,#0f0f18)]", "border border-[var(--openpkg-border-subtle,#262626)]", "rounded-lg overflow-hidden", "mb-3", className),
|
|
3826
|
+
children: /* @__PURE__ */ jsx10("div", {
|
|
3827
|
+
className: "openpkg-code-block p-5 overflow-x-auto",
|
|
3828
|
+
children: /* @__PURE__ */ jsx10("pre", {
|
|
3829
|
+
className: cn9("font-mono text-[13px] leading-relaxed", "text-[var(--openpkg-text-code,#e4e4e7)]", "m-0"),
|
|
3830
|
+
children: highlightedLines.map((html, i) => /* @__PURE__ */ jsxs7("div", {
|
|
3831
|
+
className: "openpkg-code-line flex",
|
|
3832
|
+
children: [
|
|
3833
|
+
showLineNumbers && /* @__PURE__ */ jsx10("span", {
|
|
3834
|
+
className: cn9("openpkg-line-number", "w-7 shrink-0", "text-[var(--openpkg-text-muted,#666666)]", "text-right pr-5", "select-none opacity-50"),
|
|
3835
|
+
children: i + 1
|
|
3836
|
+
}),
|
|
3837
|
+
/* @__PURE__ */ jsx10("span", {
|
|
3838
|
+
className: "openpkg-line-content flex-1",
|
|
3839
|
+
dangerouslySetInnerHTML: { __html: html }
|
|
3840
|
+
})
|
|
3841
|
+
]
|
|
3842
|
+
}, i))
|
|
3843
|
+
})
|
|
3844
|
+
})
|
|
3845
|
+
});
|
|
3846
|
+
}
|
|
3847
|
+
function highlightLine(line, language) {
|
|
3848
|
+
if (!line.trim())
|
|
3849
|
+
return " ";
|
|
3850
|
+
let result = escapeHtml(line);
|
|
3851
|
+
if (language === "typescript" || language === "javascript" || language === "ts" || language === "js") {
|
|
3852
|
+
result = highlightTS(result);
|
|
3853
|
+
} else if (language === "json") {
|
|
3854
|
+
result = highlightJSON(result);
|
|
3855
|
+
} else if (language === "sql") {
|
|
3856
|
+
result = highlightSQL(result);
|
|
3857
|
+
}
|
|
3858
|
+
return result;
|
|
3859
|
+
}
|
|
3860
|
+
function escapeHtml(str) {
|
|
3861
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
3862
|
+
}
|
|
3863
|
+
function highlightTS(line) {
|
|
3864
|
+
line = line.replace(/(\/\/.*$)/g, '<span class="openpkg-syn-comment" style="color:var(--openpkg-syn-comment,#6e6a86);font-style:italic">$1</span>');
|
|
3865
|
+
line = line.replace(/('[^&#]*'|"[^&]*"|`[^`]*`)/g, '<span class="openpkg-syn-string" style="color:var(--openpkg-syn-string,#9ccfd8)">$1</span>');
|
|
3866
|
+
const keywords = /\b(import|export|from|const|let|var|function|async|await|return|if|else|for|while|class|interface|type|extends|implements|new|this|true|false|null|undefined)\b/g;
|
|
3867
|
+
line = line.replace(keywords, '<span class="openpkg-syn-keyword" style="color:var(--openpkg-syn-keyword,#c4a7e7)">$1</span>');
|
|
3868
|
+
line = line.replace(/\b([a-zA-Z_][a-zA-Z0-9_]*)\s*(?=\()/g, '<span class="openpkg-syn-function" style="color:var(--openpkg-syn-function,#ebbcba)">$1</span>');
|
|
3869
|
+
line = line.replace(/\b(\d+\.?\d*)\b/g, '<span class="openpkg-syn-number" style="color:var(--openpkg-syn-number,#f6c177)">$1</span>');
|
|
3870
|
+
line = line.replace(/([{}[\]();:,.])/g, '<span class="openpkg-syn-punctuation" style="color:var(--openpkg-syn-punctuation,#6e6a86)">$1</span>');
|
|
3871
|
+
return line;
|
|
3872
|
+
}
|
|
3873
|
+
function highlightJSON(line) {
|
|
3874
|
+
line = line.replace(/("[^&]+")\s*:/g, '<span class="openpkg-syn-property" style="color:var(--openpkg-syn-property,#c4a7e7)">$1</span>:');
|
|
3875
|
+
line = line.replace(/:\s*("[^&]*")/g, ': <span class="openpkg-syn-string" style="color:var(--openpkg-syn-string,#9ccfd8)">$1</span>');
|
|
3876
|
+
line = line.replace(/:\s*(\d+\.?\d*)/g, ': <span class="openpkg-syn-number" style="color:var(--openpkg-syn-number,#f6c177)">$1</span>');
|
|
3877
|
+
line = line.replace(/:\s*(true|false)/g, ': <span class="openpkg-syn-boolean" style="color:var(--openpkg-syn-boolean,#eb6f92)">$1</span>');
|
|
3878
|
+
line = line.replace(/:\s*(null)/g, ': <span class="openpkg-syn-keyword" style="color:var(--openpkg-syn-keyword,#c4a7e7)">$1</span>');
|
|
3879
|
+
line = line.replace(/([{}[\]:,])/g, '<span class="openpkg-syn-punctuation" style="color:var(--openpkg-syn-punctuation,#6e6a86)">$1</span>');
|
|
3880
|
+
return line;
|
|
3881
|
+
}
|
|
3882
|
+
function highlightSQL(line) {
|
|
3883
|
+
const keywords = /\b(SELECT|FROM|WHERE|AND|OR|INSERT|INTO|VALUES|UPDATE|SET|DELETE|CREATE|TABLE|INDEX|DROP|ALTER|JOIN|LEFT|RIGHT|INNER|OUTER|ON|AS|ORDER|BY|GROUP|HAVING|LIMIT|OFFSET|PRIMARY|KEY|FOREIGN|REFERENCES|NOT|NULL|DEFAULT|UNIQUE|CHECK|CONSTRAINT)\b/gi;
|
|
3884
|
+
line = line.replace(keywords, '<span class="openpkg-syn-keyword" style="color:var(--openpkg-syn-keyword,#c4a7e7)">$1</span>');
|
|
3885
|
+
line = line.replace(/('[^&#]*')/g, '<span class="openpkg-syn-string" style="color:var(--openpkg-syn-string,#9ccfd8)">$1</span>');
|
|
3886
|
+
line = line.replace(/\b(\d+\.?\d*)\b/g, '<span class="openpkg-syn-number" style="color:var(--openpkg-syn-number,#f6c177)">$1</span>');
|
|
3887
|
+
return line;
|
|
3888
|
+
}
|
|
3889
|
+
// ../../node_modules/@radix-ui/react-collapsible/dist/index.mjs
|
|
3890
|
+
import * as React10 from "react";
|
|
3891
|
+
|
|
3892
|
+
// ../../node_modules/@radix-ui/primitive/dist/index.mjs
|
|
3893
|
+
var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
3894
|
+
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
3895
|
+
return function handleEvent(event) {
|
|
3896
|
+
originalEventHandler?.(event);
|
|
3897
|
+
if (checkForDefaultPrevented === false || !event.defaultPrevented) {
|
|
3898
|
+
return ourEventHandler?.(event);
|
|
3899
|
+
}
|
|
3900
|
+
};
|
|
3901
|
+
}
|
|
3902
|
+
|
|
3903
|
+
// ../../node_modules/@radix-ui/react-context/dist/index.mjs
|
|
3904
|
+
import * as React from "react";
|
|
3905
|
+
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
3906
|
+
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
3907
|
+
let defaultContexts = [];
|
|
3908
|
+
function createContext3(rootComponentName, defaultContext) {
|
|
3909
|
+
const BaseContext = React.createContext(defaultContext);
|
|
3910
|
+
const index = defaultContexts.length;
|
|
3911
|
+
defaultContexts = [...defaultContexts, defaultContext];
|
|
3912
|
+
const Provider = (props) => {
|
|
3913
|
+
const { scope, children, ...context } = props;
|
|
3914
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
3915
|
+
const value = React.useMemo(() => context, Object.values(context));
|
|
3916
|
+
return /* @__PURE__ */ jsx11(Context.Provider, { value, children });
|
|
3917
|
+
};
|
|
3918
|
+
Provider.displayName = rootComponentName + "Provider";
|
|
3919
|
+
function useContext22(consumerName, scope) {
|
|
3920
|
+
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
3921
|
+
const context = React.useContext(Context);
|
|
3922
|
+
if (context)
|
|
3923
|
+
return context;
|
|
3924
|
+
if (defaultContext !== undefined)
|
|
3925
|
+
return defaultContext;
|
|
3926
|
+
throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
|
|
3927
|
+
}
|
|
3928
|
+
return [Provider, useContext22];
|
|
3929
|
+
}
|
|
3930
|
+
const createScope = () => {
|
|
3931
|
+
const scopeContexts = defaultContexts.map((defaultContext) => {
|
|
3932
|
+
return React.createContext(defaultContext);
|
|
3933
|
+
});
|
|
3934
|
+
return function useScope(scope) {
|
|
3935
|
+
const contexts = scope?.[scopeName] || scopeContexts;
|
|
3936
|
+
return React.useMemo(() => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }), [scope, contexts]);
|
|
3937
|
+
};
|
|
3938
|
+
};
|
|
3939
|
+
createScope.scopeName = scopeName;
|
|
3940
|
+
return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
|
|
3941
|
+
}
|
|
3942
|
+
function composeContextScopes(...scopes) {
|
|
3943
|
+
const baseScope = scopes[0];
|
|
3944
|
+
if (scopes.length === 1)
|
|
3945
|
+
return baseScope;
|
|
3946
|
+
const createScope = () => {
|
|
3947
|
+
const scopeHooks = scopes.map((createScope2) => ({
|
|
3948
|
+
useScope: createScope2(),
|
|
3949
|
+
scopeName: createScope2.scopeName
|
|
3950
|
+
}));
|
|
3951
|
+
return function useComposedScopes(overrideScopes) {
|
|
3952
|
+
const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
|
|
3953
|
+
const scopeProps = useScope(overrideScopes);
|
|
3954
|
+
const currentScope = scopeProps[`__scope${scopeName}`];
|
|
3955
|
+
return { ...nextScopes2, ...currentScope };
|
|
3956
|
+
}, {});
|
|
3957
|
+
return React.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
|
|
3958
|
+
};
|
|
3959
|
+
};
|
|
3960
|
+
createScope.scopeName = baseScope.scopeName;
|
|
3961
|
+
return createScope;
|
|
3962
|
+
}
|
|
3963
|
+
|
|
3964
|
+
// ../../node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
|
|
3965
|
+
import * as React4 from "react";
|
|
3966
|
+
|
|
3967
|
+
// ../../node_modules/@radix-ui/react-use-layout-effect/dist/index.mjs
|
|
3968
|
+
import * as React2 from "react";
|
|
3969
|
+
var useLayoutEffect2 = globalThis?.document ? React2.useLayoutEffect : () => {};
|
|
3970
|
+
|
|
3971
|
+
// ../../node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
|
|
3972
|
+
import * as React22 from "react";
|
|
3973
|
+
|
|
3974
|
+
// ../../node_modules/@radix-ui/react-use-effect-event/dist/index.mjs
|
|
3975
|
+
import * as React3 from "react";
|
|
3976
|
+
var useReactEffectEvent = React3[" useEffectEvent ".trim().toString()];
|
|
3977
|
+
var useReactInsertionEffect = React3[" useInsertionEffect ".trim().toString()];
|
|
3978
|
+
|
|
3979
|
+
// ../../node_modules/@radix-ui/react-use-controllable-state/dist/index.mjs
|
|
3980
|
+
var useInsertionEffect = React4[" useInsertionEffect ".trim().toString()] || useLayoutEffect2;
|
|
3981
|
+
function useControllableState({
|
|
3982
|
+
prop,
|
|
3983
|
+
defaultProp,
|
|
3984
|
+
onChange = () => {},
|
|
3985
|
+
caller
|
|
3986
|
+
}) {
|
|
3987
|
+
const [uncontrolledProp, setUncontrolledProp, onChangeRef] = useUncontrolledState({
|
|
3988
|
+
defaultProp,
|
|
3989
|
+
onChange
|
|
3990
|
+
});
|
|
3991
|
+
const isControlled = prop !== undefined;
|
|
3992
|
+
const value = isControlled ? prop : uncontrolledProp;
|
|
3993
|
+
if (true) {
|
|
3994
|
+
const isControlledRef = React4.useRef(prop !== undefined);
|
|
3995
|
+
React4.useEffect(() => {
|
|
3996
|
+
const wasControlled = isControlledRef.current;
|
|
3997
|
+
if (wasControlled !== isControlled) {
|
|
3998
|
+
const from = wasControlled ? "controlled" : "uncontrolled";
|
|
3999
|
+
const to = isControlled ? "controlled" : "uncontrolled";
|
|
4000
|
+
console.warn(`${caller} is changing from ${from} to ${to}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`);
|
|
4001
|
+
}
|
|
4002
|
+
isControlledRef.current = isControlled;
|
|
4003
|
+
}, [isControlled, caller]);
|
|
4004
|
+
}
|
|
4005
|
+
const setValue = React4.useCallback((nextValue) => {
|
|
4006
|
+
if (isControlled) {
|
|
4007
|
+
const value2 = isFunction(nextValue) ? nextValue(prop) : nextValue;
|
|
4008
|
+
if (value2 !== prop) {
|
|
4009
|
+
onChangeRef.current?.(value2);
|
|
4010
|
+
}
|
|
4011
|
+
} else {
|
|
4012
|
+
setUncontrolledProp(nextValue);
|
|
4013
|
+
}
|
|
4014
|
+
}, [isControlled, prop, setUncontrolledProp, onChangeRef]);
|
|
4015
|
+
return [value, setValue];
|
|
4016
|
+
}
|
|
4017
|
+
function useUncontrolledState({
|
|
4018
|
+
defaultProp,
|
|
4019
|
+
onChange
|
|
4020
|
+
}) {
|
|
4021
|
+
const [value, setValue] = React4.useState(defaultProp);
|
|
4022
|
+
const prevValueRef = React4.useRef(value);
|
|
4023
|
+
const onChangeRef = React4.useRef(onChange);
|
|
4024
|
+
useInsertionEffect(() => {
|
|
4025
|
+
onChangeRef.current = onChange;
|
|
4026
|
+
}, [onChange]);
|
|
4027
|
+
React4.useEffect(() => {
|
|
4028
|
+
if (prevValueRef.current !== value) {
|
|
4029
|
+
onChangeRef.current?.(value);
|
|
4030
|
+
prevValueRef.current = value;
|
|
4031
|
+
}
|
|
4032
|
+
}, [value, prevValueRef]);
|
|
4033
|
+
return [value, setValue, onChangeRef];
|
|
4034
|
+
}
|
|
4035
|
+
function isFunction(value) {
|
|
4036
|
+
return typeof value === "function";
|
|
4037
|
+
}
|
|
4038
|
+
var SYNC_STATE = Symbol("RADIX:SYNC_STATE");
|
|
4039
|
+
|
|
4040
|
+
// ../../node_modules/@radix-ui/react-compose-refs/dist/index.mjs
|
|
4041
|
+
import * as React5 from "react";
|
|
4042
|
+
function setRef(ref, value) {
|
|
4043
|
+
if (typeof ref === "function") {
|
|
4044
|
+
return ref(value);
|
|
4045
|
+
} else if (ref !== null && ref !== undefined) {
|
|
4046
|
+
ref.current = value;
|
|
4047
|
+
}
|
|
4048
|
+
}
|
|
4049
|
+
function composeRefs(...refs) {
|
|
4050
|
+
return (node) => {
|
|
4051
|
+
let hasCleanup = false;
|
|
4052
|
+
const cleanups = refs.map((ref) => {
|
|
4053
|
+
const cleanup = setRef(ref, node);
|
|
4054
|
+
if (!hasCleanup && typeof cleanup == "function") {
|
|
4055
|
+
hasCleanup = true;
|
|
4056
|
+
}
|
|
4057
|
+
return cleanup;
|
|
4058
|
+
});
|
|
4059
|
+
if (hasCleanup) {
|
|
4060
|
+
return () => {
|
|
4061
|
+
for (let i = 0;i < cleanups.length; i++) {
|
|
4062
|
+
const cleanup = cleanups[i];
|
|
4063
|
+
if (typeof cleanup == "function") {
|
|
4064
|
+
cleanup();
|
|
4065
|
+
} else {
|
|
4066
|
+
setRef(refs[i], null);
|
|
4067
|
+
}
|
|
4068
|
+
}
|
|
4069
|
+
};
|
|
4070
|
+
}
|
|
4071
|
+
};
|
|
4072
|
+
}
|
|
4073
|
+
function useComposedRefs(...refs) {
|
|
4074
|
+
return React5.useCallback(composeRefs(...refs), refs);
|
|
4075
|
+
}
|
|
4076
|
+
|
|
4077
|
+
// ../../node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
4078
|
+
import * as React7 from "react";
|
|
4079
|
+
import * as ReactDOM from "react-dom";
|
|
4080
|
+
|
|
4081
|
+
// ../../node_modules/@radix-ui/react-primitive/node_modules/@radix-ui/react-slot/dist/index.mjs
|
|
4082
|
+
import * as React6 from "react";
|
|
4083
|
+
import { Fragment as Fragment22, jsx as jsx12 } from "react/jsx-runtime";
|
|
4084
|
+
function createSlot(ownerName) {
|
|
4085
|
+
const SlotClone = /* @__PURE__ */ createSlotClone(ownerName);
|
|
4086
|
+
const Slot2 = React6.forwardRef((props, forwardedRef) => {
|
|
4087
|
+
const { children, ...slotProps } = props;
|
|
4088
|
+
const childrenArray = React6.Children.toArray(children);
|
|
4089
|
+
const slottable = childrenArray.find(isSlottable);
|
|
4090
|
+
if (slottable) {
|
|
4091
|
+
const newElement = slottable.props.children;
|
|
4092
|
+
const newChildren = childrenArray.map((child) => {
|
|
4093
|
+
if (child === slottable) {
|
|
4094
|
+
if (React6.Children.count(newElement) > 1)
|
|
4095
|
+
return React6.Children.only(null);
|
|
4096
|
+
return React6.isValidElement(newElement) ? newElement.props.children : null;
|
|
4097
|
+
} else {
|
|
4098
|
+
return child;
|
|
4099
|
+
}
|
|
4100
|
+
});
|
|
4101
|
+
return /* @__PURE__ */ jsx12(SlotClone, { ...slotProps, ref: forwardedRef, children: React6.isValidElement(newElement) ? React6.cloneElement(newElement, undefined, newChildren) : null });
|
|
4102
|
+
}
|
|
4103
|
+
return /* @__PURE__ */ jsx12(SlotClone, { ...slotProps, ref: forwardedRef, children });
|
|
4104
|
+
});
|
|
4105
|
+
Slot2.displayName = `${ownerName}.Slot`;
|
|
4106
|
+
return Slot2;
|
|
4107
|
+
}
|
|
4108
|
+
function createSlotClone(ownerName) {
|
|
4109
|
+
const SlotClone = React6.forwardRef((props, forwardedRef) => {
|
|
4110
|
+
const { children, ...slotProps } = props;
|
|
4111
|
+
if (React6.isValidElement(children)) {
|
|
4112
|
+
const childrenRef = getElementRef(children);
|
|
4113
|
+
const props2 = mergeProps(slotProps, children.props);
|
|
4114
|
+
if (children.type !== React6.Fragment) {
|
|
4115
|
+
props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
|
|
4116
|
+
}
|
|
4117
|
+
return React6.cloneElement(children, props2);
|
|
4118
|
+
}
|
|
4119
|
+
return React6.Children.count(children) > 1 ? React6.Children.only(null) : null;
|
|
4120
|
+
});
|
|
4121
|
+
SlotClone.displayName = `${ownerName}.SlotClone`;
|
|
4122
|
+
return SlotClone;
|
|
4123
|
+
}
|
|
4124
|
+
var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
|
|
4125
|
+
function isSlottable(child) {
|
|
4126
|
+
return React6.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER;
|
|
4127
|
+
}
|
|
4128
|
+
function mergeProps(slotProps, childProps) {
|
|
4129
|
+
const overrideProps = { ...childProps };
|
|
4130
|
+
for (const propName in childProps) {
|
|
4131
|
+
const slotPropValue = slotProps[propName];
|
|
4132
|
+
const childPropValue = childProps[propName];
|
|
4133
|
+
const isHandler = /^on[A-Z]/.test(propName);
|
|
4134
|
+
if (isHandler) {
|
|
4135
|
+
if (slotPropValue && childPropValue) {
|
|
4136
|
+
overrideProps[propName] = (...args) => {
|
|
4137
|
+
const result = childPropValue(...args);
|
|
4138
|
+
slotPropValue(...args);
|
|
4139
|
+
return result;
|
|
4140
|
+
};
|
|
4141
|
+
} else if (slotPropValue) {
|
|
4142
|
+
overrideProps[propName] = slotPropValue;
|
|
4143
|
+
}
|
|
4144
|
+
} else if (propName === "style") {
|
|
4145
|
+
overrideProps[propName] = { ...slotPropValue, ...childPropValue };
|
|
4146
|
+
} else if (propName === "className") {
|
|
4147
|
+
overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(" ");
|
|
4148
|
+
}
|
|
4149
|
+
}
|
|
4150
|
+
return { ...slotProps, ...overrideProps };
|
|
4151
|
+
}
|
|
4152
|
+
function getElementRef(element) {
|
|
4153
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
4154
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
4155
|
+
if (mayWarn) {
|
|
4156
|
+
return element.ref;
|
|
4157
|
+
}
|
|
4158
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
4159
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
4160
|
+
if (mayWarn) {
|
|
4161
|
+
return element.props.ref;
|
|
4162
|
+
}
|
|
4163
|
+
return element.props.ref || element.ref;
|
|
4164
|
+
}
|
|
4165
|
+
|
|
4166
|
+
// ../../node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
4167
|
+
import { jsx as jsx13 } from "react/jsx-runtime";
|
|
4168
|
+
var NODES = [
|
|
4169
|
+
"a",
|
|
4170
|
+
"button",
|
|
4171
|
+
"div",
|
|
4172
|
+
"form",
|
|
4173
|
+
"h2",
|
|
4174
|
+
"h3",
|
|
4175
|
+
"img",
|
|
4176
|
+
"input",
|
|
4177
|
+
"label",
|
|
4178
|
+
"li",
|
|
4179
|
+
"nav",
|
|
4180
|
+
"ol",
|
|
4181
|
+
"p",
|
|
4182
|
+
"select",
|
|
4183
|
+
"span",
|
|
4184
|
+
"svg",
|
|
4185
|
+
"ul"
|
|
4186
|
+
];
|
|
4187
|
+
var Primitive = NODES.reduce((primitive, node) => {
|
|
4188
|
+
const Slot = createSlot(`Primitive.${node}`);
|
|
4189
|
+
const Node = React7.forwardRef((props, forwardedRef) => {
|
|
4190
|
+
const { asChild, ...primitiveProps } = props;
|
|
4191
|
+
const Comp = asChild ? Slot : node;
|
|
4192
|
+
if (typeof window !== "undefined") {
|
|
4193
|
+
window[Symbol.for("radix-ui")] = true;
|
|
4194
|
+
}
|
|
4195
|
+
return /* @__PURE__ */ jsx13(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
4196
|
+
});
|
|
4197
|
+
Node.displayName = `Primitive.${node}`;
|
|
4198
|
+
return { ...primitive, [node]: Node };
|
|
4199
|
+
}, {});
|
|
4200
|
+
|
|
4201
|
+
// ../../node_modules/@radix-ui/react-presence/dist/index.mjs
|
|
4202
|
+
import * as React23 from "react";
|
|
4203
|
+
import * as React8 from "react";
|
|
4204
|
+
|
|
4205
|
+
function useStateMachine(initialState, machine) {
|
|
4206
|
+
return React8.useReducer((state, event) => {
|
|
4207
|
+
const nextState = machine[state][event];
|
|
4208
|
+
return nextState ?? state;
|
|
4209
|
+
}, initialState);
|
|
4210
|
+
}
|
|
4211
|
+
var Presence = (props) => {
|
|
4212
|
+
const { present, children } = props;
|
|
4213
|
+
const presence = usePresence(present);
|
|
4214
|
+
const child = typeof children === "function" ? children({ present: presence.isPresent }) : React23.Children.only(children);
|
|
4215
|
+
const ref = useComposedRefs(presence.ref, getElementRef2(child));
|
|
4216
|
+
const forceMount = typeof children === "function";
|
|
4217
|
+
return forceMount || presence.isPresent ? React23.cloneElement(child, { ref }) : null;
|
|
4218
|
+
};
|
|
4219
|
+
Presence.displayName = "Presence";
|
|
4220
|
+
function usePresence(present) {
|
|
4221
|
+
const [node, setNode] = React23.useState();
|
|
4222
|
+
const stylesRef = React23.useRef(null);
|
|
4223
|
+
const prevPresentRef = React23.useRef(present);
|
|
4224
|
+
const prevAnimationNameRef = React23.useRef("none");
|
|
4225
|
+
const initialState = present ? "mounted" : "unmounted";
|
|
4226
|
+
const [state, send] = useStateMachine(initialState, {
|
|
4227
|
+
mounted: {
|
|
4228
|
+
UNMOUNT: "unmounted",
|
|
4229
|
+
ANIMATION_OUT: "unmountSuspended"
|
|
4230
|
+
},
|
|
4231
|
+
unmountSuspended: {
|
|
4232
|
+
MOUNT: "mounted",
|
|
4233
|
+
ANIMATION_END: "unmounted"
|
|
4234
|
+
},
|
|
4235
|
+
unmounted: {
|
|
4236
|
+
MOUNT: "mounted"
|
|
4237
|
+
}
|
|
4238
|
+
});
|
|
4239
|
+
React23.useEffect(() => {
|
|
4240
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
4241
|
+
prevAnimationNameRef.current = state === "mounted" ? currentAnimationName : "none";
|
|
4242
|
+
}, [state]);
|
|
4243
|
+
useLayoutEffect2(() => {
|
|
4244
|
+
const styles = stylesRef.current;
|
|
4245
|
+
const wasPresent = prevPresentRef.current;
|
|
4246
|
+
const hasPresentChanged = wasPresent !== present;
|
|
4247
|
+
if (hasPresentChanged) {
|
|
4248
|
+
const prevAnimationName = prevAnimationNameRef.current;
|
|
4249
|
+
const currentAnimationName = getAnimationName(styles);
|
|
4250
|
+
if (present) {
|
|
4251
|
+
send("MOUNT");
|
|
4252
|
+
} else if (currentAnimationName === "none" || styles?.display === "none") {
|
|
4253
|
+
send("UNMOUNT");
|
|
4254
|
+
} else {
|
|
4255
|
+
const isAnimating = prevAnimationName !== currentAnimationName;
|
|
4256
|
+
if (wasPresent && isAnimating) {
|
|
4257
|
+
send("ANIMATION_OUT");
|
|
4258
|
+
} else {
|
|
4259
|
+
send("UNMOUNT");
|
|
4260
|
+
}
|
|
4261
|
+
}
|
|
4262
|
+
prevPresentRef.current = present;
|
|
4263
|
+
}
|
|
4264
|
+
}, [present, send]);
|
|
4265
|
+
useLayoutEffect2(() => {
|
|
4266
|
+
if (node) {
|
|
4267
|
+
let timeoutId;
|
|
4268
|
+
const ownerWindow = node.ownerDocument.defaultView ?? window;
|
|
4269
|
+
const handleAnimationEnd = (event) => {
|
|
4270
|
+
const currentAnimationName = getAnimationName(stylesRef.current);
|
|
4271
|
+
const isCurrentAnimation = currentAnimationName.includes(CSS.escape(event.animationName));
|
|
4272
|
+
if (event.target === node && isCurrentAnimation) {
|
|
4273
|
+
send("ANIMATION_END");
|
|
4274
|
+
if (!prevPresentRef.current) {
|
|
4275
|
+
const currentFillMode = node.style.animationFillMode;
|
|
4276
|
+
node.style.animationFillMode = "forwards";
|
|
4277
|
+
timeoutId = ownerWindow.setTimeout(() => {
|
|
4278
|
+
if (node.style.animationFillMode === "forwards") {
|
|
4279
|
+
node.style.animationFillMode = currentFillMode;
|
|
4280
|
+
}
|
|
4281
|
+
});
|
|
4282
|
+
}
|
|
4283
|
+
}
|
|
4284
|
+
};
|
|
4285
|
+
const handleAnimationStart = (event) => {
|
|
4286
|
+
if (event.target === node) {
|
|
4287
|
+
prevAnimationNameRef.current = getAnimationName(stylesRef.current);
|
|
4288
|
+
}
|
|
4289
|
+
};
|
|
4290
|
+
node.addEventListener("animationstart", handleAnimationStart);
|
|
4291
|
+
node.addEventListener("animationcancel", handleAnimationEnd);
|
|
4292
|
+
node.addEventListener("animationend", handleAnimationEnd);
|
|
4293
|
+
return () => {
|
|
4294
|
+
ownerWindow.clearTimeout(timeoutId);
|
|
4295
|
+
node.removeEventListener("animationstart", handleAnimationStart);
|
|
4296
|
+
node.removeEventListener("animationcancel", handleAnimationEnd);
|
|
4297
|
+
node.removeEventListener("animationend", handleAnimationEnd);
|
|
4298
|
+
};
|
|
4299
|
+
} else {
|
|
4300
|
+
send("ANIMATION_END");
|
|
4301
|
+
}
|
|
4302
|
+
}, [node, send]);
|
|
4303
|
+
return {
|
|
4304
|
+
isPresent: ["mounted", "unmountSuspended"].includes(state),
|
|
4305
|
+
ref: React23.useCallback((node2) => {
|
|
4306
|
+
stylesRef.current = node2 ? getComputedStyle(node2) : null;
|
|
4307
|
+
setNode(node2);
|
|
4308
|
+
}, [])
|
|
4309
|
+
};
|
|
4310
|
+
}
|
|
4311
|
+
function getAnimationName(styles) {
|
|
4312
|
+
return styles?.animationName || "none";
|
|
4313
|
+
}
|
|
4314
|
+
function getElementRef2(element) {
|
|
4315
|
+
let getter = Object.getOwnPropertyDescriptor(element.props, "ref")?.get;
|
|
4316
|
+
let mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
4317
|
+
if (mayWarn) {
|
|
4318
|
+
return element.ref;
|
|
4319
|
+
}
|
|
4320
|
+
getter = Object.getOwnPropertyDescriptor(element, "ref")?.get;
|
|
4321
|
+
mayWarn = getter && "isReactWarning" in getter && getter.isReactWarning;
|
|
4322
|
+
if (mayWarn) {
|
|
4323
|
+
return element.props.ref;
|
|
4324
|
+
}
|
|
4325
|
+
return element.props.ref || element.ref;
|
|
4326
|
+
}
|
|
4327
|
+
|
|
4328
|
+
// ../../node_modules/@radix-ui/react-id/dist/index.mjs
|
|
4329
|
+
import * as React9 from "react";
|
|
4330
|
+
var useReactId = React9[" useId ".trim().toString()] || (() => {
|
|
4331
|
+
return;
|
|
4332
|
+
});
|
|
4333
|
+
var count = 0;
|
|
4334
|
+
function useId(deterministicId) {
|
|
4335
|
+
const [id, setId] = React9.useState(useReactId());
|
|
4336
|
+
useLayoutEffect2(() => {
|
|
4337
|
+
if (!deterministicId)
|
|
4338
|
+
setId((reactId) => reactId ?? String(count++));
|
|
4339
|
+
}, [deterministicId]);
|
|
4340
|
+
return deterministicId || (id ? `radix-${id}` : "");
|
|
4341
|
+
}
|
|
4342
|
+
|
|
4343
|
+
// ../../node_modules/@radix-ui/react-collapsible/dist/index.mjs
|
|
4344
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
4345
|
+
|
|
4346
|
+
var COLLAPSIBLE_NAME = "Collapsible";
|
|
4347
|
+
var [createCollapsibleContext, createCollapsibleScope] = createContextScope(COLLAPSIBLE_NAME);
|
|
4348
|
+
var [CollapsibleProvider, useCollapsibleContext] = createCollapsibleContext(COLLAPSIBLE_NAME);
|
|
4349
|
+
var Collapsible = React10.forwardRef((props, forwardedRef) => {
|
|
4350
|
+
const {
|
|
4351
|
+
__scopeCollapsible,
|
|
4352
|
+
open: openProp,
|
|
4353
|
+
defaultOpen,
|
|
4354
|
+
disabled,
|
|
4355
|
+
onOpenChange,
|
|
4356
|
+
...collapsibleProps
|
|
4357
|
+
} = props;
|
|
4358
|
+
const [open, setOpen] = useControllableState({
|
|
4359
|
+
prop: openProp,
|
|
4360
|
+
defaultProp: defaultOpen ?? false,
|
|
4361
|
+
onChange: onOpenChange,
|
|
4362
|
+
caller: COLLAPSIBLE_NAME
|
|
4363
|
+
});
|
|
4364
|
+
return /* @__PURE__ */ jsx14(CollapsibleProvider, {
|
|
4365
|
+
scope: __scopeCollapsible,
|
|
4366
|
+
disabled,
|
|
4367
|
+
contentId: useId(),
|
|
4368
|
+
open,
|
|
4369
|
+
onOpenToggle: React10.useCallback(() => setOpen((prevOpen) => !prevOpen), [setOpen]),
|
|
4370
|
+
children: /* @__PURE__ */ jsx14(Primitive.div, {
|
|
4371
|
+
"data-state": getState(open),
|
|
4372
|
+
"data-disabled": disabled ? "" : undefined,
|
|
4373
|
+
...collapsibleProps,
|
|
4374
|
+
ref: forwardedRef
|
|
4375
|
+
})
|
|
4376
|
+
});
|
|
4377
|
+
});
|
|
4378
|
+
Collapsible.displayName = COLLAPSIBLE_NAME;
|
|
4379
|
+
var TRIGGER_NAME = "CollapsibleTrigger";
|
|
4380
|
+
var CollapsibleTrigger = React10.forwardRef((props, forwardedRef) => {
|
|
4381
|
+
const { __scopeCollapsible, ...triggerProps } = props;
|
|
4382
|
+
const context = useCollapsibleContext(TRIGGER_NAME, __scopeCollapsible);
|
|
4383
|
+
return /* @__PURE__ */ jsx14(Primitive.button, {
|
|
4384
|
+
type: "button",
|
|
4385
|
+
"aria-controls": context.contentId,
|
|
4386
|
+
"aria-expanded": context.open || false,
|
|
4387
|
+
"data-state": getState(context.open),
|
|
4388
|
+
"data-disabled": context.disabled ? "" : undefined,
|
|
4389
|
+
disabled: context.disabled,
|
|
4390
|
+
...triggerProps,
|
|
4391
|
+
ref: forwardedRef,
|
|
4392
|
+
onClick: composeEventHandlers(props.onClick, context.onOpenToggle)
|
|
4393
|
+
});
|
|
4394
|
+
});
|
|
4395
|
+
CollapsibleTrigger.displayName = TRIGGER_NAME;
|
|
4396
|
+
var CONTENT_NAME = "CollapsibleContent";
|
|
4397
|
+
var CollapsibleContent = React10.forwardRef((props, forwardedRef) => {
|
|
4398
|
+
const { forceMount, ...contentProps } = props;
|
|
4399
|
+
const context = useCollapsibleContext(CONTENT_NAME, props.__scopeCollapsible);
|
|
4400
|
+
return /* @__PURE__ */ jsx14(Presence, { present: forceMount || context.open, children: ({ present }) => /* @__PURE__ */ jsx14(CollapsibleContentImpl, { ...contentProps, ref: forwardedRef, present }) });
|
|
4401
|
+
});
|
|
4402
|
+
CollapsibleContent.displayName = CONTENT_NAME;
|
|
4403
|
+
var CollapsibleContentImpl = React10.forwardRef((props, forwardedRef) => {
|
|
4404
|
+
const { __scopeCollapsible, present, children, ...contentProps } = props;
|
|
4405
|
+
const context = useCollapsibleContext(CONTENT_NAME, __scopeCollapsible);
|
|
4406
|
+
const [isPresent, setIsPresent] = React10.useState(present);
|
|
4407
|
+
const ref = React10.useRef(null);
|
|
4408
|
+
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
4409
|
+
const heightRef = React10.useRef(0);
|
|
4410
|
+
const height = heightRef.current;
|
|
4411
|
+
const widthRef = React10.useRef(0);
|
|
4412
|
+
const width = widthRef.current;
|
|
4413
|
+
const isOpen = context.open || isPresent;
|
|
4414
|
+
const isMountAnimationPreventedRef = React10.useRef(isOpen);
|
|
4415
|
+
const originalStylesRef = React10.useRef(undefined);
|
|
4416
|
+
React10.useEffect(() => {
|
|
4417
|
+
const rAF = requestAnimationFrame(() => isMountAnimationPreventedRef.current = false);
|
|
4418
|
+
return () => cancelAnimationFrame(rAF);
|
|
4419
|
+
}, []);
|
|
4420
|
+
useLayoutEffect2(() => {
|
|
4421
|
+
const node = ref.current;
|
|
4422
|
+
if (node) {
|
|
4423
|
+
originalStylesRef.current = originalStylesRef.current || {
|
|
4424
|
+
transitionDuration: node.style.transitionDuration,
|
|
4425
|
+
animationName: node.style.animationName
|
|
4426
|
+
};
|
|
4427
|
+
node.style.transitionDuration = "0s";
|
|
4428
|
+
node.style.animationName = "none";
|
|
4429
|
+
const rect = node.getBoundingClientRect();
|
|
4430
|
+
heightRef.current = rect.height;
|
|
4431
|
+
widthRef.current = rect.width;
|
|
4432
|
+
if (!isMountAnimationPreventedRef.current) {
|
|
4433
|
+
node.style.transitionDuration = originalStylesRef.current.transitionDuration;
|
|
4434
|
+
node.style.animationName = originalStylesRef.current.animationName;
|
|
4435
|
+
}
|
|
4436
|
+
setIsPresent(present);
|
|
4437
|
+
}
|
|
4438
|
+
}, [context.open, present]);
|
|
4439
|
+
return /* @__PURE__ */ jsx14(Primitive.div, {
|
|
4440
|
+
"data-state": getState(context.open),
|
|
4441
|
+
"data-disabled": context.disabled ? "" : undefined,
|
|
4442
|
+
id: context.contentId,
|
|
4443
|
+
hidden: !isOpen,
|
|
4444
|
+
...contentProps,
|
|
4445
|
+
ref: composedRefs,
|
|
4446
|
+
style: {
|
|
4447
|
+
[`--radix-collapsible-content-height`]: height ? `${height}px` : undefined,
|
|
4448
|
+
[`--radix-collapsible-content-width`]: width ? `${width}px` : undefined,
|
|
4449
|
+
...props.style
|
|
4450
|
+
},
|
|
4451
|
+
children: isOpen && children
|
|
4452
|
+
});
|
|
4453
|
+
});
|
|
4454
|
+
function getState(open) {
|
|
4455
|
+
return open ? "open" : "closed";
|
|
4456
|
+
}
|
|
4457
|
+
var Root = Collapsible;
|
|
4458
|
+
var Trigger = CollapsibleTrigger;
|
|
4459
|
+
var Content = CollapsibleContent;
|
|
4460
|
+
|
|
4461
|
+
// src/components/styled/CollapsiblePanel.tsx
|
|
4462
|
+
import { cn as cn10 } from "@openpkg-ts/ui/lib/utils";
|
|
4463
|
+
import { ChevronRight } from "lucide-react";
|
|
4464
|
+
import { useState as useState7 } from "react";
|
|
4465
|
+
import { jsx as jsx15, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
4466
|
+
|
|
4467
|
+
function CollapsiblePanel({
|
|
4468
|
+
title,
|
|
4469
|
+
children,
|
|
4470
|
+
defaultExpanded = false,
|
|
4471
|
+
expanded: controlledExpanded,
|
|
4472
|
+
onExpandedChange,
|
|
4473
|
+
className
|
|
4474
|
+
}) {
|
|
4475
|
+
const [internalExpanded, setInternalExpanded] = useState7(defaultExpanded);
|
|
4476
|
+
const isControlled = controlledExpanded !== undefined;
|
|
4477
|
+
const expanded = isControlled ? controlledExpanded : internalExpanded;
|
|
4478
|
+
const handleOpenChange = (open) => {
|
|
4479
|
+
if (isControlled) {
|
|
4480
|
+
onExpandedChange?.(open);
|
|
4481
|
+
} else {
|
|
4482
|
+
setInternalExpanded(open);
|
|
4483
|
+
}
|
|
4484
|
+
};
|
|
4485
|
+
return /* @__PURE__ */ jsxs8(Root, {
|
|
4486
|
+
open: expanded,
|
|
4487
|
+
onOpenChange: handleOpenChange,
|
|
4488
|
+
className: cn10("openpkg-collapsible-panel", className),
|
|
4489
|
+
children: [
|
|
4490
|
+
/* @__PURE__ */ jsxs8(Trigger, {
|
|
4491
|
+
className: cn10("openpkg-collapsible-trigger", "flex items-center gap-2.5 w-full", "px-4 py-3", "bg-[var(--openpkg-bg-collapsible,#161616)]", "border border-[var(--openpkg-border-subtle,#262626)]", "rounded-md", "cursor-pointer", "transition-all duration-150", "hover:bg-[var(--openpkg-bg-tertiary,#1c1c1c)]", expanded && "rounded-b-none border-b-transparent mb-0", !expanded && "mb-2"),
|
|
4492
|
+
children: [
|
|
4493
|
+
/* @__PURE__ */ jsx15(ChevronRight, {
|
|
4494
|
+
size: 14,
|
|
4495
|
+
className: cn10("text-[var(--openpkg-text-muted,#666666)]", "transition-transform duration-200", expanded && "rotate-90")
|
|
4496
|
+
}),
|
|
4497
|
+
/* @__PURE__ */ jsx15("span", {
|
|
4498
|
+
className: "text-[13px] font-medium text-[var(--openpkg-text-secondary,#a0a0a0)]",
|
|
4499
|
+
children: title
|
|
4500
|
+
})
|
|
4501
|
+
]
|
|
4502
|
+
}),
|
|
4503
|
+
/* @__PURE__ */ jsx15(Content, {
|
|
4504
|
+
className: cn10("openpkg-collapsible-content", "bg-[var(--openpkg-bg-code,#0f0f18)]", "border border-[var(--openpkg-border-subtle,#262626)]", "border-t-0", "rounded-b-md", "mb-2", "overflow-hidden", "data-[state=open]:animate-[openpkg-expand_200ms_ease-out]", "data-[state=closed]:animate-[openpkg-collapse_200ms_ease-out]"),
|
|
4505
|
+
children
|
|
4506
|
+
})
|
|
4507
|
+
]
|
|
4508
|
+
});
|
|
4509
|
+
}
|
|
4510
|
+
// src/components/styled/ExampleSection.tsx
|
|
4511
|
+
import { cn as cn11 } from "@openpkg-ts/ui/lib/utils";
|
|
4512
|
+
import { useEffect as useEffect7, useRef as useRef8, useState as useState8 } from "react";
|
|
4513
|
+
import { jsx as jsx16, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
4514
|
+
|
|
4515
|
+
function ExampleSection({
|
|
4516
|
+
id,
|
|
4517
|
+
examples,
|
|
4518
|
+
dataSource,
|
|
4519
|
+
response,
|
|
4520
|
+
notes,
|
|
4521
|
+
className
|
|
4522
|
+
}) {
|
|
4523
|
+
const [activeExampleId, setActiveExampleId] = useState8(examples[0]?.id ?? "");
|
|
4524
|
+
const ref = useRef8(null);
|
|
4525
|
+
const syncScroll = useSyncScrollSafe2();
|
|
4526
|
+
const activeExample = examples.find((e) => e.id === activeExampleId) ?? examples[0];
|
|
4527
|
+
const isActive = syncScroll?.activeSection === id;
|
|
4528
|
+
useEffect7(() => {
|
|
4529
|
+
if (ref.current) {
|
|
4530
|
+
ref.current.setAttribute("data-section", id);
|
|
4531
|
+
}
|
|
4532
|
+
}, [id]);
|
|
4533
|
+
return /* @__PURE__ */ jsxs9("div", {
|
|
4534
|
+
ref,
|
|
4535
|
+
"data-section": id,
|
|
4536
|
+
className: cn11("openpkg-example-section", "mb-12 last:mb-0", "transition-opacity duration-300", isActive ? "opacity-100" : "opacity-40", className),
|
|
4537
|
+
children: [
|
|
4538
|
+
examples.length > 1 && /* @__PURE__ */ jsx16(ExampleChips, {
|
|
4539
|
+
examples: examples.map((e) => ({ id: e.id, label: e.label })),
|
|
4540
|
+
activeId: activeExampleId,
|
|
4541
|
+
onSelect: setActiveExampleId
|
|
4542
|
+
}),
|
|
4543
|
+
activeExample && /* @__PURE__ */ jsx16(CodePanel, {
|
|
4544
|
+
code: activeExample.code,
|
|
4545
|
+
language: activeExample.language ?? "typescript",
|
|
4546
|
+
showLineNumbers: true
|
|
4547
|
+
}),
|
|
4548
|
+
dataSource && /* @__PURE__ */ jsx16(CollapsiblePanel, {
|
|
4549
|
+
title: "Data source",
|
|
4550
|
+
children: /* @__PURE__ */ jsx16("div", {
|
|
4551
|
+
className: "p-4",
|
|
4552
|
+
children: /* @__PURE__ */ jsx16(CodePanel, {
|
|
4553
|
+
code: dataSource,
|
|
4554
|
+
language: "sql"
|
|
4555
|
+
})
|
|
4556
|
+
})
|
|
4557
|
+
}),
|
|
4558
|
+
response && /* @__PURE__ */ jsx16(CollapsiblePanel, {
|
|
4559
|
+
title: "Response",
|
|
4560
|
+
children: /* @__PURE__ */ jsx16("div", {
|
|
4561
|
+
className: "p-4",
|
|
4562
|
+
children: /* @__PURE__ */ jsx16(CodePanel, {
|
|
4563
|
+
code: response,
|
|
4564
|
+
language: "json"
|
|
4565
|
+
})
|
|
4566
|
+
})
|
|
4567
|
+
}),
|
|
4568
|
+
notes && /* @__PURE__ */ jsx16(CollapsiblePanel, {
|
|
4569
|
+
title: "Notes",
|
|
4570
|
+
children: /* @__PURE__ */ jsx16("div", {
|
|
4571
|
+
className: cn11("openpkg-panel-note", "p-4", "text-[13px] text-[var(--openpkg-text-secondary,#a0a0a0)]", "leading-relaxed", "[&_code]:font-mono [&_code]:text-xs [&_code]:bg-[var(--openpkg-bg-badge,#262626)] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:rounded"),
|
|
4572
|
+
children: typeof notes === "string" ? /* @__PURE__ */ jsx16("p", {
|
|
4573
|
+
children: notes
|
|
4574
|
+
}) : notes
|
|
4575
|
+
})
|
|
4576
|
+
})
|
|
4577
|
+
]
|
|
4578
|
+
});
|
|
4579
|
+
}
|
|
4580
|
+
function useSyncScrollSafe2() {
|
|
4581
|
+
try {
|
|
4582
|
+
return useSyncScroll();
|
|
4583
|
+
} catch {
|
|
4584
|
+
return null;
|
|
4585
|
+
}
|
|
4586
|
+
}
|
|
4587
|
+
// src/components/styled/MethodSectionFromSpec.tsx
|
|
4588
|
+
import { cn as cn12 } from "@openpkg-ts/ui/lib/utils";
|
|
4589
|
+
|
|
4590
|
+
// src/hooks/useMethodFromSpec.ts
|
|
4591
|
+
import { buildSignatureString, formatSchema as formatSchema3 } from "@openpkg-ts/sdk/browser";
|
|
4592
|
+
import { useMemo as useMemo6 } from "react";
|
|
4593
|
+
function useMethodFromSpec(spec, exportName) {
|
|
4594
|
+
return useMemo6(() => {
|
|
4595
|
+
const exp = spec.exports.find((e) => e.name === exportName);
|
|
4596
|
+
if (!exp)
|
|
4597
|
+
return null;
|
|
4598
|
+
return extractMethodData(exp, spec);
|
|
4599
|
+
}, [spec, exportName]);
|
|
4600
|
+
}
|
|
4601
|
+
function useMethodsFromSpec(spec) {
|
|
4602
|
+
return useMemo6(() => {
|
|
4603
|
+
return spec.exports.filter((exp) => exp.kind === "function").map((exp) => extractMethodData(exp, spec));
|
|
4604
|
+
}, [spec]);
|
|
4605
|
+
}
|
|
4606
|
+
function extractMethodData(exp, _spec) {
|
|
4607
|
+
const sig = exp.signatures?.[0];
|
|
4608
|
+
const params = sig?.parameters ?? [];
|
|
4609
|
+
const title = exp.kind === "function" ? `${exp.name}()` : exp.name;
|
|
4610
|
+
const signature = buildSignatureString(exp);
|
|
4611
|
+
const description = exp.description || sig?.description;
|
|
4612
|
+
const rawExamples = exp.examples || sig?.examples || [];
|
|
4613
|
+
const examples = rawExamples.map((ex) => typeof ex === "string" ? { code: ex } : ex);
|
|
4614
|
+
const returnType = sig?.returns?.schema;
|
|
4615
|
+
const returnTypeString = returnType ? formatSchema3(returnType) : undefined;
|
|
4616
|
+
const returnDescription = sig?.returns?.description;
|
|
4617
|
+
const isAsync = !!exp.flags?.async;
|
|
4618
|
+
return {
|
|
4619
|
+
export: exp,
|
|
4620
|
+
title,
|
|
4621
|
+
signature,
|
|
4622
|
+
description,
|
|
4623
|
+
parameters: params,
|
|
4624
|
+
examples,
|
|
4625
|
+
returnType,
|
|
4626
|
+
returnTypeString,
|
|
4627
|
+
returnDescription,
|
|
4628
|
+
isAsync
|
|
4629
|
+
};
|
|
4630
|
+
}
|
|
4631
|
+
|
|
4632
|
+
// src/components/styled/MethodSectionFromSpec.tsx
|
|
4633
|
+
import { jsx as jsx17 } from "react/jsx-runtime";
|
|
4634
|
+
|
|
4635
|
+
function MethodSectionFromSpec({
|
|
4636
|
+
spec,
|
|
4637
|
+
export: exportProp,
|
|
4638
|
+
className
|
|
4639
|
+
}) {
|
|
4640
|
+
const exp = typeof exportProp === "string" ? spec.exports.find((e) => e.name === exportProp) : exportProp;
|
|
4641
|
+
if (!exp) {
|
|
4642
|
+
return null;
|
|
4643
|
+
}
|
|
4644
|
+
const method = extractMethodData(exp, spec);
|
|
4645
|
+
const notes = buildNotes(exp);
|
|
4646
|
+
return /* @__PURE__ */ jsx17(MethodSection, {
|
|
4647
|
+
id: exp.id || exp.name,
|
|
4648
|
+
title: method.title,
|
|
4649
|
+
signature: method.signature,
|
|
4650
|
+
description: method.description,
|
|
4651
|
+
notes,
|
|
4652
|
+
className: cn12("openpkg-method-from-spec", className),
|
|
4653
|
+
children: method.parameters.map((param) => /* @__PURE__ */ jsx17(ExpandableParameter, {
|
|
4654
|
+
parameter: param
|
|
4655
|
+
}, param.name))
|
|
4656
|
+
});
|
|
4657
|
+
}
|
|
4658
|
+
function buildNotes(exp) {
|
|
4659
|
+
const notes = [];
|
|
4660
|
+
if (exp.deprecated) {
|
|
4661
|
+
notes.push(exp.deprecationReason ? `⚠️ Deprecated: ${exp.deprecationReason}` : "⚠️ This function is deprecated.");
|
|
4662
|
+
}
|
|
4663
|
+
const sig = exp.signatures?.[0];
|
|
4664
|
+
if (sig?.tags) {
|
|
4665
|
+
for (const tag of sig.tags) {
|
|
4666
|
+
if (tag.name === "note" || tag.name === "remarks") {
|
|
4667
|
+
notes.push(tag.text);
|
|
4668
|
+
}
|
|
4669
|
+
}
|
|
4670
|
+
}
|
|
4671
|
+
const flags = exp.flags;
|
|
4672
|
+
if (flags?.async) {
|
|
4673
|
+
notes.push("This function is async and returns a Promise.");
|
|
4674
|
+
}
|
|
4675
|
+
return notes;
|
|
4676
|
+
}
|
|
4677
|
+
// src/components/styled/StripeAPIReferencePage.tsx
|
|
4678
|
+
import { cn as cn13 } from "@openpkg-ts/ui/lib/utils";
|
|
4679
|
+
|
|
4680
|
+
// src/adapters/spec-to-examples.ts
|
|
4681
|
+
function specExampleToCodeExample(example, index) {
|
|
4682
|
+
if (typeof example === "string") {
|
|
4683
|
+
return {
|
|
4684
|
+
id: `example-${index}`,
|
|
4685
|
+
label: `Example ${index + 1}`,
|
|
4686
|
+
code: example,
|
|
4687
|
+
language: "typescript"
|
|
4688
|
+
};
|
|
4689
|
+
}
|
|
4690
|
+
return {
|
|
4691
|
+
id: example.title?.toLowerCase().replace(/\s+/g, "-") ?? `example-${index}`,
|
|
4692
|
+
label: example.title ?? `Example ${index + 1}`,
|
|
4693
|
+
code: example.code,
|
|
4694
|
+
language: mapLanguage(example.language)
|
|
4695
|
+
};
|
|
4696
|
+
}
|
|
4697
|
+
function specExamplesToCodeExamples2(examples) {
|
|
4698
|
+
if (!examples || examples.length === 0)
|
|
4699
|
+
return [];
|
|
4700
|
+
return examples.map(specExampleToCodeExample);
|
|
4701
|
+
}
|
|
4702
|
+
function generateDefaultExample(packageName, exportName, paramNames) {
|
|
4703
|
+
const importLine = `import { ${exportName} } from '${packageName}';`;
|
|
4704
|
+
const callArgs = paramNames.length > 0 ? paramNames.join(", ") : "";
|
|
4705
|
+
const callLine = `const result = await ${exportName}(${callArgs});`;
|
|
4706
|
+
return {
|
|
4707
|
+
id: "default",
|
|
4708
|
+
label: "Basic",
|
|
4709
|
+
code: `${importLine}
|
|
4710
|
+
|
|
4711
|
+
${callLine}`,
|
|
4712
|
+
language: "typescript"
|
|
4713
|
+
};
|
|
4714
|
+
}
|
|
4715
|
+
function mapLanguage(lang) {
|
|
4716
|
+
switch (lang) {
|
|
4717
|
+
case "ts":
|
|
4718
|
+
case "tsx":
|
|
4719
|
+
return "typescript";
|
|
4720
|
+
case "js":
|
|
4721
|
+
case "jsx":
|
|
4722
|
+
return "javascript";
|
|
4723
|
+
case "shell":
|
|
4724
|
+
return "bash";
|
|
4725
|
+
case "json":
|
|
4726
|
+
return "json";
|
|
4727
|
+
default:
|
|
4728
|
+
return "typescript";
|
|
4729
|
+
}
|
|
4730
|
+
}
|
|
4731
|
+
|
|
4732
|
+
// src/components/styled/StripeAPIReferencePage.tsx
|
|
4733
|
+
import { jsx as jsx18, Fragment as Fragment3 } from "react/jsx-runtime";
|
|
4734
|
+
|
|
4735
|
+
function StripeAPIReferencePage({
|
|
4736
|
+
spec,
|
|
4737
|
+
filter,
|
|
4738
|
+
showAllKinds = false,
|
|
4739
|
+
className
|
|
4740
|
+
}) {
|
|
4741
|
+
const defaultFilter = (exp) => showAllKinds ? true : exp.kind === "function";
|
|
4742
|
+
const activeFilter = filter ?? defaultFilter;
|
|
4743
|
+
const exports = spec.exports.filter(activeFilter);
|
|
4744
|
+
const sortedExports = [...exports].sort((a, b) => a.name.localeCompare(b.name));
|
|
4745
|
+
return /* @__PURE__ */ jsx18(SyncScrollProvider, {
|
|
4746
|
+
children: /* @__PURE__ */ jsx18("div", {
|
|
4747
|
+
className: cn13("openpkg-stripe-api-page", "bg-[var(--openpkg-bg-root,#0c0c0c)]", "text-[var(--openpkg-text-primary,#ededed)]", "font-[var(--openpkg-font-sans)]", "min-h-screen", className),
|
|
4748
|
+
children: /* @__PURE__ */ jsx18(APIReferenceLayout, {
|
|
4749
|
+
examples: /* @__PURE__ */ jsx18(ExamplesColumn, {
|
|
4750
|
+
exports: sortedExports,
|
|
4751
|
+
spec
|
|
4752
|
+
}),
|
|
4753
|
+
children: /* @__PURE__ */ jsx18(DocsColumn, {
|
|
4754
|
+
exports: sortedExports,
|
|
4755
|
+
spec
|
|
4756
|
+
})
|
|
4757
|
+
})
|
|
4758
|
+
})
|
|
4759
|
+
});
|
|
4760
|
+
}
|
|
4761
|
+
function DocsColumn({ exports, spec }) {
|
|
4762
|
+
return /* @__PURE__ */ jsx18(Fragment3, {
|
|
4763
|
+
children: exports.map((exp) => /* @__PURE__ */ jsx18(MethodSectionFromSpec, {
|
|
4764
|
+
spec,
|
|
4765
|
+
export: exp
|
|
4766
|
+
}, exp.id || exp.name))
|
|
4767
|
+
});
|
|
4768
|
+
}
|
|
4769
|
+
function ExamplesColumn({ exports, spec }) {
|
|
4770
|
+
return /* @__PURE__ */ jsx18(Fragment3, {
|
|
4771
|
+
children: exports.map((exp) => {
|
|
4772
|
+
const method = extractMethodData(exp, spec);
|
|
4773
|
+
const examples = getExamplesForExport(exp, spec);
|
|
4774
|
+
return /* @__PURE__ */ jsx18(ExampleSection, {
|
|
4775
|
+
id: exp.id || exp.name,
|
|
4776
|
+
examples,
|
|
4777
|
+
response: generateMockResponse(exp),
|
|
4778
|
+
notes: method.returnDescription
|
|
4779
|
+
}, exp.id || exp.name);
|
|
4780
|
+
})
|
|
4781
|
+
});
|
|
4782
|
+
}
|
|
4783
|
+
function getExamplesForExport(exp, spec) {
|
|
4784
|
+
const method = extractMethodData(exp, spec);
|
|
4785
|
+
if (method.examples.length > 0) {
|
|
4786
|
+
return specExamplesToCodeExamples2(method.examples);
|
|
4787
|
+
}
|
|
4788
|
+
const paramNames = method.parameters.map((p) => p.name);
|
|
4789
|
+
return [generateDefaultExample(spec.meta.name, exp.name, paramNames)];
|
|
4790
|
+
}
|
|
4791
|
+
function generateMockResponse(exp) {
|
|
4792
|
+
const sig = exp.signatures?.[0];
|
|
4793
|
+
if (!sig?.returns?.schema)
|
|
4794
|
+
return;
|
|
4795
|
+
const schema = sig.returns.schema;
|
|
4796
|
+
if (typeof schema === "object") {
|
|
4797
|
+
const s = schema;
|
|
4798
|
+
if (s.type === "void" || s.type === "undefined") {
|
|
4799
|
+
return;
|
|
4800
|
+
}
|
|
4801
|
+
if (s.type === "object" && s.properties) {
|
|
4802
|
+
const props = s.properties;
|
|
4803
|
+
const mock = {};
|
|
4804
|
+
for (const [key, propSchema] of Object.entries(props)) {
|
|
4805
|
+
mock[key] = getMockValue(propSchema);
|
|
4806
|
+
}
|
|
4807
|
+
return JSON.stringify(mock, null, 2);
|
|
4808
|
+
}
|
|
4809
|
+
if (s.type === "array") {
|
|
4810
|
+
return JSON.stringify([getMockValue(s.items)], null, 2);
|
|
4811
|
+
}
|
|
4812
|
+
}
|
|
4813
|
+
return;
|
|
4814
|
+
}
|
|
4815
|
+
function getMockValue(schema) {
|
|
4816
|
+
if (!schema)
|
|
4817
|
+
return null;
|
|
4818
|
+
switch (schema.type) {
|
|
4819
|
+
case "string":
|
|
4820
|
+
return "example";
|
|
4821
|
+
case "number":
|
|
4822
|
+
case "integer":
|
|
4823
|
+
return 42;
|
|
4824
|
+
case "boolean":
|
|
4825
|
+
return true;
|
|
4826
|
+
case "array":
|
|
4827
|
+
return [];
|
|
4828
|
+
case "object":
|
|
4829
|
+
return {};
|
|
4830
|
+
default:
|
|
4831
|
+
return null;
|
|
4832
|
+
}
|
|
4833
|
+
}
|
|
4834
|
+
// src/adapters/spec-to-params.ts
|
|
4835
|
+
import { formatSchema as formatSchema4 } from "@openpkg-ts/sdk/browser";
|
|
4836
|
+
function specParamToNestedParam(param, parentPath) {
|
|
4837
|
+
const schema = param.schema;
|
|
4838
|
+
const type = formatSchema4(schema);
|
|
4839
|
+
const isRequired = param.required !== false;
|
|
4840
|
+
const children = extractNestedProperties(schema, param.name);
|
|
4841
|
+
const enumValues = extractEnumValues(schema);
|
|
4842
|
+
const expandable = children.length > 0;
|
|
4843
|
+
return {
|
|
4844
|
+
name: param.name,
|
|
4845
|
+
parentPath,
|
|
4846
|
+
type: expandable ? "object" : type,
|
|
4847
|
+
required: isRequired,
|
|
4848
|
+
expandable,
|
|
4849
|
+
description: param.description,
|
|
4850
|
+
anchorId: parentPath ? `${parentPath}${param.name}` : param.name,
|
|
4851
|
+
showAnchor: !!parentPath,
|
|
4852
|
+
children: children.length > 0 ? children : undefined,
|
|
4853
|
+
enumValues: enumValues.length > 0 ? enumValues : undefined,
|
|
4854
|
+
schema
|
|
4855
|
+
};
|
|
4856
|
+
}
|
|
4857
|
+
function specParamsToNestedParams(params) {
|
|
4858
|
+
return params.map((p) => specParamToNestedParam(p));
|
|
4859
|
+
}
|
|
4860
|
+
function extractNestedProperties(schema, parentName) {
|
|
4861
|
+
if (!schema || typeof schema !== "object")
|
|
4862
|
+
return [];
|
|
4863
|
+
const s = schema;
|
|
4864
|
+
if (s.type === "object" && s.properties && typeof s.properties === "object") {
|
|
4865
|
+
const props = s.properties;
|
|
4866
|
+
const required = Array.isArray(s.required) ? s.required : [];
|
|
4867
|
+
return Object.entries(props).map(([name, propSchema]) => {
|
|
4868
|
+
const propParam = {
|
|
4869
|
+
name,
|
|
4870
|
+
schema: propSchema,
|
|
4871
|
+
required: required.includes(name),
|
|
4872
|
+
description: propSchema?.description
|
|
4873
|
+
};
|
|
4874
|
+
return specParamToNestedParam(propParam, `${parentName}.`);
|
|
4875
|
+
});
|
|
4876
|
+
}
|
|
4877
|
+
return [];
|
|
4878
|
+
}
|
|
4879
|
+
function extractEnumValues(schema) {
|
|
4880
|
+
if (!schema || typeof schema !== "object")
|
|
4881
|
+
return [];
|
|
4882
|
+
const s = schema;
|
|
4883
|
+
if (Array.isArray(s.enum)) {
|
|
4884
|
+
return s.enum.map((value) => ({
|
|
4885
|
+
value: String(value),
|
|
4886
|
+
description: undefined
|
|
4887
|
+
}));
|
|
4888
|
+
}
|
|
4889
|
+
return [];
|
|
4890
|
+
}
|
|
4891
|
+
function resolveSchemaRef(schema, types) {
|
|
4892
|
+
if (!schema || typeof schema !== "object")
|
|
4893
|
+
return schema;
|
|
4894
|
+
const s = schema;
|
|
4895
|
+
if (typeof s.$ref === "string") {
|
|
4896
|
+
const refPath = s.$ref;
|
|
4897
|
+
const parts = refPath.split("/");
|
|
4898
|
+
const typeName = parts[parts.length - 1];
|
|
4899
|
+
if (types[typeName]) {
|
|
4900
|
+
return types[typeName];
|
|
4901
|
+
}
|
|
4902
|
+
}
|
|
4903
|
+
return schema;
|
|
4904
|
+
}
|
|
4905
|
+
// src/components/styled/sections/ClassSection.tsx
|
|
4906
|
+
import { formatSchema as formatSchema5 } from "@openpkg-ts/sdk/browser";
|
|
4907
|
+
import { APIParameterItem as APIParameterItem2, APISection, ParameterList } from "@openpkg-ts/ui/docskit";
|
|
4908
|
+
import { jsx as jsx19, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
4909
|
+
|
|
3306
4910
|
function formatMethodSignature(member) {
|
|
3307
4911
|
const sig = member.signatures?.[0];
|
|
3308
4912
|
const params = sig?.parameters ?? [];
|
|
3309
|
-
const returnType =
|
|
3310
|
-
const paramStr = params.map((p) => `${p.name}${p.required === false ? "?" : ""}: ${
|
|
4913
|
+
const returnType = formatSchema5(sig?.returns?.schema);
|
|
4914
|
+
const paramStr = params.map((p) => `${p.name}${p.required === false ? "?" : ""}: ${formatSchema5(p.schema)}`).join(", ");
|
|
3311
4915
|
return `(${paramStr}): ${returnType}`;
|
|
3312
4916
|
}
|
|
3313
4917
|
function getMemberBadges(member) {
|
|
@@ -3373,20 +4977,20 @@ const instance = new ${exp.name}(${constructorParams.map((p) => p.name).join(",
|
|
|
3373
4977
|
exp.extends && `extends ${exp.extends}`,
|
|
3374
4978
|
exp.implements?.length && `implements ${exp.implements.join(", ")}`
|
|
3375
4979
|
].filter(Boolean).join(" ");
|
|
3376
|
-
return /* @__PURE__ */
|
|
4980
|
+
return /* @__PURE__ */ jsxs10(APISection, {
|
|
3377
4981
|
id: exp.id || exp.name,
|
|
3378
4982
|
title: `class ${exp.name}`,
|
|
3379
|
-
description: /* @__PURE__ */
|
|
4983
|
+
description: /* @__PURE__ */ jsxs10("div", {
|
|
3380
4984
|
className: "space-y-3",
|
|
3381
4985
|
children: [
|
|
3382
|
-
inheritance && /* @__PURE__ */
|
|
4986
|
+
inheritance && /* @__PURE__ */ jsx19("p", {
|
|
3383
4987
|
className: "font-mono text-sm text-muted-foreground",
|
|
3384
4988
|
children: inheritance
|
|
3385
4989
|
}),
|
|
3386
|
-
exp.description && /* @__PURE__ */
|
|
4990
|
+
exp.description && /* @__PURE__ */ jsx19("p", {
|
|
3387
4991
|
children: exp.description
|
|
3388
4992
|
}),
|
|
3389
|
-
/* @__PURE__ */
|
|
4993
|
+
/* @__PURE__ */ jsx19("code", {
|
|
3390
4994
|
className: "text-sm font-mono bg-muted px-2 py-1 rounded inline-block",
|
|
3391
4995
|
children: importStatement
|
|
3392
4996
|
})
|
|
@@ -3396,11 +5000,11 @@ const instance = new ${exp.name}(${constructorParams.map((p) => p.name).join(",
|
|
|
3396
5000
|
examples: displayExamples,
|
|
3397
5001
|
codePanelTitle: `new ${exp.name}()`,
|
|
3398
5002
|
children: [
|
|
3399
|
-
constructorParams.length > 0 && /* @__PURE__ */
|
|
5003
|
+
constructorParams.length > 0 && /* @__PURE__ */ jsx19(ParameterList, {
|
|
3400
5004
|
title: "Constructor",
|
|
3401
5005
|
children: constructorParams.map((param, index) => {
|
|
3402
5006
|
const apiParam = specParamToAPIParam(param);
|
|
3403
|
-
return /* @__PURE__ */
|
|
5007
|
+
return /* @__PURE__ */ jsx19(APIParameterItem2, {
|
|
3404
5008
|
name: apiParam.name,
|
|
3405
5009
|
type: apiParam.type,
|
|
3406
5010
|
required: apiParam.required,
|
|
@@ -3409,23 +5013,23 @@ const instance = new ${exp.name}(${constructorParams.map((p) => p.name).join(",
|
|
|
3409
5013
|
}, param.name ?? index);
|
|
3410
5014
|
})
|
|
3411
5015
|
}),
|
|
3412
|
-
(staticProperties.length > 0 || staticMethods.length > 0) && /* @__PURE__ */
|
|
5016
|
+
(staticProperties.length > 0 || staticMethods.length > 0) && /* @__PURE__ */ jsxs10(ParameterList, {
|
|
3413
5017
|
title: "Static Members",
|
|
3414
5018
|
className: "mt-6",
|
|
3415
5019
|
children: [
|
|
3416
5020
|
staticProperties.map((member) => {
|
|
3417
5021
|
const badges = getMemberBadges(member);
|
|
3418
5022
|
const desc = buildMemberDescription(member);
|
|
3419
|
-
return /* @__PURE__ */
|
|
5023
|
+
return /* @__PURE__ */ jsx19(APIParameterItem2, {
|
|
3420
5024
|
name: member.name,
|
|
3421
|
-
type:
|
|
5025
|
+
type: formatSchema5(member.schema),
|
|
3422
5026
|
description: badges.length > 0 ? `[${badges.join(", ")}] ${desc || ""}` : desc
|
|
3423
5027
|
}, member.name);
|
|
3424
5028
|
}),
|
|
3425
5029
|
staticMethods.map((member) => {
|
|
3426
5030
|
const badges = getMemberBadges(member);
|
|
3427
5031
|
const desc = buildMemberDescription(member);
|
|
3428
|
-
return /* @__PURE__ */
|
|
5032
|
+
return /* @__PURE__ */ jsx19(APIParameterItem2, {
|
|
3429
5033
|
name: `${member.name}()`,
|
|
3430
5034
|
type: formatMethodSignature(member),
|
|
3431
5035
|
description: badges.length > 0 ? `[${badges.join(", ")}] ${desc || ""}` : desc
|
|
@@ -3433,28 +5037,28 @@ const instance = new ${exp.name}(${constructorParams.map((p) => p.name).join(",
|
|
|
3433
5037
|
})
|
|
3434
5038
|
]
|
|
3435
5039
|
}),
|
|
3436
|
-
instanceMethods.length > 0 && /* @__PURE__ */
|
|
5040
|
+
instanceMethods.length > 0 && /* @__PURE__ */ jsx19(ParameterList, {
|
|
3437
5041
|
title: "Methods",
|
|
3438
5042
|
className: "mt-6",
|
|
3439
5043
|
children: instanceMethods.map((member) => {
|
|
3440
5044
|
const badges = getMemberBadges(member);
|
|
3441
5045
|
const desc = buildMemberDescription(member);
|
|
3442
|
-
return /* @__PURE__ */
|
|
5046
|
+
return /* @__PURE__ */ jsx19(APIParameterItem2, {
|
|
3443
5047
|
name: `${member.name}()`,
|
|
3444
5048
|
type: formatMethodSignature(member),
|
|
3445
5049
|
description: badges.length > 0 ? `[${badges.join(", ")}] ${desc || ""}` : desc
|
|
3446
5050
|
}, member.name);
|
|
3447
5051
|
})
|
|
3448
5052
|
}),
|
|
3449
|
-
instanceProperties.length > 0 && /* @__PURE__ */
|
|
5053
|
+
instanceProperties.length > 0 && /* @__PURE__ */ jsx19(ParameterList, {
|
|
3450
5054
|
title: "Properties",
|
|
3451
5055
|
className: "mt-6",
|
|
3452
5056
|
children: instanceProperties.map((member) => {
|
|
3453
5057
|
const badges = getMemberBadges(member);
|
|
3454
5058
|
const desc = buildMemberDescription(member);
|
|
3455
|
-
return /* @__PURE__ */
|
|
5059
|
+
return /* @__PURE__ */ jsx19(APIParameterItem2, {
|
|
3456
5060
|
name: member.name,
|
|
3457
|
-
type:
|
|
5061
|
+
type: formatSchema5(member.schema),
|
|
3458
5062
|
description: badges.length > 0 ? `[${badges.join(", ")}] ${desc || ""}` : desc
|
|
3459
5063
|
}, member.name);
|
|
3460
5064
|
})
|
|
@@ -3464,12 +5068,12 @@ const instance = new ${exp.name}(${constructorParams.map((p) => p.name).join(",
|
|
|
3464
5068
|
}
|
|
3465
5069
|
|
|
3466
5070
|
// src/components/styled/ClassPage.tsx
|
|
3467
|
-
import { jsx as
|
|
5071
|
+
import { jsx as jsx20 } from "react/jsx-runtime";
|
|
3468
5072
|
|
|
3469
5073
|
function ClassPage({ export: exp, spec }) {
|
|
3470
|
-
return /* @__PURE__ */
|
|
5074
|
+
return /* @__PURE__ */ jsx20("div", {
|
|
3471
5075
|
className: "doccov-class-page not-prose",
|
|
3472
|
-
children: /* @__PURE__ */
|
|
5076
|
+
children: /* @__PURE__ */ jsx20(ClassSection, {
|
|
3473
5077
|
export: exp,
|
|
3474
5078
|
spec
|
|
3475
5079
|
})
|
|
@@ -3477,8 +5081,8 @@ function ClassPage({ export: exp, spec }) {
|
|
|
3477
5081
|
}
|
|
3478
5082
|
|
|
3479
5083
|
// src/components/styled/sections/EnumSection.tsx
|
|
3480
|
-
import { APIParameterItem as
|
|
3481
|
-
import { jsx as
|
|
5084
|
+
import { APIParameterItem as APIParameterItem3, APISection as APISection2, ParameterList as ParameterList2 } from "@openpkg-ts/ui/docskit";
|
|
5085
|
+
import { jsx as jsx21, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
3482
5086
|
|
|
3483
5087
|
function EnumSection({ export: exp, spec }) {
|
|
3484
5088
|
const members = exp.members ?? [];
|
|
@@ -3502,25 +5106,25 @@ ${enumDefinition}`,
|
|
|
3502
5106
|
}
|
|
3503
5107
|
];
|
|
3504
5108
|
const displayLanguages = languages.length > 0 ? languages : [{ id: "typescript", label: "TypeScript" }];
|
|
3505
|
-
return /* @__PURE__ */
|
|
5109
|
+
return /* @__PURE__ */ jsx21(APISection2, {
|
|
3506
5110
|
id: exp.id || exp.name,
|
|
3507
5111
|
title: `enum ${exp.name}`,
|
|
3508
|
-
description: /* @__PURE__ */
|
|
5112
|
+
description: /* @__PURE__ */ jsxs11("div", {
|
|
3509
5113
|
className: "space-y-3",
|
|
3510
5114
|
children: [
|
|
3511
|
-
exp.description && /* @__PURE__ */
|
|
5115
|
+
exp.description && /* @__PURE__ */ jsx21("p", {
|
|
3512
5116
|
children: exp.description
|
|
3513
5117
|
}),
|
|
3514
|
-
exp.deprecated && /* @__PURE__ */
|
|
5118
|
+
exp.deprecated && /* @__PURE__ */ jsxs11("div", {
|
|
3515
5119
|
className: "rounded-md bg-yellow-500/10 border border-yellow-500/20 px-3 py-2 text-sm text-yellow-600 dark:text-yellow-400",
|
|
3516
5120
|
children: [
|
|
3517
|
-
/* @__PURE__ */
|
|
5121
|
+
/* @__PURE__ */ jsx21("strong", {
|
|
3518
5122
|
children: "Deprecated:"
|
|
3519
5123
|
}),
|
|
3520
5124
|
" This export is deprecated."
|
|
3521
5125
|
]
|
|
3522
5126
|
}),
|
|
3523
|
-
/* @__PURE__ */
|
|
5127
|
+
/* @__PURE__ */ jsx21("code", {
|
|
3524
5128
|
className: "text-sm font-mono bg-muted px-2 py-1 rounded inline-block",
|
|
3525
5129
|
children: importStatement
|
|
3526
5130
|
})
|
|
@@ -3529,11 +5133,11 @@ ${enumDefinition}`,
|
|
|
3529
5133
|
languages: displayLanguages,
|
|
3530
5134
|
examples: displayExamples,
|
|
3531
5135
|
codePanelTitle: exp.name,
|
|
3532
|
-
children: members.length > 0 && /* @__PURE__ */
|
|
5136
|
+
children: members.length > 0 && /* @__PURE__ */ jsx21(ParameterList2, {
|
|
3533
5137
|
title: "Members",
|
|
3534
5138
|
children: members.map((member, index) => {
|
|
3535
5139
|
const value = member.schema !== undefined ? typeof member.schema === "object" && member.schema !== null ? member.schema.const ?? member.schema.default ?? undefined : member.schema : undefined;
|
|
3536
|
-
return /* @__PURE__ */
|
|
5140
|
+
return /* @__PURE__ */ jsx21(APIParameterItem3, {
|
|
3537
5141
|
name: member.name,
|
|
3538
5142
|
type: value !== undefined ? String(value) : "auto",
|
|
3539
5143
|
description: member.description
|
|
@@ -3544,12 +5148,12 @@ ${enumDefinition}`,
|
|
|
3544
5148
|
}
|
|
3545
5149
|
|
|
3546
5150
|
// src/components/styled/EnumPage.tsx
|
|
3547
|
-
import { jsx as
|
|
5151
|
+
import { jsx as jsx22 } from "react/jsx-runtime";
|
|
3548
5152
|
|
|
3549
5153
|
function EnumPage({ export: exp, spec }) {
|
|
3550
|
-
return /* @__PURE__ */
|
|
5154
|
+
return /* @__PURE__ */ jsx22("div", {
|
|
3551
5155
|
className: "doccov-enum-page not-prose",
|
|
3552
|
-
children: /* @__PURE__ */
|
|
5156
|
+
children: /* @__PURE__ */ jsx22(EnumSection, {
|
|
3553
5157
|
export: exp,
|
|
3554
5158
|
spec
|
|
3555
5159
|
})
|
|
@@ -3557,14 +5161,14 @@ function EnumPage({ export: exp, spec }) {
|
|
|
3557
5161
|
}
|
|
3558
5162
|
|
|
3559
5163
|
// src/components/styled/ExportIndexPage.tsx
|
|
3560
|
-
import { cn as
|
|
5164
|
+
import { cn as cn15 } from "@openpkg-ts/ui/lib/utils";
|
|
3561
5165
|
import { Search } from "lucide-react";
|
|
3562
|
-
import { useMemo, useState } from "react";
|
|
5166
|
+
import { useMemo as useMemo7, useState as useState9 } from "react";
|
|
3563
5167
|
|
|
3564
5168
|
// src/components/styled/ExportCard.tsx
|
|
3565
5169
|
var import_link = __toESM(require_link(), 1);
|
|
3566
|
-
import { cn } from "@openpkg-ts/ui/lib/utils";
|
|
3567
|
-
import { jsx as
|
|
5170
|
+
import { cn as cn14 } from "@openpkg-ts/ui/lib/utils";
|
|
5171
|
+
import { jsx as jsx23, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
3568
5172
|
|
|
3569
5173
|
var KIND_COLORS = {
|
|
3570
5174
|
function: "group-hover:text-blue-600 dark:group-hover:text-blue-400",
|
|
@@ -3589,31 +5193,31 @@ function ExportCard({
|
|
|
3589
5193
|
kind = "function",
|
|
3590
5194
|
className
|
|
3591
5195
|
}) {
|
|
3592
|
-
const
|
|
5196
|
+
const isFunction2 = kind === "function";
|
|
3593
5197
|
const hoverColor = KIND_COLORS[kind];
|
|
3594
5198
|
const badgeColor = KIND_BADGE_COLORS[kind];
|
|
3595
|
-
return /* @__PURE__ */
|
|
5199
|
+
return /* @__PURE__ */ jsxs12(import_link.default, {
|
|
3596
5200
|
href,
|
|
3597
|
-
className:
|
|
5201
|
+
className: cn14("group block rounded-lg border border-border bg-card/50 p-4", "transition-all duration-200 ease-out", "hover:border-primary/30 hover:bg-card hover:shadow-lg hover:shadow-primary/5", "hover:-translate-y-1", "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", className),
|
|
3598
5202
|
children: [
|
|
3599
|
-
/* @__PURE__ */
|
|
5203
|
+
/* @__PURE__ */ jsxs12("div", {
|
|
3600
5204
|
className: "flex items-center gap-2 mb-2",
|
|
3601
5205
|
children: [
|
|
3602
|
-
/* @__PURE__ */
|
|
3603
|
-
className:
|
|
5206
|
+
/* @__PURE__ */ jsx23("span", {
|
|
5207
|
+
className: cn14("font-mono text-base font-medium text-foreground transition-colors duration-200", hoverColor),
|
|
3604
5208
|
children: name
|
|
3605
5209
|
}),
|
|
3606
|
-
|
|
5210
|
+
isFunction2 && /* @__PURE__ */ jsx23("span", {
|
|
3607
5211
|
className: "font-mono text-base text-muted-foreground",
|
|
3608
5212
|
children: "()"
|
|
3609
5213
|
}),
|
|
3610
|
-
/* @__PURE__ */
|
|
3611
|
-
className:
|
|
5214
|
+
/* @__PURE__ */ jsx23("span", {
|
|
5215
|
+
className: cn14("ml-auto text-xs px-2 py-0.5 rounded-full font-medium", badgeColor),
|
|
3612
5216
|
children: kind
|
|
3613
5217
|
})
|
|
3614
5218
|
]
|
|
3615
5219
|
}),
|
|
3616
|
-
description && /* @__PURE__ */
|
|
5220
|
+
description && /* @__PURE__ */ jsx23("p", {
|
|
3617
5221
|
className: "text-sm text-muted-foreground line-clamp-2 leading-relaxed group-hover:text-muted-foreground/80 transition-colors",
|
|
3618
5222
|
children: description
|
|
3619
5223
|
})
|
|
@@ -3622,7 +5226,7 @@ function ExportCard({
|
|
|
3622
5226
|
}
|
|
3623
5227
|
|
|
3624
5228
|
// src/components/styled/ExportIndexPage.tsx
|
|
3625
|
-
import { jsx as
|
|
5229
|
+
import { jsx as jsx24, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
3626
5230
|
|
|
3627
5231
|
var KIND_ORDER = ["function", "class", "interface", "type", "enum", "variable"];
|
|
3628
5232
|
var KIND_LABELS = {
|
|
@@ -3664,11 +5268,11 @@ function ExportIndexPage({
|
|
|
3664
5268
|
showSearch = true,
|
|
3665
5269
|
showFilters = true
|
|
3666
5270
|
}) {
|
|
3667
|
-
const [searchQuery, setSearchQuery] =
|
|
3668
|
-
const [activeFilter, setActiveFilter] =
|
|
5271
|
+
const [searchQuery, setSearchQuery] = useState9("");
|
|
5272
|
+
const [activeFilter, setActiveFilter] = useState9("all");
|
|
3669
5273
|
if (false) {}
|
|
3670
|
-
const allGroups =
|
|
3671
|
-
const filteredGroups =
|
|
5274
|
+
const allGroups = useMemo7(() => groupByKind(spec.exports), [spec.exports]);
|
|
5275
|
+
const filteredGroups = useMemo7(() => {
|
|
3672
5276
|
const query = searchQuery.toLowerCase().trim();
|
|
3673
5277
|
return allGroups.filter((group) => activeFilter === "all" || group.kind === activeFilter).map((group) => ({
|
|
3674
5278
|
...group,
|
|
@@ -3679,62 +5283,62 @@ function ExportIndexPage({
|
|
|
3679
5283
|
})
|
|
3680
5284
|
})).filter((group) => group.exports.length > 0);
|
|
3681
5285
|
}, [allGroups, searchQuery, activeFilter]);
|
|
3682
|
-
const availableKinds =
|
|
5286
|
+
const availableKinds = useMemo7(() => allGroups.map((g) => g.kind), [allGroups]);
|
|
3683
5287
|
const totalExports = filteredGroups.reduce((sum, g) => sum + g.exports.length, 0);
|
|
3684
|
-
return /* @__PURE__ */
|
|
3685
|
-
className:
|
|
5288
|
+
return /* @__PURE__ */ jsxs13("div", {
|
|
5289
|
+
className: cn15("doccov-index-page space-y-8 not-prose", className),
|
|
3686
5290
|
children: [
|
|
3687
|
-
/* @__PURE__ */
|
|
5291
|
+
/* @__PURE__ */ jsxs13("div", {
|
|
3688
5292
|
children: [
|
|
3689
|
-
/* @__PURE__ */
|
|
5293
|
+
/* @__PURE__ */ jsx24("h1", {
|
|
3690
5294
|
className: "text-3xl font-bold text-foreground mb-3",
|
|
3691
5295
|
children: spec.meta.name || "API Reference"
|
|
3692
5296
|
}),
|
|
3693
|
-
(description || spec.meta.description) && /* @__PURE__ */
|
|
5297
|
+
(description || spec.meta.description) && /* @__PURE__ */ jsx24("p", {
|
|
3694
5298
|
className: "text-muted-foreground text-lg leading-relaxed max-w-3xl",
|
|
3695
5299
|
children: description || spec.meta.description
|
|
3696
5300
|
})
|
|
3697
5301
|
]
|
|
3698
5302
|
}),
|
|
3699
|
-
(showSearch || showFilters) && /* @__PURE__ */
|
|
5303
|
+
(showSearch || showFilters) && /* @__PURE__ */ jsxs13("div", {
|
|
3700
5304
|
className: "space-y-4",
|
|
3701
5305
|
children: [
|
|
3702
|
-
showSearch && /* @__PURE__ */
|
|
5306
|
+
showSearch && /* @__PURE__ */ jsxs13("div", {
|
|
3703
5307
|
className: "relative max-w-md",
|
|
3704
5308
|
children: [
|
|
3705
|
-
/* @__PURE__ */
|
|
5309
|
+
/* @__PURE__ */ jsx24(Search, {
|
|
3706
5310
|
size: 18,
|
|
3707
5311
|
className: "absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"
|
|
3708
5312
|
}),
|
|
3709
|
-
/* @__PURE__ */
|
|
5313
|
+
/* @__PURE__ */ jsx24("input", {
|
|
3710
5314
|
type: "text",
|
|
3711
5315
|
placeholder: "Search exports...",
|
|
3712
5316
|
value: searchQuery,
|
|
3713
5317
|
onChange: (e) => setSearchQuery(e.target.value),
|
|
3714
|
-
className:
|
|
5318
|
+
className: cn15("w-full pl-10 pr-4 py-2 rounded-lg", "border border-border bg-background", "text-sm text-foreground placeholder:text-muted-foreground", "focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent", "transition-shadow")
|
|
3715
5319
|
})
|
|
3716
5320
|
]
|
|
3717
5321
|
}),
|
|
3718
|
-
showFilters && availableKinds.length > 1 && /* @__PURE__ */
|
|
5322
|
+
showFilters && availableKinds.length > 1 && /* @__PURE__ */ jsxs13("div", {
|
|
3719
5323
|
className: "flex flex-wrap gap-2",
|
|
3720
5324
|
children: [
|
|
3721
|
-
/* @__PURE__ */
|
|
5325
|
+
/* @__PURE__ */ jsx24("button", {
|
|
3722
5326
|
type: "button",
|
|
3723
5327
|
onClick: () => setActiveFilter("all"),
|
|
3724
|
-
className:
|
|
5328
|
+
className: cn15("px-3 py-1.5 text-sm rounded-md transition-all cursor-pointer", activeFilter === "all" ? "bg-primary text-primary-foreground font-medium" : "bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),
|
|
3725
5329
|
children: "All"
|
|
3726
5330
|
}),
|
|
3727
|
-
availableKinds.map((kind) => /* @__PURE__ */
|
|
5331
|
+
availableKinds.map((kind) => /* @__PURE__ */ jsx24("button", {
|
|
3728
5332
|
type: "button",
|
|
3729
5333
|
onClick: () => setActiveFilter(kind),
|
|
3730
|
-
className:
|
|
5334
|
+
className: cn15("px-3 py-1.5 text-sm rounded-md transition-all cursor-pointer", activeFilter === kind ? "bg-primary text-primary-foreground font-medium" : "bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),
|
|
3731
5335
|
children: KIND_LABELS[kind]
|
|
3732
5336
|
}, kind))
|
|
3733
5337
|
]
|
|
3734
5338
|
})
|
|
3735
5339
|
]
|
|
3736
5340
|
}),
|
|
3737
|
-
(searchQuery || activeFilter !== "all") && /* @__PURE__ */
|
|
5341
|
+
(searchQuery || activeFilter !== "all") && /* @__PURE__ */ jsxs13("p", {
|
|
3738
5342
|
className: "text-sm text-muted-foreground",
|
|
3739
5343
|
children: [
|
|
3740
5344
|
totalExports,
|
|
@@ -3743,15 +5347,15 @@ function ExportIndexPage({
|
|
|
3743
5347
|
searchQuery && ` for "${searchQuery}"`
|
|
3744
5348
|
]
|
|
3745
5349
|
}),
|
|
3746
|
-
filteredGroups.map((group) => /* @__PURE__ */
|
|
5350
|
+
filteredGroups.map((group) => /* @__PURE__ */ jsxs13("section", {
|
|
3747
5351
|
children: [
|
|
3748
|
-
/* @__PURE__ */
|
|
5352
|
+
/* @__PURE__ */ jsx24("h2", {
|
|
3749
5353
|
className: "text-sm font-semibold uppercase tracking-wide text-muted-foreground mb-4",
|
|
3750
5354
|
children: group.label
|
|
3751
5355
|
}),
|
|
3752
|
-
/* @__PURE__ */
|
|
5356
|
+
/* @__PURE__ */ jsx24("div", {
|
|
3753
5357
|
className: "grid grid-cols-1 md:grid-cols-2 gap-4",
|
|
3754
|
-
children: group.exports.map((exp) => /* @__PURE__ */
|
|
5358
|
+
children: group.exports.map((exp) => /* @__PURE__ */ jsx24(ExportCard, {
|
|
3755
5359
|
name: exp.name,
|
|
3756
5360
|
description: exp.description,
|
|
3757
5361
|
href: `${baseHref}/${KIND_SLUGS[group.kind]}/${exp.id}`,
|
|
@@ -3760,14 +5364,14 @@ function ExportIndexPage({
|
|
|
3760
5364
|
})
|
|
3761
5365
|
]
|
|
3762
5366
|
}, group.kind)),
|
|
3763
|
-
filteredGroups.length === 0 && /* @__PURE__ */
|
|
5367
|
+
filteredGroups.length === 0 && /* @__PURE__ */ jsxs13("div", {
|
|
3764
5368
|
className: "rounded-lg border border-border bg-card/50 p-8 text-center",
|
|
3765
5369
|
children: [
|
|
3766
|
-
/* @__PURE__ */
|
|
5370
|
+
/* @__PURE__ */ jsx24("p", {
|
|
3767
5371
|
className: "text-muted-foreground",
|
|
3768
5372
|
children: searchQuery || activeFilter !== "all" ? "No exports match your search." : "No exports found in this package."
|
|
3769
5373
|
}),
|
|
3770
|
-
(searchQuery || activeFilter !== "all") && /* @__PURE__ */
|
|
5374
|
+
(searchQuery || activeFilter !== "all") && /* @__PURE__ */ jsx24("button", {
|
|
3771
5375
|
type: "button",
|
|
3772
5376
|
onClick: () => {
|
|
3773
5377
|
setSearchQuery("");
|
|
@@ -3783,9 +5387,9 @@ function ExportIndexPage({
|
|
|
3783
5387
|
}
|
|
3784
5388
|
|
|
3785
5389
|
// src/components/styled/sections/FunctionSection.tsx
|
|
3786
|
-
import { formatSchema as
|
|
3787
|
-
import { APIParameterItem as
|
|
3788
|
-
import { jsx as
|
|
5390
|
+
import { formatSchema as formatSchema6 } from "@openpkg-ts/sdk/browser";
|
|
5391
|
+
import { APIParameterItem as APIParameterItem4, APISection as APISection3, ParameterList as ParameterList3, ResponseBlock } from "@openpkg-ts/ui/docskit";
|
|
5392
|
+
import { jsx as jsx25, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
3789
5393
|
|
|
3790
5394
|
function FunctionSection({ export: exp, spec }) {
|
|
3791
5395
|
const sig = exp.signatures?.[0];
|
|
@@ -3804,16 +5408,16 @@ ${exp.name}(${sig?.parameters?.map((p) => p.name).join(", ") || ""})`,
|
|
|
3804
5408
|
}
|
|
3805
5409
|
];
|
|
3806
5410
|
const displayLanguages = languages.length > 0 ? languages : [{ id: "typescript", label: "TypeScript" }];
|
|
3807
|
-
return /* @__PURE__ */
|
|
5411
|
+
return /* @__PURE__ */ jsxs14(APISection3, {
|
|
3808
5412
|
id: exp.id || exp.name,
|
|
3809
5413
|
title: `${exp.name}()`,
|
|
3810
|
-
description: /* @__PURE__ */
|
|
5414
|
+
description: /* @__PURE__ */ jsxs14("div", {
|
|
3811
5415
|
className: "space-y-3",
|
|
3812
5416
|
children: [
|
|
3813
|
-
exp.description && /* @__PURE__ */
|
|
5417
|
+
exp.description && /* @__PURE__ */ jsx25("p", {
|
|
3814
5418
|
children: exp.description
|
|
3815
5419
|
}),
|
|
3816
|
-
/* @__PURE__ */
|
|
5420
|
+
/* @__PURE__ */ jsx25("code", {
|
|
3817
5421
|
className: "text-sm font-mono bg-muted px-2 py-1 rounded inline-block",
|
|
3818
5422
|
children: importStatement
|
|
3819
5423
|
})
|
|
@@ -3823,11 +5427,11 @@ ${exp.name}(${sig?.parameters?.map((p) => p.name).join(", ") || ""})`,
|
|
|
3823
5427
|
examples: displayExamples,
|
|
3824
5428
|
codePanelTitle: `${exp.name}()`,
|
|
3825
5429
|
children: [
|
|
3826
|
-
hasParams && /* @__PURE__ */
|
|
5430
|
+
hasParams && /* @__PURE__ */ jsx25(ParameterList3, {
|
|
3827
5431
|
title: "Parameters",
|
|
3828
5432
|
children: sig.parameters.map((param, index) => {
|
|
3829
5433
|
const apiParam = specParamToAPIParam(param);
|
|
3830
|
-
return /* @__PURE__ */
|
|
5434
|
+
return /* @__PURE__ */ jsx25(APIParameterItem4, {
|
|
3831
5435
|
name: apiParam.name,
|
|
3832
5436
|
type: apiParam.type,
|
|
3833
5437
|
required: apiParam.required,
|
|
@@ -3836,14 +5440,14 @@ ${exp.name}(${sig?.parameters?.map((p) => p.name).join(", ") || ""})`,
|
|
|
3836
5440
|
}, param.name ?? index);
|
|
3837
5441
|
})
|
|
3838
5442
|
}),
|
|
3839
|
-
sig?.returns && /* @__PURE__ */
|
|
3840
|
-
description: /* @__PURE__ */
|
|
5443
|
+
sig?.returns && /* @__PURE__ */ jsx25(ResponseBlock, {
|
|
5444
|
+
description: /* @__PURE__ */ jsxs14("span", {
|
|
3841
5445
|
children: [
|
|
3842
|
-
/* @__PURE__ */
|
|
5446
|
+
/* @__PURE__ */ jsx25("span", {
|
|
3843
5447
|
className: "font-mono text-sm font-medium",
|
|
3844
|
-
children:
|
|
5448
|
+
children: formatSchema6(sig.returns.schema)
|
|
3845
5449
|
}),
|
|
3846
|
-
sig.returns.description && /* @__PURE__ */
|
|
5450
|
+
sig.returns.description && /* @__PURE__ */ jsx25("span", {
|
|
3847
5451
|
className: "ml-2 text-muted-foreground",
|
|
3848
5452
|
children: sig.returns.description
|
|
3849
5453
|
})
|
|
@@ -3851,27 +5455,27 @@ ${exp.name}(${sig?.parameters?.map((p) => p.name).join(", ") || ""})`,
|
|
|
3851
5455
|
}),
|
|
3852
5456
|
className: "mt-6"
|
|
3853
5457
|
}),
|
|
3854
|
-
sig?.throws && sig.throws.length > 0 && /* @__PURE__ */
|
|
5458
|
+
sig?.throws && sig.throws.length > 0 && /* @__PURE__ */ jsxs14("div", {
|
|
3855
5459
|
className: "mt-6 rounded-md bg-destructive/10 border border-destructive/20 p-4",
|
|
3856
5460
|
children: [
|
|
3857
|
-
/* @__PURE__ */
|
|
5461
|
+
/* @__PURE__ */ jsx25("h4", {
|
|
3858
5462
|
className: "text-xs font-semibold uppercase tracking-wide text-destructive mb-2",
|
|
3859
5463
|
children: "Throws"
|
|
3860
5464
|
}),
|
|
3861
|
-
/* @__PURE__ */
|
|
5465
|
+
/* @__PURE__ */ jsx25("div", {
|
|
3862
5466
|
className: "space-y-1",
|
|
3863
|
-
children: sig.throws.map((t, i) => /* @__PURE__ */
|
|
5467
|
+
children: sig.throws.map((t, i) => /* @__PURE__ */ jsxs14("div", {
|
|
3864
5468
|
className: "text-sm",
|
|
3865
5469
|
children: [
|
|
3866
|
-
t.type && /* @__PURE__ */
|
|
5470
|
+
t.type && /* @__PURE__ */ jsx25("code", {
|
|
3867
5471
|
className: "font-mono text-destructive",
|
|
3868
5472
|
children: t.type
|
|
3869
5473
|
}),
|
|
3870
|
-
t.type && t.description && /* @__PURE__ */
|
|
5474
|
+
t.type && t.description && /* @__PURE__ */ jsx25("span", {
|
|
3871
5475
|
className: "mx-1",
|
|
3872
5476
|
children: "—"
|
|
3873
5477
|
}),
|
|
3874
|
-
t.description && /* @__PURE__ */
|
|
5478
|
+
t.description && /* @__PURE__ */ jsx25("span", {
|
|
3875
5479
|
className: "text-muted-foreground",
|
|
3876
5480
|
children: t.description
|
|
3877
5481
|
})
|
|
@@ -3880,10 +5484,10 @@ ${exp.name}(${sig?.parameters?.map((p) => p.name).join(", ") || ""})`,
|
|
|
3880
5484
|
})
|
|
3881
5485
|
]
|
|
3882
5486
|
}),
|
|
3883
|
-
exp.typeParameters && exp.typeParameters.length > 0 && /* @__PURE__ */
|
|
5487
|
+
exp.typeParameters && exp.typeParameters.length > 0 && /* @__PURE__ */ jsx25(ParameterList3, {
|
|
3884
5488
|
title: "Type Parameters",
|
|
3885
5489
|
className: "mt-6",
|
|
3886
|
-
children: exp.typeParameters.map((tp) => /* @__PURE__ */
|
|
5490
|
+
children: exp.typeParameters.map((tp) => /* @__PURE__ */ jsx25(APIParameterItem4, {
|
|
3887
5491
|
name: tp.name,
|
|
3888
5492
|
type: tp.constraint || "unknown",
|
|
3889
5493
|
description: tp.default ? `Default: ${tp.default}` : undefined
|
|
@@ -3894,12 +5498,12 @@ ${exp.name}(${sig?.parameters?.map((p) => p.name).join(", ") || ""})`,
|
|
|
3894
5498
|
}
|
|
3895
5499
|
|
|
3896
5500
|
// src/components/styled/FunctionPage.tsx
|
|
3897
|
-
import { jsx as
|
|
5501
|
+
import { jsx as jsx26 } from "react/jsx-runtime";
|
|
3898
5502
|
|
|
3899
5503
|
function FunctionPage({ export: exp, spec }) {
|
|
3900
|
-
return /* @__PURE__ */
|
|
5504
|
+
return /* @__PURE__ */ jsx26("div", {
|
|
3901
5505
|
className: "doccov-function-page not-prose",
|
|
3902
|
-
children: /* @__PURE__ */
|
|
5506
|
+
children: /* @__PURE__ */ jsx26(FunctionSection, {
|
|
3903
5507
|
export: exp,
|
|
3904
5508
|
spec
|
|
3905
5509
|
})
|
|
@@ -3907,15 +5511,15 @@ function FunctionPage({ export: exp, spec }) {
|
|
|
3907
5511
|
}
|
|
3908
5512
|
|
|
3909
5513
|
// src/components/styled/sections/InterfaceSection.tsx
|
|
3910
|
-
import { formatSchema as
|
|
3911
|
-
import { APIParameterItem as
|
|
3912
|
-
import { jsx as
|
|
5514
|
+
import { formatSchema as formatSchema7 } from "@openpkg-ts/sdk/browser";
|
|
5515
|
+
import { APIParameterItem as APIParameterItem5, APISection as APISection4, ParameterList as ParameterList4 } from "@openpkg-ts/ui/docskit";
|
|
5516
|
+
import { jsx as jsx27, jsxs as jsxs15 } from "react/jsx-runtime";
|
|
3913
5517
|
|
|
3914
5518
|
function formatMethodSignature2(member) {
|
|
3915
5519
|
const sig = member.signatures?.[0];
|
|
3916
5520
|
const params = sig?.parameters ?? [];
|
|
3917
|
-
const returnType =
|
|
3918
|
-
const paramStr = params.map((p) => `${p.name}${p.required === false ? "?" : ""}: ${
|
|
5521
|
+
const returnType = formatSchema7(sig?.returns?.schema);
|
|
5522
|
+
const paramStr = params.map((p) => `${p.name}${p.required === false ? "?" : ""}: ${formatSchema7(p.schema)}`).join(", ");
|
|
3919
5523
|
return `(${paramStr}): ${returnType}`;
|
|
3920
5524
|
}
|
|
3921
5525
|
function formatDecorators2(decorators) {
|
|
@@ -3942,7 +5546,7 @@ function InterfaceSection({ export: exp, spec }) {
|
|
|
3942
5546
|
const examples = specExamplesToCodeExamples(exp.examples);
|
|
3943
5547
|
const importStatement = buildImportStatement(exp, spec);
|
|
3944
5548
|
const typeDefinition = properties.length > 0 ? `${exp.kind === "type" ? "type" : "interface"} ${exp.name} {
|
|
3945
|
-
${properties.map((p) => ` ${p.name}${p.required === false ? "?" : ""}: ${
|
|
5549
|
+
${properties.map((p) => ` ${p.name}${p.required === false ? "?" : ""}: ${formatSchema7(p.schema)};`).join(`
|
|
3946
5550
|
`)}
|
|
3947
5551
|
}` : `${exp.kind === "type" ? "type" : "interface"} ${exp.name} { }`;
|
|
3948
5552
|
const displayExamples = examples.length > 0 ? examples : [
|
|
@@ -3956,32 +5560,32 @@ ${typeDefinition}`,
|
|
|
3956
5560
|
];
|
|
3957
5561
|
const displayLanguages = languages.length > 0 ? languages : [{ id: "typescript", label: "TypeScript" }];
|
|
3958
5562
|
const kindLabel = exp.kind === "type" ? "type" : "interface";
|
|
3959
|
-
return /* @__PURE__ */
|
|
5563
|
+
return /* @__PURE__ */ jsxs15(APISection4, {
|
|
3960
5564
|
id: exp.id || exp.name,
|
|
3961
5565
|
title: `${kindLabel} ${exp.name}`,
|
|
3962
|
-
description: /* @__PURE__ */
|
|
5566
|
+
description: /* @__PURE__ */ jsxs15("div", {
|
|
3963
5567
|
className: "space-y-3",
|
|
3964
5568
|
children: [
|
|
3965
|
-
exp.extends && /* @__PURE__ */
|
|
5569
|
+
exp.extends && /* @__PURE__ */ jsxs15("p", {
|
|
3966
5570
|
className: "font-mono text-sm text-muted-foreground",
|
|
3967
5571
|
children: [
|
|
3968
5572
|
"extends ",
|
|
3969
5573
|
exp.extends
|
|
3970
5574
|
]
|
|
3971
5575
|
}),
|
|
3972
|
-
exp.description && /* @__PURE__ */
|
|
5576
|
+
exp.description && /* @__PURE__ */ jsx27("p", {
|
|
3973
5577
|
children: exp.description
|
|
3974
5578
|
}),
|
|
3975
|
-
exp.deprecated && /* @__PURE__ */
|
|
5579
|
+
exp.deprecated && /* @__PURE__ */ jsxs15("div", {
|
|
3976
5580
|
className: "rounded-md bg-yellow-500/10 border border-yellow-500/20 px-3 py-2 text-sm text-yellow-600 dark:text-yellow-400",
|
|
3977
5581
|
children: [
|
|
3978
|
-
/* @__PURE__ */
|
|
5582
|
+
/* @__PURE__ */ jsx27("strong", {
|
|
3979
5583
|
children: "Deprecated:"
|
|
3980
5584
|
}),
|
|
3981
5585
|
" This export is deprecated."
|
|
3982
5586
|
]
|
|
3983
5587
|
}),
|
|
3984
|
-
/* @__PURE__ */
|
|
5588
|
+
/* @__PURE__ */ jsx27("code", {
|
|
3985
5589
|
className: "text-sm font-mono bg-muted px-2 py-1 rounded inline-block",
|
|
3986
5590
|
children: importStatement
|
|
3987
5591
|
})
|
|
@@ -3991,13 +5595,13 @@ ${typeDefinition}`,
|
|
|
3991
5595
|
examples: displayExamples,
|
|
3992
5596
|
codePanelTitle: exp.name,
|
|
3993
5597
|
children: [
|
|
3994
|
-
properties.length > 0 && /* @__PURE__ */
|
|
5598
|
+
properties.length > 0 && /* @__PURE__ */ jsx27(ParameterList4, {
|
|
3995
5599
|
title: "Properties",
|
|
3996
5600
|
children: properties.map((prop, index) => {
|
|
3997
|
-
const type =
|
|
5601
|
+
const type = formatSchema7(prop.schema);
|
|
3998
5602
|
const children = specSchemaToAPISchema(prop.schema);
|
|
3999
5603
|
const hasNestedProperties = children?.properties && Object.keys(children.properties).length > 0;
|
|
4000
|
-
return /* @__PURE__ */
|
|
5604
|
+
return /* @__PURE__ */ jsx27(APIParameterItem5, {
|
|
4001
5605
|
name: prop.name,
|
|
4002
5606
|
type,
|
|
4003
5607
|
description: buildMemberDescription2(prop),
|
|
@@ -4005,10 +5609,10 @@ ${typeDefinition}`,
|
|
|
4005
5609
|
}, prop.name ?? index);
|
|
4006
5610
|
})
|
|
4007
5611
|
}),
|
|
4008
|
-
methods.length > 0 && /* @__PURE__ */
|
|
5612
|
+
methods.length > 0 && /* @__PURE__ */ jsx27(ParameterList4, {
|
|
4009
5613
|
title: "Methods",
|
|
4010
5614
|
className: "mt-6",
|
|
4011
|
-
children: methods.map((method, index) => /* @__PURE__ */
|
|
5615
|
+
children: methods.map((method, index) => /* @__PURE__ */ jsx27(APIParameterItem5, {
|
|
4012
5616
|
name: `${method.name}()`,
|
|
4013
5617
|
type: formatMethodSignature2(method),
|
|
4014
5618
|
description: buildMemberDescription2(method)
|
|
@@ -4019,12 +5623,12 @@ ${typeDefinition}`,
|
|
|
4019
5623
|
}
|
|
4020
5624
|
|
|
4021
5625
|
// src/components/styled/InterfacePage.tsx
|
|
4022
|
-
import { jsx as
|
|
5626
|
+
import { jsx as jsx28 } from "react/jsx-runtime";
|
|
4023
5627
|
|
|
4024
5628
|
function InterfacePage({ export: exp, spec }) {
|
|
4025
|
-
return /* @__PURE__ */
|
|
5629
|
+
return /* @__PURE__ */ jsx28("div", {
|
|
4026
5630
|
className: "doccov-interface-page not-prose",
|
|
4027
|
-
children: /* @__PURE__ */
|
|
5631
|
+
children: /* @__PURE__ */ jsx28(InterfaceSection, {
|
|
4028
5632
|
export: exp,
|
|
4029
5633
|
spec
|
|
4030
5634
|
})
|
|
@@ -4032,12 +5636,12 @@ function InterfacePage({ export: exp, spec }) {
|
|
|
4032
5636
|
}
|
|
4033
5637
|
|
|
4034
5638
|
// src/components/styled/sections/VariableSection.tsx
|
|
4035
|
-
import { formatSchema as
|
|
4036
|
-
import { APIParameterItem as
|
|
4037
|
-
import { jsx as
|
|
5639
|
+
import { formatSchema as formatSchema8 } from "@openpkg-ts/sdk/browser";
|
|
5640
|
+
import { APIParameterItem as APIParameterItem6, APISection as APISection5, ParameterList as ParameterList5 } from "@openpkg-ts/ui/docskit";
|
|
5641
|
+
import { jsx as jsx29, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
4038
5642
|
|
|
4039
5643
|
function VariableSection({ export: exp, spec }) {
|
|
4040
|
-
const typeValue = typeof exp.type === "string" ? exp.type :
|
|
5644
|
+
const typeValue = typeof exp.type === "string" ? exp.type : formatSchema8(exp.schema);
|
|
4041
5645
|
const languages = getLanguagesFromExamples(exp.examples);
|
|
4042
5646
|
const examples = specExamplesToCodeExamples(exp.examples);
|
|
4043
5647
|
const importStatement = buildImportStatement(exp, spec);
|
|
@@ -4052,25 +5656,25 @@ console.log(${exp.name}); // ${constValue !== undefined ? JSON.stringify(constVa
|
|
|
4052
5656
|
}
|
|
4053
5657
|
];
|
|
4054
5658
|
const displayLanguages = languages.length > 0 ? languages : [{ id: "typescript", label: "TypeScript" }];
|
|
4055
|
-
return /* @__PURE__ */
|
|
5659
|
+
return /* @__PURE__ */ jsx29(APISection5, {
|
|
4056
5660
|
id: exp.id || exp.name,
|
|
4057
5661
|
title: `const ${exp.name}`,
|
|
4058
|
-
description: /* @__PURE__ */
|
|
5662
|
+
description: /* @__PURE__ */ jsxs16("div", {
|
|
4059
5663
|
className: "space-y-3",
|
|
4060
5664
|
children: [
|
|
4061
|
-
exp.description && /* @__PURE__ */
|
|
5665
|
+
exp.description && /* @__PURE__ */ jsx29("p", {
|
|
4062
5666
|
children: exp.description
|
|
4063
5667
|
}),
|
|
4064
|
-
exp.deprecated && /* @__PURE__ */
|
|
5668
|
+
exp.deprecated && /* @__PURE__ */ jsxs16("div", {
|
|
4065
5669
|
className: "rounded-md bg-yellow-500/10 border border-yellow-500/20 px-3 py-2 text-sm text-yellow-600 dark:text-yellow-400",
|
|
4066
5670
|
children: [
|
|
4067
|
-
/* @__PURE__ */
|
|
5671
|
+
/* @__PURE__ */ jsx29("strong", {
|
|
4068
5672
|
children: "Deprecated:"
|
|
4069
5673
|
}),
|
|
4070
5674
|
" This export is deprecated."
|
|
4071
5675
|
]
|
|
4072
5676
|
}),
|
|
4073
|
-
/* @__PURE__ */
|
|
5677
|
+
/* @__PURE__ */ jsx29("code", {
|
|
4074
5678
|
className: "text-sm font-mono bg-muted px-2 py-1 rounded inline-block",
|
|
4075
5679
|
children: importStatement
|
|
4076
5680
|
})
|
|
@@ -4079,9 +5683,9 @@ console.log(${exp.name}); // ${constValue !== undefined ? JSON.stringify(constVa
|
|
|
4079
5683
|
languages: displayLanguages,
|
|
4080
5684
|
examples: displayExamples,
|
|
4081
5685
|
codePanelTitle: exp.name,
|
|
4082
|
-
children: /* @__PURE__ */
|
|
5686
|
+
children: /* @__PURE__ */ jsx29(ParameterList5, {
|
|
4083
5687
|
title: "Type",
|
|
4084
|
-
children: /* @__PURE__ */
|
|
5688
|
+
children: /* @__PURE__ */ jsx29(APIParameterItem6, {
|
|
4085
5689
|
name: exp.name,
|
|
4086
5690
|
type: typeValue,
|
|
4087
5691
|
description: constValue !== undefined ? `Value: ${JSON.stringify(constValue)}` : undefined
|
|
@@ -4091,12 +5695,12 @@ console.log(${exp.name}); // ${constValue !== undefined ? JSON.stringify(constVa
|
|
|
4091
5695
|
}
|
|
4092
5696
|
|
|
4093
5697
|
// src/components/styled/VariablePage.tsx
|
|
4094
|
-
import { jsx as
|
|
5698
|
+
import { jsx as jsx30 } from "react/jsx-runtime";
|
|
4095
5699
|
|
|
4096
5700
|
function VariablePage({ export: exp, spec }) {
|
|
4097
|
-
return /* @__PURE__ */
|
|
5701
|
+
return /* @__PURE__ */ jsx30("div", {
|
|
4098
5702
|
className: "doccov-variable-page not-prose",
|
|
4099
|
-
children: /* @__PURE__ */
|
|
5703
|
+
children: /* @__PURE__ */ jsx30(VariableSection, {
|
|
4100
5704
|
export: exp,
|
|
4101
5705
|
spec
|
|
4102
5706
|
})
|
|
@@ -4104,16 +5708,16 @@ function VariablePage({ export: exp, spec }) {
|
|
|
4104
5708
|
}
|
|
4105
5709
|
|
|
4106
5710
|
// src/components/styled/APIPage.tsx
|
|
4107
|
-
import { jsx as
|
|
5711
|
+
import { jsx as jsx31, jsxs as jsxs17 } from "react/jsx-runtime";
|
|
4108
5712
|
|
|
4109
5713
|
function NotFound({ id }) {
|
|
4110
|
-
return /* @__PURE__ */
|
|
5714
|
+
return /* @__PURE__ */ jsx31("div", {
|
|
4111
5715
|
className: "rounded-lg border border-border bg-card p-6 text-center",
|
|
4112
|
-
children: /* @__PURE__ */
|
|
5716
|
+
children: /* @__PURE__ */ jsxs17("p", {
|
|
4113
5717
|
className: "text-muted-foreground",
|
|
4114
5718
|
children: [
|
|
4115
5719
|
"Export ",
|
|
4116
|
-
/* @__PURE__ */
|
|
5720
|
+
/* @__PURE__ */ jsx31("code", {
|
|
4117
5721
|
className: "font-mono text-primary",
|
|
4118
5722
|
children: id
|
|
4119
5723
|
}),
|
|
@@ -4123,17 +5727,17 @@ function NotFound({ id }) {
|
|
|
4123
5727
|
});
|
|
4124
5728
|
}
|
|
4125
5729
|
function NoSpec() {
|
|
4126
|
-
return /* @__PURE__ */
|
|
5730
|
+
return /* @__PURE__ */ jsx31("div", {
|
|
4127
5731
|
className: "rounded-lg border border-red-500/20 bg-red-500/10 p-6 text-center",
|
|
4128
|
-
children: /* @__PURE__ */
|
|
5732
|
+
children: /* @__PURE__ */ jsxs17("p", {
|
|
4129
5733
|
className: "text-red-600 dark:text-red-400",
|
|
4130
5734
|
children: [
|
|
4131
5735
|
"No spec provided. Pass either ",
|
|
4132
|
-
/* @__PURE__ */
|
|
5736
|
+
/* @__PURE__ */ jsx31("code", {
|
|
4133
5737
|
children: "spec"
|
|
4134
5738
|
}),
|
|
4135
5739
|
" or ",
|
|
4136
|
-
/* @__PURE__ */
|
|
5740
|
+
/* @__PURE__ */ jsx31("code", {
|
|
4137
5741
|
children: "instance"
|
|
4138
5742
|
}),
|
|
4139
5743
|
" prop."
|
|
@@ -4151,10 +5755,10 @@ function APIPage({
|
|
|
4151
5755
|
}) {
|
|
4152
5756
|
const resolvedSpec = spec ?? instance?.spec;
|
|
4153
5757
|
if (!resolvedSpec) {
|
|
4154
|
-
return /* @__PURE__ */
|
|
5758
|
+
return /* @__PURE__ */ jsx31(NoSpec, {});
|
|
4155
5759
|
}
|
|
4156
5760
|
if (!id) {
|
|
4157
|
-
return /* @__PURE__ */
|
|
5761
|
+
return /* @__PURE__ */ jsx31(ExportIndexPage, {
|
|
4158
5762
|
spec: resolvedSpec,
|
|
4159
5763
|
baseHref,
|
|
4160
5764
|
description
|
|
@@ -4162,72 +5766,72 @@ function APIPage({
|
|
|
4162
5766
|
}
|
|
4163
5767
|
const exp = resolvedSpec.exports.find((e) => e.id === id);
|
|
4164
5768
|
if (!exp) {
|
|
4165
|
-
return /* @__PURE__ */
|
|
5769
|
+
return /* @__PURE__ */ jsx31(NotFound, {
|
|
4166
5770
|
id
|
|
4167
5771
|
});
|
|
4168
5772
|
}
|
|
4169
5773
|
const pageProps = { export: exp, spec: resolvedSpec, renderExample };
|
|
4170
5774
|
switch (exp.kind) {
|
|
4171
5775
|
case "function":
|
|
4172
|
-
return /* @__PURE__ */
|
|
5776
|
+
return /* @__PURE__ */ jsx31(FunctionPage, {
|
|
4173
5777
|
...pageProps
|
|
4174
5778
|
});
|
|
4175
5779
|
case "class":
|
|
4176
|
-
return /* @__PURE__ */
|
|
5780
|
+
return /* @__PURE__ */ jsx31(ClassPage, {
|
|
4177
5781
|
...pageProps
|
|
4178
5782
|
});
|
|
4179
5783
|
case "interface":
|
|
4180
5784
|
case "type":
|
|
4181
|
-
return /* @__PURE__ */
|
|
5785
|
+
return /* @__PURE__ */ jsx31(InterfacePage, {
|
|
4182
5786
|
...pageProps
|
|
4183
5787
|
});
|
|
4184
5788
|
case "enum":
|
|
4185
|
-
return /* @__PURE__ */
|
|
5789
|
+
return /* @__PURE__ */ jsx31(EnumPage, {
|
|
4186
5790
|
...pageProps
|
|
4187
5791
|
});
|
|
4188
5792
|
default:
|
|
4189
|
-
return /* @__PURE__ */
|
|
5793
|
+
return /* @__PURE__ */ jsx31(VariablePage, {
|
|
4190
5794
|
...pageProps
|
|
4191
5795
|
});
|
|
4192
5796
|
}
|
|
4193
5797
|
}
|
|
4194
5798
|
// src/components/styled/FullAPIReferencePage.tsx
|
|
4195
5799
|
import { APIReferencePage } from "@openpkg-ts/ui/docskit";
|
|
4196
|
-
import { cn as
|
|
4197
|
-
import { useCallback, useEffect, useMemo as
|
|
5800
|
+
import { cn as cn16 } from "@openpkg-ts/ui/lib/utils";
|
|
5801
|
+
import { useCallback as useCallback6, useEffect as useEffect8, useMemo as useMemo8, useRef as useRef9, useState as useState10 } from "react";
|
|
4198
5802
|
|
|
4199
5803
|
// src/components/styled/sections/ExportSection.tsx
|
|
4200
|
-
import { jsx as
|
|
5804
|
+
import { jsx as jsx32 } from "react/jsx-runtime";
|
|
4201
5805
|
|
|
4202
5806
|
function ExportSection({ export: exp, spec }) {
|
|
4203
5807
|
const props = { export: exp, spec };
|
|
4204
5808
|
switch (exp.kind) {
|
|
4205
5809
|
case "function":
|
|
4206
|
-
return /* @__PURE__ */
|
|
5810
|
+
return /* @__PURE__ */ jsx32(FunctionSection, {
|
|
4207
5811
|
...props
|
|
4208
5812
|
});
|
|
4209
5813
|
case "class":
|
|
4210
|
-
return /* @__PURE__ */
|
|
5814
|
+
return /* @__PURE__ */ jsx32(ClassSection, {
|
|
4211
5815
|
...props
|
|
4212
5816
|
});
|
|
4213
5817
|
case "interface":
|
|
4214
5818
|
case "type":
|
|
4215
|
-
return /* @__PURE__ */
|
|
5819
|
+
return /* @__PURE__ */ jsx32(InterfaceSection, {
|
|
4216
5820
|
...props
|
|
4217
5821
|
});
|
|
4218
5822
|
case "enum":
|
|
4219
|
-
return /* @__PURE__ */
|
|
5823
|
+
return /* @__PURE__ */ jsx32(EnumSection, {
|
|
4220
5824
|
...props
|
|
4221
5825
|
});
|
|
4222
5826
|
default:
|
|
4223
|
-
return /* @__PURE__ */
|
|
5827
|
+
return /* @__PURE__ */ jsx32(VariableSection, {
|
|
4224
5828
|
...props
|
|
4225
5829
|
});
|
|
4226
5830
|
}
|
|
4227
5831
|
}
|
|
4228
5832
|
|
|
4229
5833
|
// src/components/styled/FullAPIReferencePage.tsx
|
|
4230
|
-
import { jsx as
|
|
5834
|
+
import { jsx as jsx33, jsxs as jsxs18 } from "react/jsx-runtime";
|
|
4231
5835
|
|
|
4232
5836
|
var KIND_ORDER2 = ["function", "class", "interface", "type", "enum", "variable"];
|
|
4233
5837
|
var KIND_LABELS2 = {
|
|
@@ -4262,10 +5866,10 @@ function FullAPIReferencePage({
|
|
|
4262
5866
|
description,
|
|
4263
5867
|
className
|
|
4264
5868
|
}) {
|
|
4265
|
-
const [activeFilter, setActiveFilter] =
|
|
4266
|
-
const [activeSection, setActiveSection] =
|
|
4267
|
-
const isScrollingRef =
|
|
4268
|
-
const availableKinds =
|
|
5869
|
+
const [activeFilter, setActiveFilter] = useState10("all");
|
|
5870
|
+
const [activeSection, setActiveSection] = useState10(null);
|
|
5871
|
+
const isScrollingRef = useRef9(false);
|
|
5872
|
+
const availableKinds = useMemo8(() => {
|
|
4269
5873
|
const kindSet = new Set;
|
|
4270
5874
|
for (const exp of spec.exports) {
|
|
4271
5875
|
const kind = exp.kind;
|
|
@@ -4275,7 +5879,7 @@ function FullAPIReferencePage({
|
|
|
4275
5879
|
}
|
|
4276
5880
|
return KIND_ORDER2.filter((k) => kindSet.has(k));
|
|
4277
5881
|
}, [spec.exports]);
|
|
4278
|
-
const filteredExports =
|
|
5882
|
+
const filteredExports = useMemo8(() => {
|
|
4279
5883
|
let exports = spec.exports;
|
|
4280
5884
|
if (kinds?.length) {
|
|
4281
5885
|
exports = exports.filter((e) => kinds.includes(e.kind));
|
|
@@ -4292,7 +5896,7 @@ function FullAPIReferencePage({
|
|
|
4292
5896
|
return a.name.localeCompare(b.name);
|
|
4293
5897
|
});
|
|
4294
5898
|
}, [spec.exports, kinds, activeFilter]);
|
|
4295
|
-
const groupedExports =
|
|
5899
|
+
const groupedExports = useMemo8(() => {
|
|
4296
5900
|
const groups = new Map;
|
|
4297
5901
|
for (const exp of filteredExports) {
|
|
4298
5902
|
const kind = exp.kind;
|
|
@@ -4303,7 +5907,7 @@ function FullAPIReferencePage({
|
|
|
4303
5907
|
}
|
|
4304
5908
|
return groups;
|
|
4305
5909
|
}, [filteredExports]);
|
|
4306
|
-
|
|
5910
|
+
useEffect8(() => {
|
|
4307
5911
|
if (typeof window === "undefined")
|
|
4308
5912
|
return;
|
|
4309
5913
|
const hash = window.location.hash.slice(1);
|
|
@@ -4322,7 +5926,7 @@ function FullAPIReferencePage({
|
|
|
4322
5926
|
return () => clearTimeout(timer);
|
|
4323
5927
|
}
|
|
4324
5928
|
}, []);
|
|
4325
|
-
|
|
5929
|
+
useEffect8(() => {
|
|
4326
5930
|
if (!showTOC || typeof window === "undefined")
|
|
4327
5931
|
return;
|
|
4328
5932
|
const sectionIds = filteredExports.map((exp) => exp.id || exp.name);
|
|
@@ -4355,7 +5959,7 @@ function FullAPIReferencePage({
|
|
|
4355
5959
|
observer.disconnect();
|
|
4356
5960
|
};
|
|
4357
5961
|
}, [showTOC, filteredExports]);
|
|
4358
|
-
const handleTOCClick =
|
|
5962
|
+
const handleTOCClick = useCallback6((id) => {
|
|
4359
5963
|
const element = document.getElementById(id);
|
|
4360
5964
|
if (element) {
|
|
4361
5965
|
isScrollingRef.current = true;
|
|
@@ -4367,12 +5971,12 @@ function FullAPIReferencePage({
|
|
|
4367
5971
|
}, 1000);
|
|
4368
5972
|
}
|
|
4369
5973
|
}, []);
|
|
4370
|
-
const defaultDescription = /* @__PURE__ */
|
|
5974
|
+
const defaultDescription = /* @__PURE__ */ jsxs18("div", {
|
|
4371
5975
|
children: [
|
|
4372
|
-
spec.meta.description && /* @__PURE__ */
|
|
5976
|
+
spec.meta.description && /* @__PURE__ */ jsx33("p", {
|
|
4373
5977
|
children: spec.meta.description
|
|
4374
5978
|
}),
|
|
4375
|
-
spec.meta.version && /* @__PURE__ */
|
|
5979
|
+
spec.meta.version && /* @__PURE__ */ jsxs18("p", {
|
|
4376
5980
|
className: "text-sm text-muted-foreground mt-2",
|
|
4377
5981
|
children: [
|
|
4378
5982
|
"Version ",
|
|
@@ -4382,40 +5986,40 @@ function FullAPIReferencePage({
|
|
|
4382
5986
|
]
|
|
4383
5987
|
});
|
|
4384
5988
|
const shouldShowFilters = showFilters && !kinds?.length && availableKinds.length > 1;
|
|
4385
|
-
return /* @__PURE__ */
|
|
4386
|
-
className:
|
|
5989
|
+
return /* @__PURE__ */ jsxs18("div", {
|
|
5990
|
+
className: cn16("doccov-full-reference-page not-prose", showTOC && "lg:grid lg:grid-cols-[220px_1fr] lg:gap-8", className),
|
|
4387
5991
|
children: [
|
|
4388
|
-
showTOC && /* @__PURE__ */
|
|
5992
|
+
showTOC && /* @__PURE__ */ jsx33("aside", {
|
|
4389
5993
|
className: "hidden lg:block",
|
|
4390
|
-
children: /* @__PURE__ */
|
|
5994
|
+
children: /* @__PURE__ */ jsxs18("nav", {
|
|
4391
5995
|
className: "sticky top-20 max-h-[calc(100vh-6rem)] overflow-y-auto pr-4",
|
|
4392
5996
|
children: [
|
|
4393
|
-
/* @__PURE__ */
|
|
5997
|
+
/* @__PURE__ */ jsx33("h4", {
|
|
4394
5998
|
className: "text-sm font-semibold text-foreground mb-3",
|
|
4395
5999
|
children: "On this page"
|
|
4396
6000
|
}),
|
|
4397
|
-
/* @__PURE__ */
|
|
6001
|
+
/* @__PURE__ */ jsx33("div", {
|
|
4398
6002
|
className: "space-y-4",
|
|
4399
6003
|
children: KIND_ORDER2.map((kind) => {
|
|
4400
6004
|
const exports = groupedExports.get(kind);
|
|
4401
6005
|
if (!exports?.length)
|
|
4402
6006
|
return null;
|
|
4403
|
-
return /* @__PURE__ */
|
|
6007
|
+
return /* @__PURE__ */ jsxs18("div", {
|
|
4404
6008
|
children: [
|
|
4405
|
-
/* @__PURE__ */
|
|
6009
|
+
/* @__PURE__ */ jsx33("h5", {
|
|
4406
6010
|
className: "text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2",
|
|
4407
6011
|
children: KIND_LABELS2[kind]
|
|
4408
6012
|
}),
|
|
4409
|
-
/* @__PURE__ */
|
|
6013
|
+
/* @__PURE__ */ jsx33("ul", {
|
|
4410
6014
|
className: "space-y-1",
|
|
4411
6015
|
children: exports.map((exp) => {
|
|
4412
6016
|
const id = exp.id || exp.name;
|
|
4413
6017
|
const isActive = activeSection === id;
|
|
4414
|
-
return /* @__PURE__ */
|
|
4415
|
-
children: /* @__PURE__ */
|
|
6018
|
+
return /* @__PURE__ */ jsx33("li", {
|
|
6019
|
+
children: /* @__PURE__ */ jsx33("button", {
|
|
4416
6020
|
type: "button",
|
|
4417
6021
|
onClick: () => handleTOCClick(id),
|
|
4418
|
-
className:
|
|
6022
|
+
className: cn16("block w-full text-left text-sm py-1 px-2 rounded-md transition-colors cursor-pointer truncate", isActive ? "bg-primary/10 text-primary font-medium" : "text-muted-foreground hover:text-foreground hover:bg-muted/50"),
|
|
4419
6023
|
title: getExportTitle(exp),
|
|
4420
6024
|
children: getExportTitle(exp)
|
|
4421
6025
|
})
|
|
@@ -4429,40 +6033,40 @@ function FullAPIReferencePage({
|
|
|
4429
6033
|
]
|
|
4430
6034
|
})
|
|
4431
6035
|
}),
|
|
4432
|
-
/* @__PURE__ */
|
|
4433
|
-
children: /* @__PURE__ */
|
|
6036
|
+
/* @__PURE__ */ jsx33("div", {
|
|
6037
|
+
children: /* @__PURE__ */ jsxs18(APIReferencePage, {
|
|
4434
6038
|
title: title || spec.meta.name || "API Reference",
|
|
4435
6039
|
description: description || defaultDescription,
|
|
4436
6040
|
children: [
|
|
4437
|
-
shouldShowFilters && /* @__PURE__ */
|
|
6041
|
+
shouldShowFilters && /* @__PURE__ */ jsxs18("div", {
|
|
4438
6042
|
className: "flex flex-wrap gap-2 mb-8 -mt-4",
|
|
4439
6043
|
children: [
|
|
4440
|
-
/* @__PURE__ */
|
|
6044
|
+
/* @__PURE__ */ jsx33("button", {
|
|
4441
6045
|
type: "button",
|
|
4442
6046
|
onClick: () => setActiveFilter("all"),
|
|
4443
|
-
className:
|
|
6047
|
+
className: cn16("px-3 py-1.5 text-sm rounded-md transition-all cursor-pointer", activeFilter === "all" ? "bg-primary text-primary-foreground font-medium" : "bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),
|
|
4444
6048
|
children: "All"
|
|
4445
6049
|
}),
|
|
4446
|
-
availableKinds.map((kind) => /* @__PURE__ */
|
|
6050
|
+
availableKinds.map((kind) => /* @__PURE__ */ jsx33("button", {
|
|
4447
6051
|
type: "button",
|
|
4448
6052
|
onClick: () => setActiveFilter(kind),
|
|
4449
|
-
className:
|
|
6053
|
+
className: cn16("px-3 py-1.5 text-sm rounded-md transition-all cursor-pointer", activeFilter === kind ? "bg-primary text-primary-foreground font-medium" : "bg-muted text-muted-foreground hover:bg-muted/80 hover:text-foreground"),
|
|
4450
6054
|
children: KIND_LABELS2[kind]
|
|
4451
6055
|
}, kind))
|
|
4452
6056
|
]
|
|
4453
6057
|
}),
|
|
4454
|
-
filteredExports.map((exp) => /* @__PURE__ */
|
|
6058
|
+
filteredExports.map((exp) => /* @__PURE__ */ jsx33(ExportSection, {
|
|
4455
6059
|
export: exp,
|
|
4456
6060
|
spec
|
|
4457
6061
|
}, exp.id || exp.name)),
|
|
4458
|
-
filteredExports.length === 0 && /* @__PURE__ */
|
|
6062
|
+
filteredExports.length === 0 && /* @__PURE__ */ jsxs18("div", {
|
|
4459
6063
|
className: "rounded-lg border border-border bg-card/50 p-8 text-center",
|
|
4460
6064
|
children: [
|
|
4461
|
-
/* @__PURE__ */
|
|
6065
|
+
/* @__PURE__ */ jsx33("p", {
|
|
4462
6066
|
className: "text-muted-foreground",
|
|
4463
6067
|
children: activeFilter !== "all" ? `No ${KIND_LABELS2[activeFilter].toLowerCase()} found.` : "No exports found in this package."
|
|
4464
6068
|
}),
|
|
4465
|
-
activeFilter !== "all" && /* @__PURE__ */
|
|
6069
|
+
activeFilter !== "all" && /* @__PURE__ */ jsx33("button", {
|
|
4466
6070
|
type: "button",
|
|
4467
6071
|
onClick: () => setActiveFilter("all"),
|
|
4468
6072
|
className: "mt-3 text-sm text-primary hover:underline cursor-pointer",
|
|
@@ -4477,11 +6081,11 @@ function FullAPIReferencePage({
|
|
|
4477
6081
|
});
|
|
4478
6082
|
}
|
|
4479
6083
|
// src/components/styled/ParameterItem.tsx
|
|
4480
|
-
import { formatSchema as
|
|
4481
|
-
import { cn as
|
|
4482
|
-
import { ChevronRight } from "lucide-react";
|
|
4483
|
-
import { useState as
|
|
4484
|
-
import { jsx as
|
|
6084
|
+
import { formatSchema as formatSchema9 } from "@openpkg-ts/sdk/browser";
|
|
6085
|
+
import { cn as cn17 } from "@openpkg-ts/ui/lib/utils";
|
|
6086
|
+
import { ChevronRight as ChevronRight2 } from "lucide-react";
|
|
6087
|
+
import { useState as useState11 } from "react";
|
|
6088
|
+
import { jsx as jsx34, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
4485
6089
|
|
|
4486
6090
|
function getNestedProperties(schema) {
|
|
4487
6091
|
if (!schema || typeof schema !== "object")
|
|
@@ -4511,55 +6115,55 @@ function NestedPropertyItem({
|
|
|
4511
6115
|
required = false,
|
|
4512
6116
|
depth = 0
|
|
4513
6117
|
}) {
|
|
4514
|
-
const [expanded, setExpanded] =
|
|
4515
|
-
const type =
|
|
6118
|
+
const [expanded, setExpanded] = useState11(false);
|
|
6119
|
+
const type = formatSchema9(schema);
|
|
4516
6120
|
const nestedProps = getNestedProperties(schema);
|
|
4517
6121
|
const nestedCount = countProperties(schema);
|
|
4518
6122
|
const hasNested = nestedCount > 0;
|
|
4519
6123
|
const schemaObj = schema;
|
|
4520
6124
|
const description = schemaObj?.description;
|
|
4521
|
-
return /* @__PURE__ */
|
|
4522
|
-
className:
|
|
6125
|
+
return /* @__PURE__ */ jsxs19("div", {
|
|
6126
|
+
className: cn17("border-t border-border first:border-t-0", depth > 0 && "ml-4"),
|
|
4523
6127
|
children: [
|
|
4524
|
-
/* @__PURE__ */
|
|
6128
|
+
/* @__PURE__ */ jsx34("div", {
|
|
4525
6129
|
className: "py-3",
|
|
4526
|
-
children: /* @__PURE__ */
|
|
6130
|
+
children: /* @__PURE__ */ jsxs19("div", {
|
|
4527
6131
|
className: "flex items-start gap-2",
|
|
4528
6132
|
children: [
|
|
4529
|
-
hasNested && /* @__PURE__ */
|
|
6133
|
+
hasNested && /* @__PURE__ */ jsx34("button", {
|
|
4530
6134
|
type: "button",
|
|
4531
6135
|
onClick: () => setExpanded(!expanded),
|
|
4532
6136
|
className: "mt-0.5 p-0.5 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",
|
|
4533
6137
|
"aria-label": expanded ? "Collapse" : "Expand",
|
|
4534
|
-
children: /* @__PURE__ */
|
|
6138
|
+
children: /* @__PURE__ */ jsx34(ChevronRight2, {
|
|
4535
6139
|
size: 14,
|
|
4536
|
-
className:
|
|
6140
|
+
className: cn17("transition-transform duration-200", expanded && "rotate-90")
|
|
4537
6141
|
})
|
|
4538
6142
|
}),
|
|
4539
|
-
!hasNested && /* @__PURE__ */
|
|
6143
|
+
!hasNested && /* @__PURE__ */ jsx34("div", {
|
|
4540
6144
|
className: "w-5"
|
|
4541
6145
|
}),
|
|
4542
|
-
/* @__PURE__ */
|
|
6146
|
+
/* @__PURE__ */ jsxs19("div", {
|
|
4543
6147
|
className: "flex-1 min-w-0",
|
|
4544
6148
|
children: [
|
|
4545
|
-
/* @__PURE__ */
|
|
6149
|
+
/* @__PURE__ */ jsxs19("div", {
|
|
4546
6150
|
className: "flex items-baseline gap-2 flex-wrap",
|
|
4547
6151
|
children: [
|
|
4548
|
-
/* @__PURE__ */
|
|
6152
|
+
/* @__PURE__ */ jsxs19("span", {
|
|
4549
6153
|
className: "font-mono text-sm text-foreground",
|
|
4550
6154
|
children: [
|
|
4551
6155
|
name,
|
|
4552
|
-
!required && /* @__PURE__ */
|
|
6156
|
+
!required && /* @__PURE__ */ jsx34("span", {
|
|
4553
6157
|
className: "text-muted-foreground",
|
|
4554
6158
|
children: "?"
|
|
4555
6159
|
})
|
|
4556
6160
|
]
|
|
4557
6161
|
}),
|
|
4558
|
-
/* @__PURE__ */
|
|
6162
|
+
/* @__PURE__ */ jsx34("span", {
|
|
4559
6163
|
className: "font-mono text-sm text-muted-foreground",
|
|
4560
6164
|
children: hasNested ? "object" : type
|
|
4561
6165
|
}),
|
|
4562
|
-
hasNested && /* @__PURE__ */
|
|
6166
|
+
hasNested && /* @__PURE__ */ jsxs19("button", {
|
|
4563
6167
|
type: "button",
|
|
4564
6168
|
onClick: () => setExpanded(!expanded),
|
|
4565
6169
|
className: "text-xs text-primary hover:underline cursor-pointer",
|
|
@@ -4571,7 +6175,7 @@ function NestedPropertyItem({
|
|
|
4571
6175
|
})
|
|
4572
6176
|
]
|
|
4573
6177
|
}),
|
|
4574
|
-
description && /* @__PURE__ */
|
|
6178
|
+
description && /* @__PURE__ */ jsx34("p", {
|
|
4575
6179
|
className: "text-sm text-muted-foreground mt-1",
|
|
4576
6180
|
children: description
|
|
4577
6181
|
})
|
|
@@ -4580,9 +6184,9 @@ function NestedPropertyItem({
|
|
|
4580
6184
|
]
|
|
4581
6185
|
})
|
|
4582
6186
|
}),
|
|
4583
|
-
hasNested && expanded && nestedProps && /* @__PURE__ */
|
|
6187
|
+
hasNested && expanded && nestedProps && /* @__PURE__ */ jsx34("div", {
|
|
4584
6188
|
className: "border-l border-border ml-2",
|
|
4585
|
-
children: Object.entries(nestedProps).map(([propName, propSchema]) => /* @__PURE__ */
|
|
6189
|
+
children: Object.entries(nestedProps).map(([propName, propSchema]) => /* @__PURE__ */ jsx34(NestedPropertyItem, {
|
|
4586
6190
|
name: propName,
|
|
4587
6191
|
schema: propSchema,
|
|
4588
6192
|
required: getRequiredFields(schema).includes(propName),
|
|
@@ -4597,52 +6201,52 @@ function ParameterItem({
|
|
|
4597
6201
|
depth = 0,
|
|
4598
6202
|
className
|
|
4599
6203
|
}) {
|
|
4600
|
-
const [expanded, setExpanded] =
|
|
4601
|
-
const type =
|
|
6204
|
+
const [expanded, setExpanded] = useState11(false);
|
|
6205
|
+
const type = formatSchema9(param.schema);
|
|
4602
6206
|
const isRequired = param.required !== false;
|
|
4603
6207
|
const nestedProps = getNestedProperties(param.schema);
|
|
4604
6208
|
const nestedCount = countProperties(param.schema);
|
|
4605
6209
|
const hasNested = nestedCount > 0;
|
|
4606
|
-
return /* @__PURE__ */
|
|
4607
|
-
className:
|
|
6210
|
+
return /* @__PURE__ */ jsxs19("div", {
|
|
6211
|
+
className: cn17("border-b border-border last:border-b-0", className),
|
|
4608
6212
|
children: [
|
|
4609
|
-
/* @__PURE__ */
|
|
6213
|
+
/* @__PURE__ */ jsx34("div", {
|
|
4610
6214
|
className: "py-3",
|
|
4611
|
-
children: /* @__PURE__ */
|
|
6215
|
+
children: /* @__PURE__ */ jsxs19("div", {
|
|
4612
6216
|
className: "flex items-start gap-2",
|
|
4613
6217
|
children: [
|
|
4614
|
-
hasNested && /* @__PURE__ */
|
|
6218
|
+
hasNested && /* @__PURE__ */ jsx34("button", {
|
|
4615
6219
|
type: "button",
|
|
4616
6220
|
onClick: () => setExpanded(!expanded),
|
|
4617
6221
|
className: "mt-0.5 p-0.5 text-muted-foreground hover:text-foreground transition-colors cursor-pointer",
|
|
4618
6222
|
"aria-label": expanded ? "Collapse" : "Expand",
|
|
4619
|
-
children: /* @__PURE__ */
|
|
6223
|
+
children: /* @__PURE__ */ jsx34(ChevronRight2, {
|
|
4620
6224
|
size: 14,
|
|
4621
|
-
className:
|
|
6225
|
+
className: cn17("transition-transform duration-200", expanded && "rotate-90")
|
|
4622
6226
|
})
|
|
4623
6227
|
}),
|
|
4624
|
-
!hasNested && /* @__PURE__ */
|
|
6228
|
+
!hasNested && /* @__PURE__ */ jsx34("div", {
|
|
4625
6229
|
className: "w-5"
|
|
4626
6230
|
}),
|
|
4627
|
-
/* @__PURE__ */
|
|
6231
|
+
/* @__PURE__ */ jsxs19("div", {
|
|
4628
6232
|
className: "flex-1 min-w-0",
|
|
4629
6233
|
children: [
|
|
4630
|
-
/* @__PURE__ */
|
|
6234
|
+
/* @__PURE__ */ jsxs19("div", {
|
|
4631
6235
|
className: "flex items-baseline gap-2 flex-wrap",
|
|
4632
6236
|
children: [
|
|
4633
|
-
/* @__PURE__ */
|
|
6237
|
+
/* @__PURE__ */ jsx34("span", {
|
|
4634
6238
|
className: "font-mono text-sm font-medium text-foreground",
|
|
4635
6239
|
children: param.name
|
|
4636
6240
|
}),
|
|
4637
|
-
isRequired && /* @__PURE__ */
|
|
6241
|
+
isRequired && /* @__PURE__ */ jsx34("span", {
|
|
4638
6242
|
className: "text-[10px] font-semibold px-1.5 py-0.5 rounded border border-border bg-muted text-muted-foreground uppercase tracking-wide",
|
|
4639
6243
|
children: "Required"
|
|
4640
6244
|
}),
|
|
4641
|
-
/* @__PURE__ */
|
|
6245
|
+
/* @__PURE__ */ jsx34("span", {
|
|
4642
6246
|
className: "font-mono text-sm text-muted-foreground",
|
|
4643
6247
|
children: hasNested ? "object" : type
|
|
4644
6248
|
}),
|
|
4645
|
-
hasNested && /* @__PURE__ */
|
|
6249
|
+
hasNested && /* @__PURE__ */ jsxs19("button", {
|
|
4646
6250
|
type: "button",
|
|
4647
6251
|
onClick: () => setExpanded(!expanded),
|
|
4648
6252
|
className: "text-xs text-primary hover:underline cursor-pointer",
|
|
@@ -4654,7 +6258,7 @@ function ParameterItem({
|
|
|
4654
6258
|
})
|
|
4655
6259
|
]
|
|
4656
6260
|
}),
|
|
4657
|
-
param.description && /* @__PURE__ */
|
|
6261
|
+
param.description && /* @__PURE__ */ jsx34("p", {
|
|
4658
6262
|
className: "text-sm text-muted-foreground mt-1",
|
|
4659
6263
|
children: param.description
|
|
4660
6264
|
})
|
|
@@ -4663,9 +6267,9 @@ function ParameterItem({
|
|
|
4663
6267
|
]
|
|
4664
6268
|
})
|
|
4665
6269
|
}),
|
|
4666
|
-
hasNested && expanded && nestedProps && /* @__PURE__ */
|
|
6270
|
+
hasNested && expanded && nestedProps && /* @__PURE__ */ jsx34("div", {
|
|
4667
6271
|
className: "border-l border-border ml-2 mb-3",
|
|
4668
|
-
children: Object.entries(nestedProps).map(([propName, propSchema]) => /* @__PURE__ */
|
|
6272
|
+
children: Object.entries(nestedProps).map(([propName, propSchema]) => /* @__PURE__ */ jsx34(NestedPropertyItem, {
|
|
4669
6273
|
name: propName,
|
|
4670
6274
|
schema: propSchema,
|
|
4671
6275
|
required: getRequiredFields(param.schema).includes(propName),
|
|
@@ -4676,24 +6280,40 @@ function ParameterItem({
|
|
|
4676
6280
|
});
|
|
4677
6281
|
}
|
|
4678
6282
|
export {
|
|
6283
|
+
useSyncSection,
|
|
6284
|
+
useSyncScroll,
|
|
6285
|
+
useMethodsFromSpec,
|
|
6286
|
+
useMethodFromSpec,
|
|
4679
6287
|
specSchemaToAPISchema,
|
|
6288
|
+
specParamsToNestedParams,
|
|
6289
|
+
specParamToNestedParam,
|
|
4680
6290
|
specParamToAPIParam,
|
|
4681
6291
|
specExamplesToCodeExamples,
|
|
6292
|
+
specExampleToCodeExample,
|
|
6293
|
+
resolveSchemaRef,
|
|
4682
6294
|
groupMembersByKind,
|
|
4683
6295
|
getLanguagesFromExamples,
|
|
4684
6296
|
getExampleTitle,
|
|
4685
6297
|
getExampleLanguage,
|
|
4686
6298
|
getExampleCode,
|
|
6299
|
+
generateDefaultExample,
|
|
6300
|
+
extractMethodData,
|
|
4687
6301
|
cleanCode,
|
|
4688
6302
|
buildImportStatement,
|
|
4689
6303
|
VariableSection,
|
|
4690
6304
|
VariablePage,
|
|
4691
6305
|
TypeTable,
|
|
6306
|
+
SyncScrollProvider,
|
|
6307
|
+
StripeAPIReferencePage,
|
|
4692
6308
|
Signature,
|
|
4693
6309
|
ParameterItem,
|
|
4694
6310
|
ParamTable,
|
|
4695
6311
|
ParamRow,
|
|
4696
6312
|
NestedProperty,
|
|
6313
|
+
NestedParameterToggle,
|
|
6314
|
+
NestedParameterContainer,
|
|
6315
|
+
MethodSectionFromSpec,
|
|
6316
|
+
MethodSection,
|
|
4697
6317
|
MembersTable,
|
|
4698
6318
|
MemberRow,
|
|
4699
6319
|
InterfaceSection,
|
|
@@ -4706,12 +6326,20 @@ export {
|
|
|
4706
6326
|
ExportIndexPage,
|
|
4707
6327
|
ExportCard,
|
|
4708
6328
|
ExpandableProperty,
|
|
6329
|
+
ExpandableParameter,
|
|
6330
|
+
ExampleSection,
|
|
6331
|
+
ExampleChips,
|
|
4709
6332
|
ExampleBlock,
|
|
6333
|
+
EnumValuesSection,
|
|
4710
6334
|
EnumSection,
|
|
4711
6335
|
EnumPage,
|
|
6336
|
+
CollapsiblePanel,
|
|
4712
6337
|
CollapsibleMethod,
|
|
4713
6338
|
CodeTabs,
|
|
6339
|
+
CodePanel,
|
|
4714
6340
|
ClassSection,
|
|
4715
6341
|
ClassPage,
|
|
6342
|
+
APIReferenceLayout,
|
|
6343
|
+
APIParameterItem,
|
|
4716
6344
|
APIPage
|
|
4717
6345
|
};
|