@mintlify/msft-sdk 1.1.10 → 1.1.12

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.
Files changed (45) hide show
  1. package/dist/components/content-components/code-block.js +3 -3
  2. package/dist/components/content-components/code-block.js.map +1 -1
  3. package/dist/components/content-components/default-components.js +21 -26
  4. package/dist/components/content-components/default-components.js.map +1 -1
  5. package/dist/components/content-components/details/details.js +1 -1
  6. package/dist/components/content-components/details/details.js.map +1 -1
  7. package/dist/components/content-components/home.js +3 -278
  8. package/dist/components/content-components/home.js.map +1 -1
  9. package/dist/components/content-components/image.js +80 -0
  10. package/dist/components/content-components/image.js.map +1 -0
  11. package/dist/components/content-components/param-name.js +1 -1
  12. package/dist/components/content-components/param-name.js.map +1 -1
  13. package/dist/components/content-components/zone-pivots/zone-pivot-selector.js +22 -19
  14. package/dist/components/content-components/zone-pivots/zone-pivot-selector.js.map +1 -1
  15. package/dist/components/docsLayout.js +60 -0
  16. package/dist/components/docsLayout.js.map +1 -0
  17. package/dist/components/docsPage.js +128 -0
  18. package/dist/components/docsPage.js.map +1 -0
  19. package/dist/components/nav-tree/index.js +127 -159
  20. package/dist/components/nav-tree/index.js.map +1 -1
  21. package/dist/components/nav-tree/mobile-nav.js +21 -23
  22. package/dist/components/nav-tree/mobile-nav.js.map +1 -1
  23. package/dist/components/page-context-menu.js +47 -53
  24. package/dist/components/page-context-menu.js.map +1 -1
  25. package/dist/components/toc/index.js +5 -5
  26. package/dist/components/toc/index.js.map +1 -1
  27. package/dist/index.d.ts +180 -40
  28. package/dist/index.js +62 -64
  29. package/dist/index.js.map +1 -1
  30. package/dist/parser/serialize-mdx.js +27 -22
  31. package/dist/parser/serialize-mdx.js.map +1 -1
  32. package/dist/plugins/extract-headings.js +23 -17
  33. package/dist/plugins/extract-headings.js.map +1 -1
  34. package/dist/plugins/remark/remark-heading-ids.js +21 -14
  35. package/dist/plugins/remark/remark-heading-ids.js.map +1 -1
  36. package/dist/styles.css +1 -1
  37. package/package.json +1 -1
  38. package/dist/components/Api/Api.js +0 -42
  39. package/dist/components/Api/Api.js.map +0 -1
  40. package/dist/components/Api/Api.module.css.js +0 -22
  41. package/dist/components/Api/Api.module.css.js.map +0 -1
  42. package/dist/components/nav-tree/dropdown-menu.js +0 -75
  43. package/dist/components/nav-tree/dropdown-menu.js.map +0 -1
  44. package/dist/components/page.js +0 -120
  45. package/dist/components/page.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"mobile-nav.js","sources":["../../../src/components/nav-tree/mobile-nav.tsx"],"sourcesContent":["import { NavTreeData, LinkComponent } from \"../../types\";\nimport { Dialog, DialogBackdrop, DialogPanel } from \"@headlessui/react\";\nimport { DropdownConfig, NavTree, BottomLinkConfig } from \"./index\";\nimport { Dismiss16Regular } from \"@fluentui/react-icons\";\nimport { ComponentsProvider } from \"../../context/components-context\";\nimport { cn } from \"../../utils/cn\";\nimport \"../../styles.css\";\n\nexport interface MobileNavTreeProps {\n isOpen: boolean;\n setIsOpen: (isOpen: boolean) => void;\n navTree: NavTreeData;\n activeId?: string;\n className?: string;\n theme?: \"light\" | \"dark\" | \"system\";\n dropdown?: DropdownConfig;\n activeHref?: string;\n bottomLinks?: BottomLinkConfig[];\n LinkComponent?: LinkComponent;\n}\n\nexport function MobileNavTree({\n isOpen,\n setIsOpen,\n navTree,\n activeId,\n className = \"\",\n theme,\n dropdown,\n activeHref,\n bottomLinks,\n LinkComponent,\n}: MobileNavTreeProps) {\n return (\n <ComponentsProvider LinkComponent={LinkComponent}>\n <Dialog\n open={isOpen}\n onClose={() => setIsOpen(false)}\n className={cn(\n \"mint:fixed mint:inset-0 mint:overflow-y-auto mint:z-50 mint:lg:hidden\",\n theme === \"dark\" && \"mint:dark\"\n )}\n >\n <DialogBackdrop\n transition\n className=\"mint:fixed mint:inset-0 mint:bg-black/20 mint:dark:bg-black/80 mint:backdrop-blur mint:transition-opacity mint:duration-300 mint:ease-out mint:data-[closed]:opacity-0\"\n />\n <div className=\"mint:fixed mint:inset-0 mint:flex\">\n {isOpen && <CloseButton setIsOpen={setIsOpen} />}\n <DialogPanel\n id=\"mobile-nav\"\n transition\n className=\"mint:flex mint:flex-col mint:relative mint:bg-white mint:dark:bg-[#0f0f0f] mint:w-[85vw] mint:min-w-[19rem] mint:max-w-[22rem] mint:min-h-full mint:transition-transform mint:duration-100 mint:ease-in-out mint:data-[closed]:-translate-x-full\"\n >\n <div className=\"mint:flex mint:flex-col mint:flex-1 mint:p-4 mint:pt-4 mint:pb-12 mint:overflow-y-auto mint:h-full\">\n <NavTree\n navTree={navTree}\n activeId={activeId}\n className={className}\n dropdown={dropdown}\n activeHref={activeHref}\n theme={theme}\n bottomLinks={bottomLinks}\n />\n </div>\n </DialogPanel>\n </div>\n </Dialog>\n </ComponentsProvider>\n );\n}\n\nconst CloseButton = ({\n setIsOpen,\n}: {\n setIsOpen: (isOpen: boolean) => void;\n}) => {\n return (\n <button\n type=\"button\"\n onClick={() => setIsOpen(false)}\n className=\"mint:absolute mint:bg-white mint:dark:bg-[#0f0f0f] mint:rounded-full mint:top-4 mint:right-4 mint:w-8 mint:h-8 mint:flex mint:items-center mint:justify-center mint:border-none mint:cursor-pointer\"\n >\n <span className=\"mint:absolute mint:w-px mint:h-px mint:p-0 mint:-m-px mint:overflow-hidden mint:whitespace-nowrap mint:border-0 mint:[clip:rect(0,0,0,0)]\">\n Close navigation\n </span>\n <Dismiss16Regular className=\"mint:w-4 mint:h-4 mint:text-[#6b7280] mint:dark:text-[#9ca3af] mint:hover:text-[#4b5563] mint:dark:hover:text-[#d1d5db]\" />\n </button>\n );\n};\n"],"names":["MobileNavTree","isOpen","setIsOpen","navTree","activeId","className","theme","dropdown","activeHref","bottomLinks","LinkComponent","jsx","ComponentsProvider","jsxs","Dialog","cn","DialogBackdrop","CloseButton","DialogPanel","NavTree","Dismiss16Regular"],"mappings":";;;;;;;AAqBO,SAASA,EAAc;AAAA,EAC5B,QAAAC;AAAA,EACA,WAA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C9B,WAAU;AAAA,IAEV,UAAA;AAAA,MAAA,gBAAAS,EAAC,QAAA,EAAK,WAAU,6IAA4I,UAAA,oBAE5J;AAAA,MACA,gBAAAA,EAACS,GAAA,EAAiB,WAAU,0HAAA,CAA0H;AAAA,IAAA;AAAA,EAAA;AAAA;"}
