@geenius/docs 0.8.10 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,21 @@
1
1
  import React, { useState, useId, useRef, useEffect, useCallback, useMemo, Children } from 'react';
2
+ import { clsx } from 'clsx';
3
+ import { twMerge } from 'tailwind-merge';
2
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
5
  import ReactMarkdown from 'react-markdown';
4
6
  import remarkGfm from 'remark-gfm';
5
7
  import { AnimatePresence, motion } from '@geenius/motion/react';
6
8
 
7
9
  // src/components/Breadcrumbs.tsx
10
+ function cn(...inputs) {
11
+ return twMerge(clsx(inputs));
12
+ }
8
13
  function Breadcrumbs({
9
- items
14
+ items,
15
+ className
10
16
  }) {
11
17
  if (items.length === 0) return null;
12
- return /* @__PURE__ */ jsx("nav", { className: "flex items-center gap-1.5 text-sm", "aria-label": "Breadcrumb", children: items.map((item, idx) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
18
+ return /* @__PURE__ */ jsx("nav", { className: cn("flex items-center gap-1.5 text-sm", className), "aria-label": "Breadcrumb", children: items.map((item, idx) => /* @__PURE__ */ jsxs(React.Fragment, { children: [
13
19
  idx > 0 && /* @__PURE__ */ jsx(
14
20
  "svg",
15
21
  {
@@ -31,7 +37,7 @@ function Breadcrumbs({
31
37
  ] }, `${item.href}-${item.title}`)) });
32
38
  }
33
39
 
34
- // ../shared/dist/chunk-BR2XBF64.js
40
+ // ../shared/dist/chunk-QKKVTCRJ.js
35
41
  function toTocLevel(level) {
36
42
  if (level === 2 || level === 3 || level === 4) {
37
43
  return level;
@@ -188,11 +194,11 @@ function createHeading(Tag, className) {
188
194
  return ({ children }) => {
189
195
  const text = getNodeText(children);
190
196
  const id = slugify(text);
191
- return /* @__PURE__ */ jsx(Tag, { id, className: `${className} scroll-mt-20`, children: /* @__PURE__ */ jsx("a", { href: `#${id}`, className: "transition-colors hover:text-primary", children }) });
197
+ return /* @__PURE__ */ jsx(Tag, { id, className: cn(className, "scroll-mt-20"), children: /* @__PURE__ */ jsx("a", { href: `#${id}`, className: "transition-colors hover:text-primary", children }) });
192
198
  };
193
199
  }
194
200
  function DocPage(props) {
195
- return /* @__PURE__ */ jsx("article", { className: "prose-custom max-w-none", children: /* @__PURE__ */ jsx(
201
+ return /* @__PURE__ */ jsx("article", { className: cn("prose-custom max-w-none", props.className), children: /* @__PURE__ */ jsx(
196
202
  ReactMarkdown,
197
203
  {
198
204
  remarkPlugins: [remarkGfm],
@@ -236,7 +242,8 @@ function DocSearch({
236
242
  onQuery,
237
243
  onSelect,
238
244
  isOpen,
239
- onClose
245
+ onClose,
246
+ className
240
247
  }) {
241
248
  const [activeIndex, setActiveIndex] = useState(0);
242
249
  const dialogId = useId();
@@ -297,7 +304,7 @@ function DocSearch({
297
304
  },
298
305
  [results, activeIndex, onSelect, onClose]
299
306
  );
300
- return /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsxs("div", { className: "fixed inset-0 z-50 flex items-start justify-center pt-[15vh]", children: [
307
+ return /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsxs("div", { className: cn("fixed inset-0 z-50 flex items-start justify-center pt-[15vh]", className), children: [
301
308
  /* @__PURE__ */ jsx(
302
309
  motion.button,
303
310
  {
@@ -443,7 +450,8 @@ function DocSearch({
443
450
  function DocSidebar({
444
451
  sections,
445
452
  currentPageId,
446
- onNavigate
453
+ onNavigate,
454
+ className
447
455
  }) {
448
456
  const [expandedIds, setExpandedIds] = useState(/* @__PURE__ */ new Set());
449
457
  const toggle = useCallback((id) => {
@@ -514,7 +522,7 @@ function DocSidebar({
514
522
  ) })
515
523
  ] }, section.id);
516
524
  };
517
- return /* @__PURE__ */ jsxs("nav", { className: "flex flex-col gap-1 py-4", children: [
525
+ return /* @__PURE__ */ jsxs("nav", { className: cn("flex flex-col gap-1 py-4", className), children: [
518
526
  /* @__PURE__ */ jsx("div", { className: "px-4 pb-3 text-xs font-bold uppercase tracking-widest text-muted-foreground", children: "Documentation" }),
519
527
  topLevel.map((s) => renderSection(s, 0))
520
528
  ] });
@@ -526,7 +534,10 @@ function TocLink({ item, activeId, depth = 0 }) {
526
534
  motion.a,
527
535
  {
528
536
  href: `#${item.id}`,
529
- className: `block truncate border-l-2 py-1 text-[13px] transition-all relative ${isActive ? "border-primary text-primary font-medium" : "border-transparent text-white/40 hover:text-white/80 hover:border-white/20"}`,
537
+ className: cn(
538
+ "block truncate border-l-2 py-1 text-[13px] transition-all relative",
539
+ isActive ? "border-primary text-primary font-medium" : "border-transparent text-white/40 hover:text-white/80 hover:border-white/20"
540
+ ),
530
541
  style: { paddingLeft: 12 + depth * 12 },
531
542
  whileHover: { x: 2 },
532
543
  whileTap: { scale: 0.98 },
@@ -539,10 +550,11 @@ function TocLink({ item, activeId, depth = 0 }) {
539
550
  }
540
551
  function TableOfContents({
541
552
  toc,
542
- activeId
553
+ activeId,
554
+ className
543
555
  }) {
544
556
  if (toc.length === 0) return null;
545
- return /* @__PURE__ */ jsxs("nav", { className: "sticky top-24", children: [
557
+ return /* @__PURE__ */ jsxs("nav", { className: cn("sticky top-24", className), children: [
546
558
  /* @__PURE__ */ jsx("h4", { className: "mb-3 text-xs font-semibold uppercase tracking-widest text-white/40", children: "On this page" }),
547
559
  /* @__PURE__ */ jsx(motion.div, { className: "flex flex-col relative", layoutRoot: true, children: /* @__PURE__ */ jsx(AnimatePresence, { children: toc.map((item) => /* @__PURE__ */ jsx(motion.div, { initial: { opacity: 0, x: -10 }, animate: { opacity: 1, x: 0 }, children: /* @__PURE__ */ jsx(TocLink, { item, activeId }) }, item.id)) }) })
548
560
  ] });
@@ -554,9 +566,10 @@ function DocsLayout({
554
566
  breadcrumbs,
555
567
  currentPageId,
556
568
  onNavigate,
557
- children
569
+ children,
570
+ className
558
571
  }) {
559
- return /* @__PURE__ */ jsxs("div", { className: "flex min-h-screen bg-[#090a0f] text-white", children: [
572
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex min-h-screen bg-[#090a0f] text-white", className), children: [
560
573
  /* @__PURE__ */ jsx("aside", { className: "sticky top-0 hidden h-screen w-[260px] shrink-0 overflow-y-auto border-r border-white/5 bg-[#0b0c12] lg:block", children: /* @__PURE__ */ jsx(
561
574
  DocSidebar,
562
575
  {
@@ -604,7 +617,8 @@ function DocsLayout({
604
617
  }
605
618
  function EditButton({
606
619
  pageSlug,
607
- editUrl
620
+ editUrl,
621
+ className
608
622
  }) {
609
623
  if (!editUrl) return null;
610
624
  const href = `${editUrl.replace(/\/$/, "")}/${pageSlug}.mdx`;
@@ -614,7 +628,10 @@ function EditButton({
614
628
  href,
615
629
  target: "_blank",
616
630
  rel: "noopener noreferrer",
617
- className: "inline-flex items-center gap-1.5 rounded-lg border border-white/10 px-3 py-1.5 text-xs text-white/40 transition-colors hover:border-white/20 hover:text-white/60",
631
+ className: cn(
632
+ "inline-flex items-center gap-1.5 rounded-lg border border-white/10 px-3 py-1.5 text-xs text-white/40 transition-colors hover:border-white/20 hover:text-white/60",
633
+ className
634
+ ),
618
635
  children: [
619
636
  /* @__PURE__ */ jsx("svg", { "aria-hidden": "true", className: "h-3.5 w-3.5", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", children: /* @__PURE__ */ jsx("path", { d: "M11.5 1.5l3 3-9 9H2.5v-3l9-9z", strokeWidth: "1.5", strokeLinejoin: "round" }) }),
620
637
  "Edit this page"
@@ -624,10 +641,11 @@ function EditButton({
624
641
  }
625
642
  function PageNavigation({
626
643
  prev,
627
- next
644
+ next,
645
+ className
628
646
  }) {
629
647
  if (!prev && !next) return null;
630
- return /* @__PURE__ */ jsxs("div", { className: "mt-12 flex items-stretch gap-4 border-t border-white/10 pt-8", children: [
648
+ return /* @__PURE__ */ jsxs("div", { className: cn("mt-12 flex items-stretch gap-4 border-t border-white/10 pt-8", className), children: [
631
649
  prev ? /* @__PURE__ */ jsxs(
632
650
  "a",
633
651
  {
@@ -655,7 +673,8 @@ function PageNavigation({
655
673
  function VersionSelector({
656
674
  versions,
657
675
  current,
658
- onSelect
676
+ onSelect,
677
+ className
659
678
  }) {
660
679
  const [isOpen, setIsOpen] = useState(false);
661
680
  const ref = useRef(null);
@@ -669,7 +688,7 @@ function VersionSelector({
669
688
  return () => document.removeEventListener("mousedown", handleClickOutside);
670
689
  }, []);
671
690
  if (versions.length <= 1) return null;
672
- return /* @__PURE__ */ jsxs("div", { ref, className: "relative", children: [
691
+ return /* @__PURE__ */ jsxs("div", { ref, className: cn("relative", className), children: [
673
692
  /* @__PURE__ */ jsxs(
674
693
  "button",
675
694
  {
@@ -898,7 +917,8 @@ function useTableOfContents(mdxContent) {
898
917
  }
899
918
  function DocSearchPage({
900
919
  tree,
901
- onSelectPage
920
+ onSelectPage,
921
+ className
902
922
  }) {
903
923
  const sections = useMemo(() => tree ?? [], [tree]);
904
924
  const flatPages = useMemo(() => sections.flatMap((s) => s.pages ?? []), [sections]);
@@ -911,12 +931,12 @@ function DocSearchPage({
911
931
  );
912
932
  const { results, isSearching, query, setQuery } = useDocSearch(searchFn);
913
933
  if (tree === void 0) {
914
- return /* @__PURE__ */ jsx("div", { className: "min-h-screen bg-[#090a0f] px-6 py-16", children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-2xl", children: [
934
+ return /* @__PURE__ */ jsx("div", { className: cn("min-h-screen bg-[#090a0f] px-6 py-16", className), children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-2xl", children: [
915
935
  /* @__PURE__ */ jsx("div", { className: "mb-8 h-12 animate-pulse rounded-xl bg-white/5" }),
916
936
  /* @__PURE__ */ jsx("div", { className: "space-y-3", children: Array.from({ length: 5 }, (_, index) => `doc-search-skeleton-${index}`).map((key) => /* @__PURE__ */ jsx("div", { className: "h-20 animate-pulse rounded-xl bg-white/5" }, key)) })
917
937
  ] }) });
918
938
  }
919
- return /* @__PURE__ */ jsx("div", { className: "min-h-screen bg-[#090a0f] text-white", children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-2xl px-6 py-16", children: [
939
+ return /* @__PURE__ */ jsx("div", { className: cn("min-h-screen bg-[#090a0f] text-white", className), children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-2xl px-6 py-16", children: [
920
940
  /* @__PURE__ */ jsx("h1", { className: "mb-8 text-2xl font-bold", children: "Search Documentation" }),
921
941
  /* @__PURE__ */ jsxs("div", { className: "relative mb-8", children: [
922
942
  /* @__PURE__ */ jsx("svg", { "aria-hidden": "true", className: "absolute left-4 top-1/2 h-5 w-5 -translate-y-1/2 text-white/30", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", d: "M9 3.5a5.5 5.5 0 100 11 5.5 5.5 0 000-11zM2 9a7 7 0 1112.452 4.391l3.328 3.329a.75.75 0 11-1.06 1.06l-3.329-3.328A7 7 0 012 9z", clipRule: "evenodd" }) }),
@@ -997,7 +1017,8 @@ function initialPageForm() {
997
1017
  function DocsAdminPage({
998
1018
  tree,
999
1019
  allPages,
1000
- admin
1020
+ admin,
1021
+ className
1001
1022
  }) {
1002
1023
  const sections = useMemo(() => tree ?? [], [tree]);
1003
1024
  const [selectedSectionId, setSelectedSectionId] = useState(null);
@@ -1014,7 +1035,7 @@ function DocsAdminPage({
1014
1035
  const canCreateSection = sectionForm.title.trim().length > 0 && sectionForm.slug.trim().length > 0;
1015
1036
  const canCreatePage = pageForm.title.trim().length > 0 && pageForm.slug.trim().length > 0 && pageForm.content.trim().length > 0;
1016
1037
  if (tree === void 0) {
1017
- return /* @__PURE__ */ jsx("div", { className: "min-h-screen bg-[#090a0f] px-6 py-12", children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-6xl", children: [
1038
+ return /* @__PURE__ */ jsx("div", { className: cn("min-h-screen bg-[#090a0f] px-6 py-12", className), children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-6xl", children: [
1018
1039
  /* @__PURE__ */ jsx("div", { className: "mb-8 h-10 w-48 animate-pulse rounded bg-white/5" }),
1019
1040
  /* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
1020
1041
  /* @__PURE__ */ jsx("div", { className: "h-96 animate-pulse rounded-xl bg-white/5" }),
@@ -1022,7 +1043,7 @@ function DocsAdminPage({
1022
1043
  ] })
1023
1044
  ] }) });
1024
1045
  }
1025
- return /* @__PURE__ */ jsx("div", { className: "min-h-screen bg-[#090a0f] text-white", children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-6xl px-6 py-12", children: [
1046
+ return /* @__PURE__ */ jsx("div", { className: cn("min-h-screen bg-[#090a0f] text-white", className), children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-6xl px-6 py-12", children: [
1026
1047
  /* @__PURE__ */ jsx("h1", { className: "mb-8 text-2xl font-bold", children: "Docs Admin" }),
1027
1048
  /* @__PURE__ */ jsxs("div", { className: "grid gap-6 md:grid-cols-2", children: [
1028
1049
  /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-white/8 bg-white/[0.02] p-5", children: [
@@ -1394,7 +1415,8 @@ function DocsAdminPage({
1394
1415
  }
1395
1416
  function DocsIndexPage({
1396
1417
  tree,
1397
- onSelectPage
1418
+ onSelectPage,
1419
+ className
1398
1420
  }) {
1399
1421
  const docs = useDocs(tree);
1400
1422
  const [isSearchOpen, setIsSearchOpen] = useState(false);
@@ -1417,20 +1439,29 @@ function DocsIndexPage({
1417
1439
  return () => document.removeEventListener("keydown", handler);
1418
1440
  }, []);
1419
1441
  if (docs.isLoading) {
1420
- return /* @__PURE__ */ jsx("div", { className: "min-h-screen bg-[#090a0f] px-6 py-16", children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-5xl", children: [
1442
+ return /* @__PURE__ */ jsx("div", { className: cn("min-h-screen bg-[#090a0f] px-6 py-16", className), children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-5xl", children: [
1421
1443
  /* @__PURE__ */ jsx("div", { className: "mb-10 h-10 w-64 animate-pulse rounded-lg bg-white/5" }),
1422
1444
  /* @__PURE__ */ jsx("div", { className: "mb-8 h-12 w-full max-w-xl animate-pulse rounded-xl bg-white/5" }),
1423
1445
  /* @__PURE__ */ jsx("div", { className: "grid gap-4 md:grid-cols-2 lg:grid-cols-3", children: Array.from({ length: 6 }, (_, index) => `docs-index-skeleton-${index}`).map((key) => /* @__PURE__ */ jsx("div", { className: "h-36 animate-pulse rounded-xl bg-white/5" }, key)) })
1424
1446
  ] }) });
1425
1447
  }
1426
1448
  if (docs.sections.length === 0) {
1427
- return /* @__PURE__ */ jsxs("div", { className: "flex min-h-screen flex-col items-center justify-center bg-[#090a0f] text-center", children: [
1428
- /* @__PURE__ */ jsx("div", { className: "mb-4 text-6xl opacity-30", children: "\u{1F4DA}" }),
1429
- /* @__PURE__ */ jsx("h2", { className: "mb-2 text-xl font-semibold text-white/80", children: "No documentation yet" }),
1430
- /* @__PURE__ */ jsx("p", { className: "max-w-sm text-sm text-white/40", children: "Create your first section and pages to get started with your documentation." })
1431
- ] });
1449
+ return /* @__PURE__ */ jsxs(
1450
+ "div",
1451
+ {
1452
+ className: cn(
1453
+ "flex min-h-screen flex-col items-center justify-center bg-[#090a0f] text-center",
1454
+ className
1455
+ ),
1456
+ children: [
1457
+ /* @__PURE__ */ jsx("div", { className: "mb-4 text-6xl opacity-30", children: "\u{1F4DA}" }),
1458
+ /* @__PURE__ */ jsx("h2", { className: "mb-2 text-xl font-semibold text-white/80", children: "No documentation yet" }),
1459
+ /* @__PURE__ */ jsx("p", { className: "max-w-sm text-sm text-white/40", children: "Create your first section and pages to get started with your documentation." })
1460
+ ]
1461
+ }
1462
+ );
1432
1463
  }
1433
- return /* @__PURE__ */ jsxs("div", { className: "min-h-screen bg-[#090a0f] text-white", children: [
1464
+ return /* @__PURE__ */ jsxs("div", { className: cn("min-h-screen bg-[#090a0f] text-white", className), children: [
1434
1465
  /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-5xl px-6 py-16", children: [
1435
1466
  /* @__PURE__ */ jsx("h1", { className: "mb-2 text-4xl font-bold tracking-tight", children: "Documentation" }),
1436
1467
  /* @__PURE__ */ jsx("p", { className: "mb-10 text-lg text-white/50", children: "Browse guides, API references, and tutorials." }),
@@ -1518,7 +1549,8 @@ function DocViewPage({
1518
1549
  page,
1519
1550
  editPageUrl,
1520
1551
  onNavigate,
1521
- onIncrementView
1552
+ onIncrementView,
1553
+ className
1522
1554
  }) {
1523
1555
  const docs = useDocs(tree);
1524
1556
  const { toc, activeId } = useTableOfContents(page?.content);
@@ -1542,7 +1574,7 @@ function DocViewPage({
1542
1574
  };
1543
1575
  }, [page, docs.flatPages, docs.sections]);
1544
1576
  if (docs.isLoading || page === void 0) {
1545
- return /* @__PURE__ */ jsxs("div", { className: "flex min-h-screen bg-[#090a0f]", children: [
1577
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex min-h-screen bg-[#090a0f]", className), children: [
1546
1578
  /* @__PURE__ */ jsx("div", { className: "hidden w-[260px] shrink-0 border-r border-white/5 bg-[#0b0c12] lg:block", children: /* @__PURE__ */ jsx("div", { className: "space-y-3 p-4", children: Array.from({ length: 8 }, (_, index) => `doc-view-sidebar-skeleton-${index}`).map((key) => /* @__PURE__ */ jsx("div", { className: "h-8 animate-pulse rounded-lg bg-white/5" }, key)) }) }),
1547
1579
  /* @__PURE__ */ jsx("div", { className: "flex-1 px-10 py-8", children: /* @__PURE__ */ jsxs("div", { className: "mx-auto max-w-3xl space-y-4", children: [
1548
1580
  /* @__PURE__ */ jsx("div", { className: "h-5 w-48 animate-pulse rounded bg-white/5" }),
@@ -1552,11 +1584,20 @@ function DocViewPage({
1552
1584
  ] });
1553
1585
  }
1554
1586
  if (!page) {
1555
- return /* @__PURE__ */ jsxs("div", { className: "flex min-h-screen flex-col items-center justify-center bg-[#090a0f] text-center", children: [
1556
- /* @__PURE__ */ jsx("div", { className: "mb-4 text-6xl opacity-30", children: "\u{1F50D}" }),
1557
- /* @__PURE__ */ jsx("h2", { className: "mb-2 text-xl font-semibold text-white/80", children: "Page not found" }),
1558
- /* @__PURE__ */ jsx("p", { className: "text-sm text-white/40", children: "The documentation page you're looking for doesn't exist." })
1559
- ] });
1587
+ return /* @__PURE__ */ jsxs(
1588
+ "div",
1589
+ {
1590
+ className: cn(
1591
+ "flex min-h-screen flex-col items-center justify-center bg-[#090a0f] text-center",
1592
+ className
1593
+ ),
1594
+ children: [
1595
+ /* @__PURE__ */ jsx("div", { className: "mb-4 text-6xl opacity-30", children: "\u{1F50D}" }),
1596
+ /* @__PURE__ */ jsx("h2", { className: "mb-2 text-xl font-semibold text-white/80", children: "Page not found" }),
1597
+ /* @__PURE__ */ jsx("p", { className: "text-sm text-white/40", children: "The documentation page you're looking for doesn't exist." })
1598
+ ]
1599
+ }
1600
+ );
1560
1601
  }
1561
1602
  return /* @__PURE__ */ jsxs(
1562
1603
  DocsLayout,
@@ -1568,6 +1609,7 @@ function DocViewPage({
1568
1609
  breadcrumbs,
1569
1610
  currentPageId: page.id,
1570
1611
  onNavigate,
1612
+ className,
1571
1613
  children: [
1572
1614
  /* @__PURE__ */ jsxs("div", { className: "mb-8", children: [
1573
1615
  /* @__PURE__ */ jsx("h1", { className: "mb-3 text-3xl font-bold tracking-tight", children: page.title }),