1
+ {"version":3,"file":"mobile-nav.js","sources":["../../../src/components/nav-tree/mobile-nav.tsx"],"sourcesContent":["import { NavTreeData, LinkComponent } from \"../../types\";\nimport { Dialog, DialogBackdrop, DialogPanel } from \"@headlessui/react\";\nimport { NavTree, BottomLinkConfig } from \"./index\";\nimport { Dismiss16Regular } from \"@fluentui/react-icons\";\nimport { ComponentsProvider } from \"../../context/components-context\";\nimport { cn } from \"../../utils/cn\";\nimport \"../../styles.css\";\n\nexport interface MobileNavTreeProps {\n isOpen: boolean;\n setIsOpen: (isOpen: boolean) => void;\n navTree: NavTreeData;\n activeId?: string;\n className?: string;\n theme?: \"light\" | \"dark\" | \"system\";\n activeHref?: string;\n bottomLinks?: BottomLinkConfig[];\n LinkComponent?: LinkComponent;\n}\n\nexport function MobileNavTree({\n isOpen,\n setIsOpen,\n navTree,\n activeId,\n className = \"\",\n theme,\n activeHref,\n bottomLinks,\n LinkComponent,\n}: MobileNavTreeProps) {\n return (\n <ComponentsProvider LinkComponent={LinkComponent}>\n <Dialog\n open={isOpen}\n onClose={() => setIsOpen(false)}\n className={cn(\n \"mint:fixed mint:inset-0 mint:overflow-y-auto mint:z-50 mint:lg:hidden\",\n theme === \"dark\" && \"mint:dark\"\n )}\n >\n <DialogBackdrop\n transition\n className=\"mint:fixed mint:inset-0 mint:bg-black/20 mint:dark:bg-black/80 mint:backdrop-blur mint:transition-opacity mint:duration-300 mint:ease-out mint:data-[closed]:opacity-0\"\n />\n <div className=\"mint:fixed mint:inset-0 mint:flex\">\n {isOpen && <CloseButton setIsOpen={setIsOpen} />}\n <DialogPanel\n id=\"mobile-nav\"\n transition\n className=\"mint:flex mint:flex-col mint:relative mint:bg-white mint:dark:bg-[#0f0f0f] mint:w-[85vw] mint:min-w-[19rem] mint:max-w-[22rem] mint:min-h-full mint:transition-transform mint:duration-100 mint:ease-in-out mint:data-[closed]:-translate-x-full\"\n >\n <div className=\"mint:flex mint:flex-col mint:flex-1 mint:p-4 mint:pt-4 mint:pb-12 mint:overflow-y-auto mint:h-full\">\n <NavTree\n navTree={navTree}\n activeId={activeId}\n className={className}\n activeHref={activeHref}\n theme={theme}\n bottomLinks={bottomLinks}\n />\n </div>\n </DialogPanel>\n </div>\n </Dialog>\n </ComponentsProvider>\n );\n}\n\nconst CloseButton = ({\n setIsOpen,\n}: {\n setIsOpen: (isOpen: boolean) => void;\n}) => {\n return (\n <button\n type=\"button\"\n onClick={() => setIsOpen(false)}\n className=\"mint:absolute mint:bg-white mint:dark:bg-[#0f0f0f] mint:rounded-full mint:top-4 mint:right-4 mint:w-8 mint:h-8 mint:flex mint:items-center mint:justify-center mint:border-none mint:cursor-pointer\"\n >\n <span className=\"mint:absolute mint:w-px mint:h-px mint:p-0 mint:-m-px mint:overflow-hidden mint:whitespace-nowrap mint:border-0 mint:[clip:rect(0,0,0,0)]\">\n Close navigation\n </span>\n <Dismiss16Regular className=\"mint:w-4 mint:h-4 mint:text-[#6b7280] mint:dark:text-[#9ca3af] mint:hover:text-[#4b5563] mint:dark:hover:text-[#d1d5db]\" />\n </button>\n );\n};\n"],"names":["MobileNavTree","isOpen","setIsOpen","navTree","activeId","className","theme","activeHref","bottomLinks","LinkComponent","jsx","ComponentsProvider","jsxs","Dialog","cn","DialogBackdrop","CloseButton","DialogPanel","NavTree","Dismiss16Regular"],"mappings":";;;;;;;AAoBO,SAASA,EAAc;AAAA,EAC5B,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,aAAAC;AAAA,EACA,eAAAC;AACF,GAAuB;AACrB,SACE,gBAA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,22 @@
1
- import { jsxs as i, jsx as e, Fragment as f } from "react/jsx-runtime";
2
- import { useState as h, useRef as P, useEffect as w } from "react";
3
- import { CopyRegular as k, MarkdownRegular as C, ChevronDownRegular as F, ArrowUpRightRegular as T, DocumentOnePageSparkleRegular as A, DocumentOnePageMultipleSparkleRegular as I } from "@fluentui/react-icons";
1
+ import { jsxs as m, jsx as e, Fragment as g } from "react/jsx-runtime";
2
+ import { useState as h, useRef as C, useEffect as w } from "react";
3
+ import { CopyRegular as k, MarkdownRegular as F, ChevronDownRegular as T, DocumentOnePageSparkleRegular as I, DocumentOnePageMultipleSparkleRegular as L } from "@fluentui/react-icons";
4
4
  import { copyMarkdownToClipboard as S } from "../hooks/useMarkdownCopy.js";
5
- import { cn as x } from "../utils/cn.js";
6
- const B = ({
5
+ import { cn as u } from "../utils/cn.js";
6
+ const z = ({
7
7
  className: v,
8
8
  pathname: d,
9
- markdownContent: u,
10
- onCopyMarkdown: n,
9
+ markdownContent: x,
10
+ onCopyMarkdown: i,
11
11
  onViewMarkdown: p,
12
12
  allPages: N,
13
13
  baseUrl: _
14
14
  }) => {
15
- const [r, s] = h(!1), [a, g] = h(!1), c = P(null);
15
+ const [r, s] = h(!1), [a, f] = h(!1), c = C(null);
16
16
  w(() => {
17
17
  if (a) {
18
18
  const t = setTimeout(() => {
19
- g(!1);
19
+ f(!1);
20
20
  }, 2e3);
21
21
  return () => clearTimeout(t);
22
22
  }
@@ -28,70 +28,67 @@ const B = ({
28
28
  document.removeEventListener("mousedown", t);
29
29
  };
30
30
  }, [r]);
31
- const R = async () => {
32
- g(!0);
31
+ const y = async () => {
32
+ f(!0);
33
33
  try {
34
- if (u) {
34
+ if (x) {
35
35
  const t = new ClipboardItem({
36
- "text/plain": new Blob([u], { type: "text/plain" })
36
+ "text/plain": new Blob([x], { type: "text/plain" })
37
37
  });
38
- await navigator.clipboard.write([t]), n == null || n();
38
+ await navigator.clipboard.write([t]), i == null || i();
39
39
  } else
40
40
  S({
41
41
  pathname: d,
42
42
  onSuccess: () => {
43
- n == null || n();
43
+ i == null || i();
44
44
  }
45
45
  });
46
46
  } catch (t) {
47
47
  console.error("Failed to copy markdown:", t);
48
48
  }
49
- }, y = () => {
49
+ }, R = () => {
50
50
  p ? p(d) : window.open(`${d}.md`, "_blank");
51
- }, L = () => {
52
- window.open("/docs/llms.txt", "_blank");
53
51
  }, O = () => {
52
+ window.open("/docs/llms.txt", "_blank");
53
+ }, P = () => {
54
54
  window.open("/docs/llms-full.txt", "_blank");
55
55
  }, l = (t) => () => {
56
56
  s(!1), t();
57
- }, m = [
57
+ }, n = [
58
58
  {
59
59
  id: "copy",
60
60
  title: "Copy Page",
61
61
  description: "Copy page as markdown",
62
62
  icon: k,
63
- action: l(R)
63
+ action: l(y)
64
64
  },
65
65
  {
66
66
  id: "view",
67
67
  title: "View as Markdown",
68
68
  description: "View this page as plain text",
69
- icon: C,
70
- action: l(y),
71
- externalLink: !0
69
+ icon: F,
70
+ action: l(R)
72
71
  }
73
72
  ];
74
- N && _ && (m.push({
73
+ N && _ && (n.push({
75
74
  id: "llms",
76
75
  title: "View llms.txt",
77
76
  description: "View generated llms.txt file",
78
- icon: A,
79
- action: l(L),
80
- externalLink: !0
81
- }), m.push({
77
+ icon: I,
78
+ action: l(O)
79
+ }), n.push({
82
80
  id: "llms-full",
83
81
  title: "View llms-full.txt",
84
82
  description: "Generated llms-full.txt file",
85
- icon: I,
86
- action: l(O),
87
- externalLink: !0
83
+ icon: L,
84
+ action: l(P)
88
85
  }));
89
- const o = m[0];
90
- return /* @__PURE__ */ i(
86
+ const o = n[0];
87
+ return /* @__PURE__ */ m(
91
88
  "div",
92
89
  {
93
- className: x(
94
- "mint:flex mint:items-center mint:flex-shrink-0",
90
+ className: u(
91
+ "mint:flex mint:items-center mint:justify-end mint:shrink-0 mint:w-[160px]",
95
92
  v
96
93
  ),
97
94
  ref: c,
@@ -99,33 +96,33 @@ const B = ({
99
96
  /* @__PURE__ */ e(
100
97
  "button",
101
98
  {
102
- className: x(
103
- "mint:rounded-xl mint:py-1.5 mint:px-3 mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#374151] mint:dark:text-[#d1d5db] mint:cursor-pointer mint:flex mint:items-center mint:gap-2 mint:text-sm mint:font-medium mint:hover:bg-[rgba(75,85,99,0.05)] mint:dark:hover:bg-[rgba(229,231,235,0.05)]",
104
- m.length > 1 && "mint:rounded-tr-none mint:rounded-br-none mint:border-r-0",
99
+ className: u(
100
+ "mint:rounded-full mint:py-1.5 mint:px-3 mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#374151] mint:dark:text-[#d1d5db] mint:cursor-pointer mint:flex mint:items-center mint:gap-2 mint:text-sm mint:font-medium mint:hover:bg-[rgba(75,85,99,0.05)] mint:dark:hover:bg-[rgba(229,231,235,0.05)]",
101
+ n.length > 1 && "mint:rounded-tr-none mint:rounded-br-none mint:border-r-0",
105
102
  a && "mint:text-[#6b7280] mint:dark:text-[#9ca3af]"
106
103
  ),
107
104
  onClick: () => {
108
105
  o.action();
109
106
  },
110
- children: /* @__PURE__ */ e("div", { className: "mint:flex mint:items-center mint:gap-2 mint:text-sm mint:font-medium mint:text-[#242424] mint:dark:text-[#dbdbdb]", children: o.id === "copy" ? /* @__PURE__ */ i(f, { children: [
107
+ children: /* @__PURE__ */ e("div", { className: "mint:flex mint:items-center mint:gap-2 mint:text-sm mint:font-medium mint:text-[#242424] mint:dark:text-[#dbdbdb]", children: o.id === "copy" ? /* @__PURE__ */ m(g, { children: [
111
108
  /* @__PURE__ */ e(k, { className: "mint:w-5 mint:h-5 mint:text-[#424242] mint:dark:text-[#b2b2b2]" }),
112
- /* @__PURE__ */ e("span", { children: a ? "Copied" : "Copy Page" })
113
- ] }) : /* @__PURE__ */ i(f, { children: [
109
+ /* @__PURE__ */ e("span", { className: "mint:font-semibold", children: a ? "Copied" : "Copy Page" })
110
+ ] }) : /* @__PURE__ */ m(g, { children: [
114
111
  /* @__PURE__ */ e(o.icon, { className: "mint:w-5 mint:h-5 mint:text-[#424242] mint:dark:text-[#b2b2b2]" }),
115
112
  /* @__PURE__ */ e("span", { children: o.title })
116
113
  ] }) })
117
114
  }
118
115
  ),
119
- m.length > 1 && /* @__PURE__ */ i("div", { className: "mint:relative", children: [
116
+ n.length > 1 && /* @__PURE__ */ m("div", { className: "mint:relative", children: [
120
117
  /* @__PURE__ */ e(
121
118
  "button",
122
119
  {
123
- className: "mint:rounded-none mint:rounded-tr-xl mint:rounded-br-xl mint:py-1.5 mint:px-2 mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#374151] mint:dark:text-[#d1d5db] mint:cursor-pointer mint:hover:bg-[rgba(75,85,99,0.05)] mint:dark:hover:bg-[rgba(229,231,235,0.05)]",
120
+ className: "mint:rounded-none mint:rounded-tr-full mint:rounded-br-full mint:py-1.5 mint:px-2 mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#374151] mint:dark:text-[#d1d5db] mint:cursor-pointer mint:hover:bg-[rgba(75,85,99,0.05)] mint:dark:hover:bg-[rgba(229,231,235,0.05)]",
124
121
  onClick: () => s(!r),
125
122
  children: /* @__PURE__ */ e(
126
- F,
123
+ T,
127
124
  {
128
- className: x(
125
+ className: u(
129
126
  "mint:w-4 mint:h-4 mint:transition-transform mint:duration-150",
130
127
  r && "mint:rotate-180"
131
128
  )
@@ -133,18 +130,15 @@ const B = ({
133
130
  )
134
131
  }
135
132
  ),
136
- r && /* @__PURE__ */ e("div", { className: "mint:absolute mint:right-0 mint:top-full mint:mt-1 mint:z-50 mint:max-h-[420px] mint:py-1.5 mint:min-w-[240px] mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:bg-white mint:dark:bg-[#1a1a1a] mint:rounded-xl mint:shadow-[0_20px_25px_-5px_rgba(0,0,0,0.1),0_10px_10px_-5px_rgba(0,0,0,0.04)] mint:overflow-y-auto", children: m.map((t, b) => /* @__PURE__ */ i(
133
+ r && /* @__PURE__ */ e("div", { className: "mint:absolute mint:right-0 mint:top-full mint:mt-1 mint:z-50 mint:max-h-[420px] mint:p-1 mint:min-w-[240px] mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:bg-white mint:dark:bg-[#1a1a1a] mint:rounded-2xl mint:shadow-[0_20px_25px_-5px_rgba(0,0,0,0.1),0_10px_10px_-5px_rgba(0,0,0,0.04)] mint:overflow-y-auto", children: n.map((t, b) => /* @__PURE__ */ m(
137
134
  "button",
138
135
  {
139
136
  onClick: t.action,
140
137
  className: "mint:w-full mint:flex mint:items-center mint:gap-3 mint:py-2 mint:px-2.5 mint:cursor-pointer mint:rounded-xl mint:transition-colors mint:duration-150 mint:border-none mint:bg-none mint:hover:bg-[rgba(75,85,99,0.05)] mint:dark:hover:bg-[rgba(229,231,235,0.05)]",
141
138
  children: [
142
- /* @__PURE__ */ e("div", { className: "mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:rounded-lg mint:p-1 mint:flex-shrink-0", children: /* @__PURE__ */ e(t.icon, { className: "mint:w-5 mint:h-5 mint:text-[#424242] mint:dark:text-[#b2b2b2]" }) }),
143
- /* @__PURE__ */ i("div", { className: "mint:flex mint:flex-col mint:flex-1 mint:min-w-0 mint:text-left", children: [
144
- /* @__PURE__ */ i("div", { className: "mint:text-sm mint:font-medium mint:text-[#1f2937] mint:dark:text-[#d1d5db] mint:flex mint:items-center mint:gap-1.5", children: [
145
- t.title,
146
- t.externalLink && /* @__PURE__ */ e(T, { className: "mint:w-3 mint:h-3 mint:text-[#6b7280] mint:dark:text-[#9ca3af] mint:flex-shrink-0" })
147
- ] }),
139
+ /* @__PURE__ */ e("div", { className: "mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:rounded-lg mint:p-1 mint:shrink-0", children: /* @__PURE__ */ e(t.icon, { className: "mint:w-5 mint:h-5 mint:text-[#424242] mint:dark:text-[#b2b2b2]" }) }),
140
+ /* @__PURE__ */ m("div", { className: "mint:flex mint:flex-col mint:flex-1 mint:min-w-0 mint:text-left", children: [
141
+ /* @__PURE__ */ e("div", { className: "mint:text-sm mint:font-medium mint:text-[#1f2937] mint:dark:text-[#d1d5db] mint:flex mint:items-center mint:gap-1.5", children: t.title }),
148
142
  /* @__PURE__ */ e("div", { className: "mint:text-xs mint:text-[#6b7280] mint:dark:text-[#9ca3af] mint:mt-0.5", children: t.description })
149
143
  ] })
150
144
  ]
@@ -157,6 +151,6 @@ const B = ({
157
151
  );
158
152
  };
159
153
  export {
160
- B as PageContextMenu
154
+ z as PageContextMenu
161
155
  };
162
156
  //# sourceMappingURL=page-context-menu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"page-context-menu.js","sources":["../../src/components/page-context-menu.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef } from \"react\";\nimport {\n CopyRegular,\n MarkdownRegular,\n ChevronDownRegular,\n ArrowUpRightRegular,\n DocumentTextRegular,\n DocumentOnePageSparkleRegular,\n DocumentOnePageMultipleSparkleRegular,\n} from \"@fluentui/react-icons\";\nimport { copyMarkdownToClipboard } from \"../hooks/useMarkdownCopy\";\nimport type { LlmsPageConfig } from \"../utils/generate-llms-txt\";\nimport { cn } from \"../utils/cn\";\n\nexport type ContextualOption = {\n id: string;\n title: string;\n description: string;\n icon: React.ElementType;\n action: () => void;\n externalLink?: boolean;\n};\n\nexport interface PageContextMenuProps {\n className?: string;\n pathname: string;\n markdownContent?: string;\n onCopyMarkdown?: () => void;\n onViewMarkdown?: (pathname: string) => void;\n allPages?: LlmsPageConfig[];\n baseUrl?: string;\n}\n\nexport const PageContextMenu = ({\n className,\n pathname,\n markdownContent,\n onCopyMarkdown,\n onViewMarkdown,\n allPages,\n baseUrl,\n}: PageContextMenuProps) => {\n const [isOpen, setIsOpen] = useState(false);\n const [isCopied, setIsCopied] = useState(false);\n const dropdownRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (isCopied) {\n const timeout = setTimeout(() => {\n setIsCopied(false);\n }, 2000);\n return () => clearTimeout(timeout);\n }\n }, [isCopied]);\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (\n dropdownRef.current &&\n !dropdownRef.current.contains(event.target as Node)\n ) {\n setIsOpen(false);\n }\n };\n\n if (isOpen) {\n document.addEventListener(\"mousedown\", handleClickOutside);\n }\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [isOpen]);\n\n const copyPageAsMarkdown = async () => {\n setIsCopied(true);\n try {\n if (markdownContent) {\n const clipboardItem = new ClipboardItem({\n \"text/plain\": new Blob([markdownContent], { type: \"text/plain\" }),\n });\n await navigator.clipboard.write([clipboardItem]);\n onCopyMarkdown?.();\n } else {\n copyMarkdownToClipboard({\n pathname,\n onSuccess: () => {\n onCopyMarkdown?.();\n },\n });\n }\n } catch (error) {\n console.error(\"Failed to copy markdown:\", error);\n }\n };\n\n const viewAsMarkdown = () => {\n if (onViewMarkdown) {\n onViewMarkdown(pathname);\n } else {\n window.open(`${pathname}.md`, \"_blank\");\n }\n };\n\n const viewLlmsTxtFile = () => {\n window.open(\"/docs/llms.txt\", \"_blank\");\n };\n\n const viewLlmsFullTxtFile = () => {\n window.open(\"/docs/llms-full.txt\", \"_blank\");\n };\n\n const wrapAction = (actionFn: () => void) => {\n return () => {\n setIsOpen(false);\n actionFn();\n };\n };\n\n const options: ContextualOption[] = [\n {\n id: \"copy\",\n title: \"Copy Page\",\n description: \"Copy page as markdown\",\n icon: CopyRegular,\n action: wrapAction(copyPageAsMarkdown),\n },\n {\n id: \"view\",\n title: \"View as Markdown\",\n description: \"View this page as plain text\",\n icon: MarkdownRegular,\n action: wrapAction(viewAsMarkdown),\n externalLink: true,\n },\n ];\n\n if (allPages && baseUrl) {\n options.push({\n id: \"llms\",\n title: \"View llms.txt\",\n description: \"View generated llms.txt file\",\n icon: DocumentOnePageSparkleRegular,\n action: wrapAction(viewLlmsTxtFile),\n externalLink: true,\n });\n options.push({\n id: \"llms-full\",\n title: \"View llms-full.txt\",\n description: \"Generated llms-full.txt file\",\n icon: DocumentOnePageMultipleSparkleRegular,\n action: wrapAction(viewLlmsFullTxtFile),\n externalLink: true,\n });\n }\n\n const firstOption = options[0];\n\n return (\n <div\n className={cn(\n \"mint:flex mint:items-center mint:flex-shrink-0\",\n className\n )}\n ref={dropdownRef}\n >\n <button\n className={cn(\n \"mint:rounded-xl mint:py-1.5 mint:px-3 mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#374151] mint:dark:text-[#d1d5db] mint:cursor-pointer mint:flex mint:items-center mint:gap-2 mint:text-sm mint:font-medium mint:hover:bg-[rgba(75,85,99,0.05)] mint:dark:hover:bg-[rgba(229,231,235,0.05)]\",\n options.length > 1 &&\n \"mint:rounded-tr-none mint:rounded-br-none mint:border-r-0\",\n isCopied && \"mint:text-[#6b7280] mint:dark:text-[#9ca3af]\"\n )}\n onClick={() => {\n void firstOption.action();\n }}\n >\n <div className=\"mint:flex mint:items-center mint:gap-2 mint:text-sm mint:font-medium mint:text-[#242424] mint:dark:text-[#dbdbdb]\">\n {firstOption.id === \"copy\" ? (\n <>\n <CopyRegular className=\"mint:w-5 mint:h-5 mint:text-[#424242] mint:dark:text-[#b2b2b2]\" />\n <span>{isCopied ? \"Copied\" : \"Copy Page\"}</span>\n </>\n ) : (\n <>\n <firstOption.icon className=\"mint:w-5 mint:h-5 mint:text-[#424242] mint:dark:text-[#b2b2b2]\" />\n <span>{firstOption.title}</span>\n </>\n )}\n </div>\n </button>\n\n {options.length > 1 && (\n <div className=\"mint:relative\">\n <button\n className=\"mint:rounded-none mint:rounded-tr-xl mint:rounded-br-xl mint:py-1.5 mint:px-2 mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#374151] mint:dark:text-[#d1d5db] mint:cursor-pointer mint:hover:bg-[rgba(75,85,99,0.05)] mint:dark:hover:bg-[rgba(229,231,235,0.05)]\"\n onClick={() => setIsOpen(!isOpen)}\n >\n <ChevronDownRegular\n className={cn(\n \"mint:w-4 mint:h-4 mint:transition-transform mint:duration-150\",\n isOpen && \"mint:rotate-180\"\n )}\n />\n </button>\n\n {isOpen && (\n <div className=\"mint:absolute mint:right-0 mint:top-full mint:mt-1 mint:z-50 mint:max-h-[420px] mint:py-1.5 mint:min-w-[240px] mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:bg-white mint:dark:bg-[#1a1a1a] mint:rounded-xl mint:shadow-[0_20px_25px_-5px_rgba(0,0,0,0.1),0_10px_10px_-5px_rgba(0,0,0,0.04)] mint:overflow-y-auto\">\n {options.map((option, index) => (\n <button\n key={option.id + index}\n onClick={option.action}\n className=\"mint:w-full mint:flex mint:items-center mint:gap-3 mint:py-2 mint:px-2.5 mint:cursor-pointer mint:rounded-xl mint:transition-colors mint:duration-150 mint:border-none mint:bg-none mint:hover:bg-[rgba(75,85,99,0.05)] mint:dark:hover:bg-[rgba(229,231,235,0.05)]\"\n >\n <div className=\"mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:rounded-lg mint:p-1 mint:flex-shrink-0\">\n <option.icon className=\"mint:w-5 mint:h-5 mint:text-[#424242] mint:dark:text-[#b2b2b2]\" />\n </div>\n <div className=\"mint:flex mint:flex-col mint:flex-1 mint:min-w-0 mint:text-left\">\n <div className=\"mint:text-sm mint:font-medium mint:text-[#1f2937] mint:dark:text-[#d1d5db] mint:flex mint:items-center mint:gap-1.5\">\n {option.title}\n {option.externalLink && (\n <ArrowUpRightRegular className=\"mint:w-3 mint:h-3 mint:text-[#6b7280] mint:dark:text-[#9ca3af] mint:flex-shrink-0\" />\n )}\n </div>\n <div className=\"mint:text-xs mint:text-[#6b7280] mint:dark:text-[#9ca3af] mint:mt-0.5\">\n {option.description}\n </div>\n </div>\n </button>\n ))}\n </div>\n )}\n </div>\n )}\n </div>\n );\n};\n"],"names":["PageContextMenu","className","pathname","markdownContent","onCopyMarkdown","onViewMarkdown","allPages","baseUrl","isOpen","setIsOpen","useState","isCopied","setIsCopied","dropdownRef","useRef","useEffect","timeout","handleClickOutside","event","copyPageAsMarkdown","clipboardItem","copyMarkdownToClipboard","error","viewAsMarkdown","viewLlmsTxtFile","viewLlmsFullTxtFile","wrapAction","actionFn","options","CopyRegular","MarkdownRegular","DocumentOnePageSparkleRegular","DocumentOnePageMultipleSparkleRegular","firstOption","jsxs","cn","jsx","Fragment","ChevronDownRegular","option","index","ArrowUpRightRegular"],"mappings":";;;;;AAiCO,MAAMA,IAAkB,CAAC;AAAA,EAC9B,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AACF,MAA4B;AAC1B,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpC,CAACC,GAAUC,CAAW,IAAIF,EAAS,EAAK,GACxCG,IAAcC,EAAuB,IAAI;AAE/C,EAAAC,EAAU,MAAM;AACd,QAAIJ,GAAU;AACZ,YAAMK,IAAU,WAAW,MAAM;AAC/B,QAAAJ,EAAY,EAAK;AAAA,MACnB,GAAG,GAAI;AACP,aAAO,MAAM,aAAaI,CAAO;AAAA,IACnC;AAAA,EACF,GAAG,CAACL,CAAQ,CAAC,GAEbI,EAAU,MAAM;AACd,UAAME,IAAqB,CAACC,MAAsB;AAChD,MACEL,EAAY,WACZ,CAACA,EAAY,QAAQ,SAASK,EAAM,MAAc,KAElDT,EAAU,EAAK;AAAA,IAEnB;AAEA,WAAID,KACF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,KAChB,gBAAAM,EAAC,OAAA,EAAI,WAAU,iBACb,UAAA;AAAA,UAAA,gBAAAE;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAU;AAAA,cACV,SAAS,MAAM3B,EAAU,CAACD,CAAM;AAAA,cAEhC,UAAA,gBAAA4B;AAAA,gBAACE;AAAA,gBAAA;AAAA,kBACC,WAAWH;AAAA,oBACT;AAAA,oBACA3B,KAAU;AAAA,kBAAA;AAAA,gBACZ;AAAA,cAAA;AAAA,YACF;AAAA,UAAA;AAAA,UAGDA,uBACE,OAAA,EAAI,WAAU,yVACZ,UAAAoB,EAAQ,IAAI,CAACW,GAAQC,MACpB,gBAAAN;AAAA,YAAC;AAAA,YAAA;AAAA,cAEC,SAASK,EAAO;AAAA,cAChB,WAAU;AAAA,cAEV,UAAA;AAAA,gBAAA,gBAAAH,EAAC,OAAA,EAAI,WAAU,2HACb,UAAA,gBAAAA,EAACG,EAAO,MAAP,EAAY,WAAU,iEAAA,CAAiE,EAAA,CAC1F;AAAA,gBACA,gBAAAL,EAAC,OAAA,EAAI,WAAU,mEACb,UAAA;AAAA,kBAAA,gBAAAA,EAAC,OAAA,EAAI,WAAU,uHACZ,UAAA;AAAA,oBAAAK,EAAO;AAAA,oBACPA,EAAO,gBACN,gBAAAH,EAACK,GAAA,EAAoB,WAAU,oFAAA,CAAoF;AAAA,kBAAA,GAEvH;AAAA,kBACA,gBAAAL,EAAC,OAAA,EAAI,WAAU,yEACZ,YAAO,YAAA,CACV;AAAA,gBAAA,EAAA,CACF;AAAA,cAAA;AAAA,YAAA;AAAA,YAjBKG,EAAO,KAAKC;AAAA,UAAA,CAmBpB,EAAA,CACH;AAAA,QAAA,EAAA,CAEJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAIR;"}
1
+ {"version":3,"file":"page-context-menu.js","sources":["../../src/components/page-context-menu.tsx"],"sourcesContent":["import React, { useState, useEffect, useRef } from \"react\";\nimport {\n CopyRegular,\n MarkdownRegular,\n ChevronDownRegular,\n DocumentOnePageSparkleRegular,\n DocumentOnePageMultipleSparkleRegular,\n} from \"@fluentui/react-icons\";\nimport { copyMarkdownToClipboard } from \"../hooks/useMarkdownCopy\";\nimport type { LlmsPageConfig } from \"../utils/generate-llms-txt\";\nimport { cn } from \"../utils/cn\";\n\nexport type ContextualOption = {\n id: string;\n title: string;\n description: string;\n icon: React.ElementType;\n action: () => void;\n};\n\nexport interface PageContextMenuProps {\n className?: string;\n pathname: string;\n markdownContent?: string;\n onCopyMarkdown?: () => void;\n onViewMarkdown?: (pathname: string) => void;\n allPages?: LlmsPageConfig[];\n baseUrl?: string;\n}\n\nexport const PageContextMenu = ({\n className,\n pathname,\n markdownContent,\n onCopyMarkdown,\n onViewMarkdown,\n allPages,\n baseUrl,\n}: PageContextMenuProps) => {\n const [isOpen, setIsOpen] = useState(false);\n const [isCopied, setIsCopied] = useState(false);\n const dropdownRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (isCopied) {\n const timeout = setTimeout(() => {\n setIsCopied(false);\n }, 2000);\n return () => clearTimeout(timeout);\n }\n }, [isCopied]);\n\n useEffect(() => {\n const handleClickOutside = (event: MouseEvent) => {\n if (\n dropdownRef.current &&\n !dropdownRef.current.contains(event.target as Node)\n ) {\n setIsOpen(false);\n }\n };\n\n if (isOpen) {\n document.addEventListener(\"mousedown\", handleClickOutside);\n }\n\n return () => {\n document.removeEventListener(\"mousedown\", handleClickOutside);\n };\n }, [isOpen]);\n\n const copyPageAsMarkdown = async () => {\n setIsCopied(true);\n try {\n if (markdownContent) {\n const clipboardItem = new ClipboardItem({\n \"text/plain\": new Blob([markdownContent], { type: \"text/plain\" }),\n });\n await navigator.clipboard.write([clipboardItem]);\n onCopyMarkdown?.();\n } else {\n copyMarkdownToClipboard({\n pathname,\n onSuccess: () => {\n onCopyMarkdown?.();\n },\n });\n }\n } catch (error) {\n console.error(\"Failed to copy markdown:\", error);\n }\n };\n\n const viewAsMarkdown = () => {\n if (onViewMarkdown) {\n onViewMarkdown(pathname);\n } else {\n window.open(`${pathname}.md`, \"_blank\");\n }\n };\n\n const viewLlmsTxtFile = () => {\n window.open(\"/docs/llms.txt\", \"_blank\");\n };\n\n const viewLlmsFullTxtFile = () => {\n window.open(\"/docs/llms-full.txt\", \"_blank\");\n };\n\n const wrapAction = (actionFn: () => void) => {\n return () => {\n setIsOpen(false);\n actionFn();\n };\n };\n\n const options: ContextualOption[] = [\n {\n id: \"copy\",\n title: \"Copy Page\",\n description: \"Copy page as markdown\",\n icon: CopyRegular,\n action: wrapAction(copyPageAsMarkdown),\n },\n {\n id: \"view\",\n title: \"View as Markdown\",\n description: \"View this page as plain text\",\n icon: MarkdownRegular,\n action: wrapAction(viewAsMarkdown),\n },\n ];\n\n if (allPages && baseUrl) {\n options.push({\n id: \"llms\",\n title: \"View llms.txt\",\n description: \"View generated llms.txt file\",\n icon: DocumentOnePageSparkleRegular,\n action: wrapAction(viewLlmsTxtFile),\n });\n options.push({\n id: \"llms-full\",\n title: \"View llms-full.txt\",\n description: \"Generated llms-full.txt file\",\n icon: DocumentOnePageMultipleSparkleRegular,\n action: wrapAction(viewLlmsFullTxtFile),\n });\n }\n\n const firstOption = options[0];\n\n return (\n <div\n className={cn(\n \"mint:flex mint:items-center mint:justify-end mint:shrink-0 mint:w-[160px]\",\n className\n )}\n ref={dropdownRef}\n >\n <button\n className={cn(\n \"mint:rounded-full mint:py-1.5 mint:px-3 mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#374151] mint:dark:text-[#d1d5db] mint:cursor-pointer mint:flex mint:items-center mint:gap-2 mint:text-sm mint:font-medium mint:hover:bg-[rgba(75,85,99,0.05)] mint:dark:hover:bg-[rgba(229,231,235,0.05)]\",\n options.length > 1 &&\n \"mint:rounded-tr-none mint:rounded-br-none mint:border-r-0\",\n isCopied && \"mint:text-[#6b7280] mint:dark:text-[#9ca3af]\"\n )}\n onClick={() => {\n void firstOption.action();\n }}\n >\n <div className=\"mint:flex mint:items-center mint:gap-2 mint:text-sm mint:font-medium mint:text-[#242424] mint:dark:text-[#dbdbdb]\">\n {firstOption.id === \"copy\" ? (\n <>\n <CopyRegular className=\"mint:w-5 mint:h-5 mint:text-[#424242] mint:dark:text-[#b2b2b2]\" />\n <span className=\"mint:font-semibold\">{isCopied ? \"Copied\" : \"Copy Page\"}</span>\n </>\n ) : (\n <>\n <firstOption.icon className=\"mint:w-5 mint:h-5 mint:text-[#424242] mint:dark:text-[#b2b2b2]\" />\n <span>{firstOption.title}</span>\n </>\n )}\n </div>\n </button>\n\n {options.length > 1 && (\n <div className=\"mint:relative\">\n <button\n className=\"mint:rounded-none mint:rounded-tr-full mint:rounded-br-full mint:py-1.5 mint:px-2 mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#374151] mint:dark:text-[#d1d5db] mint:cursor-pointer mint:hover:bg-[rgba(75,85,99,0.05)] mint:dark:hover:bg-[rgba(229,231,235,0.05)]\"\n onClick={() => setIsOpen(!isOpen)}\n >\n <ChevronDownRegular\n className={cn(\n \"mint:w-4 mint:h-4 mint:transition-transform mint:duration-150\",\n isOpen && \"mint:rotate-180\"\n )}\n />\n </button>\n\n {isOpen && (\n <div className=\"mint:absolute mint:right-0 mint:top-full mint:mt-1 mint:z-50 mint:max-h-[420px] mint:p-1 mint:min-w-[240px] mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:bg-white mint:dark:bg-[#1a1a1a] mint:rounded-2xl mint:shadow-[0_20px_25px_-5px_rgba(0,0,0,0.1),0_10px_10px_-5px_rgba(0,0,0,0.04)] mint:overflow-y-auto\">\n {options.map((option, index) => (\n <button\n key={option.id + index}\n onClick={option.action}\n className=\"mint:w-full mint:flex mint:items-center mint:gap-3 mint:py-2 mint:px-2.5 mint:cursor-pointer mint:rounded-xl mint:transition-colors mint:duration-150 mint:border-none mint:bg-none mint:hover:bg-[rgba(75,85,99,0.05)] mint:dark:hover:bg-[rgba(229,231,235,0.05)]\"\n >\n <div className=\"mint:border mint:border-[#e5e7eb] mint:dark:border-[rgba(255,255,255,0.07)] mint:rounded-lg mint:p-1 mint:shrink-0\">\n <option.icon className=\"mint:w-5 mint:h-5 mint:text-[#424242] mint:dark:text-[#b2b2b2]\" />\n </div>\n <div className=\"mint:flex mint:flex-col mint:flex-1 mint:min-w-0 mint:text-left\">\n <div className=\"mint:text-sm mint:font-medium mint:text-[#1f2937] mint:dark:text-[#d1d5db] mint:flex mint:items-center mint:gap-1.5\">\n {option.title}\n </div>\n <div className=\"mint:text-xs mint:text-[#6b7280] mint:dark:text-[#9ca3af] mint:mt-0.5\">\n {option.description}\n </div>\n </div>\n </button>\n ))}\n </div>\n )}\n </div>\n )}\n </div>\n );\n};\n"],"names":["PageContextMenu","className","pathname","markdownContent","onCopyMarkdown","onViewMarkdown","allPages","baseUrl","isOpen","setIsOpen","useState","isCopied","setIsCopied","dropdownRef","useRef","useEffect","timeout","handleClickOutside","event","copyPageAsMarkdown","clipboardItem","copyMarkdownToClipboard","error","viewAsMarkdown","viewLlmsTxtFile","viewLlmsFullTxtFile","wrapAction","actionFn","options","CopyRegular","MarkdownRegular","DocumentOnePageSparkleRegular","DocumentOnePageMultipleSparkleRegular","firstOption","jsxs","cn","jsx","Fragment","ChevronDownRegular","option","index"],"mappings":";;;;;AA8BO,MAAMA,IAAkB,CAAC;AAAA,EAC9B,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,SAAAC;AACF,MAA4B;AAC1B,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK,GACpC,CAACC,GAAUC,CAAW,IAAIF,EAAS,EAAK,GACxCG,IAAcC,EAAuB,IAAI;AAE/C,EAAAC,EAAU,MAAM;AACd,QAAIJ,GAAU;AAC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A;AAAA,IAAA;AAAA,EAAA;AAIR;"}
@@ -21,7 +21,7 @@ function j({ toc: i }) {
21
21
  if (!e) return (p = i[0]) == null ? void 0 : p.slug;
22
22
  const r = window.getComputedStyle(document.documentElement), E = parseFloat(
23
23
  r.getPropertyValue("--scroll-mt") || "0"
24
- ), R = parseFloat(r.fontSize), k = E * R + 100, h = e.scrollTop, f = i.map((s) => {
24
+ ), k = parseFloat(r.fontSize), R = E * k + 100, h = e.scrollTop, f = i.map((s) => {
25
25
  const v = document.getElementById(s.slug);
26
26
  if (!v) return null;
27
27
  const C = v.getBoundingClientRect(), I = e.getBoundingClientRect(), L = C.top - I.top + h;
@@ -30,7 +30,7 @@ function j({ toc: i }) {
30
30
  if (f.length === 0) return (b = i[0]) == null ? void 0 : b.slug;
31
31
  let a = f[0];
32
32
  for (const s of f)
33
- h + k >= s.top && (a = s);
33
+ h + R >= s.top && (a = s);
34
34
  return a == null ? void 0 : a.id;
35
35
  }, l = () => {
36
36
  if (o.current) return;
@@ -47,14 +47,14 @@ function j({ toc: i }) {
47
47
  }, [i]), /* @__PURE__ */ d("ul", { className: "mint:flex mint:flex-col mint:gap-1 mint:text-sm mint:text-[#6b7280] mint:dark:text-[#9ca3af] mint:font-medium mint:relative mint:pl-[0.15rem] mint:before:content-[''] mint:before:absolute mint:before:left-[0.15rem] mint:before:top-0 mint:before:bottom-0 mint:before:w-[3px] mint:before:bg-[#f2f3f3] mint:dark:before:bg-[#222223] mint:before:rounded-full", children: i.map((n, m) => {
48
48
  const e = x === n.slug;
49
49
  return /* @__PURE__ */ S("li", { className: "mint:relative", children: [
50
- e && /* @__PURE__ */ d("div", { className: "mint:absolute mint:left-0 mint:top-0 mint:bottom-0 mint:w-[3px] mint:rounded-full mint:bg-[#643fb2] mint:dark:bg-[#c9aaf9] mint:z-[1]" }),
50
+ e && /* @__PURE__ */ d("div", { className: "mint:absolute mint:left-0 mint:top-0 mint:bottom-0 mint:w-[3px] mint:rounded-full mint:bg-[#643fb2] mint:dark:bg-[#c9aaf9] mint:z-1" }),
51
51
  /* @__PURE__ */ d(
52
52
  "a",
53
53
  {
54
54
  href: `#${n.slug}`,
55
55
  className: A(
56
- "mint:block mint:pl-6 mint:leading-relaxed mint:transition-colors mint:duration-150 mint:no-underline",
57
- e ? "mint:text-[#643fb2] mint:dark:text-[#c9aaf9] font-semibold" : "mint:text-[#424242] mint:hover:text-[#111827] mint:dark:hover:text-[#d1d5db]"
56
+ "mint:block mint:pl-6 mint:leading-relaxed mint:no-underline",
57
+ e ? "mint:text-[#643fb2] mint:dark:text-[#c9aaf9] font-semibold" : "mint:text-[#424242] mint:dark:text-[#d6d6d6] mint:hover:text-[#111827] mint:dark:hover:text-[#d1d5db]"
58
58
  ),
59
59
  children: n.title
60
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/toc/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport type { TocItem } from \"../../types\";\nimport { cn } from \"../../utils/cn\";\n\ninterface TableOfContentsProps {\n toc: TocItem[];\n}\n\nexport function TableOfContents({ toc }: TableOfContentsProps) {\n const [activeId, setActiveId] = useState(\"\");\n const ignoreScrollRef = useRef(false);\n const ignoreTimeoutRef = useRef<NodeJS.Timeout>();\n\n useEffect(() => {\n if (toc.length === 0) return;\n\n ignoreScrollRef.current = false;\n if (ignoreTimeoutRef.current) {\n clearTimeout(ignoreTimeoutRef.current);\n }\n\n const hash = window.location.hash.slice(1);\n if (hash) {\n setActiveId(hash);\n ignoreScrollRef.current = true;\n ignoreTimeoutRef.current = setTimeout(() => {\n ignoreScrollRef.current = false;\n }, 1000);\n } else {\n setActiveId(toc[0]?.slug || \"\");\n }\n\n const handleHashChange = () => {\n const hash = window.location.hash.slice(1);\n if (hash) {\n setActiveId(hash);\n ignoreScrollRef.current = true;\n if (ignoreTimeoutRef.current) {\n clearTimeout(ignoreTimeoutRef.current);\n }\n ignoreTimeoutRef.current = setTimeout(() => {\n ignoreScrollRef.current = false;\n }, 1000);\n }\n };\n\n const scrollContainer = document.getElementById(\"main-content\");\n\n const getActiveHeading = () => {\n if (!scrollContainer) return toc[0]?.slug;\n\n const style = window.getComputedStyle(document.documentElement);\n const scrollMtRem = parseFloat(\n style.getPropertyValue(\"--scroll-mt\") || \"0\"\n );\n const fontSize = parseFloat(style.fontSize);\n const scrollOffset = scrollMtRem * fontSize + 100;\n\n const scrollY = scrollContainer.scrollTop;\n\n const headingPositions = toc\n .map((item) => {\n const element = document.getElementById(item.slug);\n if (!element) return null;\n\n const rect = element.getBoundingClientRect();\n const containerRect = scrollContainer.getBoundingClientRect();\n const relativeTop = rect.top - containerRect.top + scrollY;\n\n return { id: item.slug, top: relativeTop };\n })\n .filter(Boolean) as Array<{ id: string; top: number }>;\n\n if (headingPositions.length === 0) return toc[0]?.slug;\n\n let currentHeading = headingPositions[0];\n for (const heading of headingPositions) {\n if (scrollY + scrollOffset >= heading.top) {\n currentHeading = heading;\n }\n }\n\n return currentHeading?.id;\n };\n\n const handleScroll = () => {\n if (ignoreScrollRef.current) return;\n\n const newActiveId = getActiveHeading();\n if (newActiveId) {\n setActiveId(newActiveId);\n }\n };\n\n window.addEventListener(\"hashchange\", handleHashChange);\n\n if (scrollContainer) {\n scrollContainer.addEventListener(\"scroll\", handleScroll, {\n passive: true,\n });\n } else {\n window.addEventListener(\"scroll\", handleScroll, { passive: true });\n }\n\n let timeoutId: NodeJS.Timeout | undefined;\n if (!hash) {\n timeoutId = setTimeout(handleScroll, 100);\n }\n\n return () => {\n if (timeoutId) clearTimeout(timeoutId);\n if (ignoreTimeoutRef.current) clearTimeout(ignoreTimeoutRef.current);\n window.removeEventListener(\"hashchange\", handleHashChange);\n if (scrollContainer) {\n scrollContainer.removeEventListener(\"scroll\", handleScroll);\n } else {\n window.removeEventListener(\"scroll\", handleScroll);\n }\n };\n }, [toc]);\n\n return (\n <ul className=\"mint:flex mint:flex-col mint:gap-1 mint:text-sm mint:text-[#6b7280] mint:dark:text-[#9ca3af] mint:font-medium mint:relative mint:pl-[0.15rem] mint:before:content-[''] mint:before:absolute mint:before:left-[0.15rem] mint:before:top-0 mint:before:bottom-0 mint:before:w-[3px] mint:before:bg-[#f2f3f3] mint:dark:before:bg-[#222223] mint:before:rounded-full\">\n {toc.map((item, index) => {\n const isActive = activeId === item.slug;\n return (\n <li key={`${item.slug}-${index}`} className=\"mint:relative\">\n {isActive && (\n <div className=\"mint:absolute mint:left-0 mint:top-0 mint:bottom-0 mint:w-[3px] mint:rounded-full mint:bg-[#643fb2] mint:dark:bg-[#c9aaf9] mint:z-[1]\" />\n )}\n <a\n href={`#${item.slug}`}\n className={cn(\n \"mint:block mint:pl-6 mint:leading-relaxed mint:transition-colors mint:duration-150 mint:no-underline\",\n isActive\n ? \"mint:text-[#643fb2] mint:dark:text-[#c9aaf9] font-semibold\"\n : \"mint:text-[#424242] mint:hover:text-[#111827] mint:dark:hover:text-[#d1d5db]\"\n )}\n >\n {item.title}\n </a>\n </li>\n );\n })}\n </ul>\n );\n}\n"],"names":["TableOfContents","toc","activeId","setActiveId","useState","ignoreScrollRef","useRef","ignoreTimeoutRef","useEffect","hash","_a","handleHashChange","scrollContainer","getActiveHeading","style","scrollMtRem","fontSize","scrollOffset","scrollY","headingPositions","item","element","rect","containerRect","relativeTop","_b","currentHeading","heading","handleScroll","newActiveId","timeoutId","jsx","index","isActive","jsxs","cn"],"mappings":";;;AAQO,SAASA,EAAgB,EAAE,KAAAC,KAA6B;AAC7D,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAE,GACrCC,IAAkBC,EAAO,EAAK,GAC9BC,IAAmBD,EAAA;AAEzB,SAAAE,EAAU,MAAM;;AACd,QAAIP,EAAI,WAAW,EAAG;AAEtB,IAAAI,EAAgB,UAAU,IACtBE,EAAiB,WACnB,aAAaA,EAAiB,OAAO;AAGvC,UAAME,IAAO,OAAO,SAAS,KAAK,MAAM,CAAC;AACzC,IAAIA,KACFN,EAAYM,CAAI,GAChBJ,EAAgB,UA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/index.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport type { TocItem } from \"../../types\";\nimport { cn } from \"../../utils/cn\";\n\ninterface TableOfContentsProps {\n toc: TocItem[];\n}\n\nexport function TableOfContents({ toc }: TableOfContentsProps) {\n const [activeId, setActiveId] = useState(\"\");\n const ignoreScrollRef = useRef(false);\n const ignoreTimeoutRef = useRef<NodeJS.Timeout>();\n\n useEffect(() => {\n if (toc.length === 0) return;\n\n ignoreScrollRef.current = false;\n if (ignoreTimeoutRef.current) {\n clearTimeout(ignoreTimeoutRef.current);\n }\n\n const hash = window.location.hash.slice(1);\n if (hash) {\n setActiveId(hash);\n ignoreScrollRef.current = true;\n ignoreTimeoutRef.current = setTimeout(() => {\n ignoreScrollRef.current = false;\n }, 1000);\n } else {\n setActiveId(toc[0]?.slug || \"\");\n }\n\n const handleHashChange = () => {\n const hash = window.location.hash.slice(1);\n if (hash) {\n setActiveId(hash);\n ignoreScrollRef.current = true;\n if (ignoreTimeoutRef.current) {\n clearTimeout(ignoreTimeoutRef.current);\n }\n ignoreTimeoutRef.current = setTimeout(() => {\n ignoreScrollRef.current = false;\n }, 1000);\n }\n };\n\n const scrollContainer = document.getElementById(\"main-content\");\n\n const getActiveHeading = () => {\n if (!scrollContainer) return toc[0]?.slug;\n\n const style = window.getComputedStyle(document.documentElement);\n const scrollMtRem = parseFloat(\n style.getPropertyValue(\"--scroll-mt\") || \"0\"\n );\n const fontSize = parseFloat(style.fontSize);\n const scrollOffset = scrollMtRem * fontSize + 100;\n\n const scrollY = scrollContainer.scrollTop;\n\n const headingPositions = toc\n .map((item) => {\n const element = document.getElementById(item.slug);\n if (!element) return null;\n\n const rect = element.getBoundingClientRect();\n const containerRect = scrollContainer.getBoundingClientRect();\n const relativeTop = rect.top - containerRect.top + scrollY;\n\n return { id: item.slug, top: relativeTop };\n })\n .filter(Boolean) as Array<{ id: string; top: number }>;\n\n if (headingPositions.length === 0) return toc[0]?.slug;\n\n let currentHeading = headingPositions[0];\n for (const heading of headingPositions) {\n if (scrollY + scrollOffset >= heading.top) {\n currentHeading = heading;\n }\n }\n\n return currentHeading?.id;\n };\n\n const handleScroll = () => {\n if (ignoreScrollRef.current) return;\n\n const newActiveId = getActiveHeading();\n if (newActiveId) {\n setActiveId(newActiveId);\n }\n };\n\n window.addEventListener(\"hashchange\", handleHashChange);\n\n if (scrollContainer) {\n scrollContainer.addEventListener(\"scroll\", handleScroll, {\n passive: true,\n });\n } else {\n window.addEventListener(\"scroll\", handleScroll, { passive: true });\n }\n\n let timeoutId: NodeJS.Timeout | undefined;\n if (!hash) {\n timeoutId = setTimeout(handleScroll, 100);\n }\n\n return () => {\n if (timeoutId) clearTimeout(timeoutId);\n if (ignoreTimeoutRef.current) clearTimeout(ignoreTimeoutRef.current);\n window.removeEventListener(\"hashchange\", handleHashChange);\n if (scrollContainer) {\n scrollContainer.removeEventListener(\"scroll\", handleScroll);\n } else {\n window.removeEventListener(\"scroll\", handleScroll);\n }\n };\n }, [toc]);\n\n return (\n <ul className=\"mint:flex mint:flex-col mint:gap-1 mint:text-sm mint:text-[#6b7280] mint:dark:text-[#9ca3af] mint:font-medium mint:relative mint:pl-[0.15rem] mint:before:content-[''] mint:before:absolute mint:before:left-[0.15rem] mint:before:top-0 mint:before:bottom-0 mint:before:w-[3px] mint:before:bg-[#f2f3f3] mint:dark:before:bg-[#222223] mint:before:rounded-full\">\n {toc.map((item, index) => {\n const isActive = activeId === item.slug;\n return (\n <li key={`${item.slug}-${index}`} className=\"mint:relative\">\n {isActive && (\n <div className=\"mint:absolute mint:left-0 mint:top-0 mint:bottom-0 mint:w-[3px] mint:rounded-full mint:bg-[#643fb2] mint:dark:bg-[#c9aaf9] mint:z-1\" />\n )}\n <a\n href={`#${item.slug}`}\n className={cn(\n \"mint:block mint:pl-6 mint:leading-relaxed mint:no-underline\",\n isActive\n ? \"mint:text-[#643fb2] mint:dark:text-[#c9aaf9] font-semibold\"\n : \"mint:text-[#424242] mint:dark:text-[#d6d6d6] mint:hover:text-[#111827] mint:dark:hover:text-[#d1d5db]\"\n )}\n >\n {item.title}\n </a>\n </li>\n );\n })}\n </ul>\n );\n}\n"],"names":["TableOfContents","toc","activeId","setActiveId","useState","ignoreScrollRef","useRef","ignoreTimeoutRef","useEffect","hash","_a","handleHashChange","scrollContainer","getActiveHeading","style","scrollMtRem","fontSize","scrollOffset","scrollY","headingPositions","item","element","rect","containerRect","relativeTop","_b","currentHeading","heading","handleScroll","newActiveId","timeoutId","jsx","index","isActive","jsxs","cn"],"mappings":";;;AAQO,SAASA,EAAgB,EAAE,KAAAC,KAA6B;AAC7D,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAE,GACrCC,IAAkBC,EAAO,EAAK,GAC9BC,IAAmBD,EAAA;AAEzB,SAAAE,EAAU,MAAM;;AACd,QAAIP,EAAI,WAAW,EAAG;AAEtB,IAAAI,EAAgB,UAAU,IACtBE,EAAiB,WACnB,aAAaA,EAAiB,OAAO;AAGvC,UAAME,IAAO,OAAO,SAAS,KAAK,MAAM,CAAC;AACzC,IAAIA,KACFN,EAAYM,CAAI,GAChBJ,EAAgB,UAAU,IAC1BE,EAAiB,UAAU,WAAW,MAAM;AAC1C,MAAAF,EAAgB,UAAU;AAAA,IAC5B,GAAG,GAAI,KAEPF,IAAYO,IAAAT,EAAI,CAAC,MAAL,gBAAAS,EAAQ,SAAQ,EAAE;AAGhC,UAAMC,IAAmB,MAAM;AAC7B,YAAMF,IAAO,OAAO,SAAS,KAAK,MAAM,CAAC;AACzC,MAAIA,MACFN,EAAYM,CAAI,GAChBJ,EAAgB,UAAU,IACtBE,EAAiB,WACnB,aAAaA,EAAiB,OAAO,GAEvCA,EAAiB,UAAU,WAAW,MAAM;AAC1C,QAAAF,EAAgB,UAAU;AAAA,MAC5B,GAAG,GAAI;AAAA,IAEX,GAEMO,IAAkB,SAAS,eAAe,cAAc,GAExDC,IAAmB,MAAM;;AAC7B,UAAI,CAACD,EAAiB,SAAOF,IAAAT,EAA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