boltdocs 3.2.2 → 3.3.1
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/bin/boltdocs.js +20 -1
- package/bin/preloader.mjs +28 -0
- package/dist/{adapters-ByYY44Zy.mjs → adapters-BmB4TKCc.mjs} +1 -1
- package/dist/{adapters-DvmtpdSF.cjs → adapters-Cp1Maurn.cjs} +1 -1
- package/dist/audit-CLXjMzwQ.mjs +11 -0
- package/dist/audit-COgjnQ5n.cjs +11 -0
- package/dist/build-D6FfNA8m.cjs +6 -0
- package/dist/build-D_7SvwTh.mjs +6 -0
- package/dist/cache-CJE9nWLE.cjs +6 -0
- package/dist/cache-OY4HzIXl.mjs +6 -0
- package/dist/callout-oI_LCbxS.d.ts +71 -0
- package/dist/callout-plqx9Dw-.d.cts +71 -0
- package/dist/client/index.cjs +1265 -569
- package/dist/client/index.d.cts +3 -542
- package/dist/client/index.d.ts +3 -542
- package/dist/client/index.js +1167 -521
- package/dist/client/mdx.cjs +1 -1
- package/dist/client/mdx.d.cts +24 -2
- package/dist/client/mdx.d.ts +24 -2
- package/dist/client/mdx.js +1 -1
- package/dist/client/primitives.cjs +14 -4
- package/dist/client/primitives.d.cts +281 -38
- package/dist/client/primitives.d.ts +281 -38
- package/dist/client/primitives.js +5 -5
- package/dist/client/router.cjs +49 -0
- package/dist/client/router.d.cts +3 -0
- package/dist/client/router.d.ts +3 -0
- package/dist/client/router.js +8 -0
- package/dist/client/theme/reset.css +40 -4
- package/dist/{config-BpzaPsJj.d.cts → config-BoRlz0Ca.d.mts} +157 -14
- package/dist/{config-xtS0ZkMm.d.mts → config-CTsX_tGM.d.cts} +157 -14
- package/dist/config-Ceib-AOH.cjs +7 -0
- package/dist/config-DGLQsy7y.mjs +7 -0
- package/dist/{package-CH2ChQqw.cjs → config-files-BYHDOrKn.mjs} +1 -1
- package/dist/config-files-D9cdBMl2.cjs +6 -0
- package/dist/config-jJh8WYJI.cjs +6 -0
- package/dist/csp-C4LmN1ko.cjs +6 -0
- package/dist/csp-D6JEOqKh.mjs +6 -0
- package/dist/dev-B9l7fVoQ.cjs +6 -0
- package/dist/dev-CwOyh-wP.mjs +6 -0
- package/dist/{docs-layout-BdtZ9z6s.js → docs-layout-CbZ7LDRe.js} +504 -249
- package/dist/{docs-layout-CFWI15Id.cjs → docs-layout-vzfXed1Q.cjs} +516 -254
- package/dist/{doctor-BBtmNJE0.cjs → doctor-B1_YL0Wt.cjs} +1 -1
- package/dist/doctor-C7whl4ED.cjs +6 -0
- package/dist/doctor-DmQnml2k.mjs +6 -0
- package/dist/{generator-COepVWGi.cjs → generator-BlW45ST7.cjs} +5 -3
- package/dist/{generator-CcOBN5vI.mjs → generator-BwknNejd.mjs} +5 -3
- package/dist/{handler-XX7cLTqe.cjs → handler-CDEoKARD.cjs} +2 -2
- package/dist/{handler-DzQae4eA.mjs → handler-D7UyZlPm.mjs} +2 -2
- package/dist/{image-Bz87fCla.js → image-B-NDSDuY.js} +129 -11
- package/dist/{image-C4TlpMHn.cjs → image-Hnaa2bJd.cjs} +175 -9
- package/dist/index-C56bL-A-.d.cts +1344 -0
- package/dist/{sidebar-COTaMHR-.d.ts → index-CPUUKzxD.d.cts} +344 -327
- package/dist/{sidebar-CrEdJuHX.d.cts → index-Ci4kfOHF.d.ts} +344 -327
- package/dist/index-Cu9H6CRa.d.ts +1344 -0
- package/dist/link-CgdI6O2o.js +872 -0
- package/dist/{link-D1Gjkb-2.cjs → link-vZjmD-es.cjs} +406 -223
- package/dist/{mdx-BuO6a1f7.js → mdx-BRT71V5Q.js} +211 -168
- package/dist/{mdx-CD-tSjRG.cjs → mdx-D0Absdq5.cjs} +225 -169
- package/dist/native-BNCY7PRF.cjs +6 -0
- package/dist/native-Di9Fnfrv.mjs +6 -0
- package/dist/native-Kre2T5eS.cjs +6 -0
- package/dist/node/cache.cjs +1 -1
- package/dist/node/cache.d.cts +19 -3
- package/dist/node/cache.d.mts +19 -3
- package/dist/node/cache.mjs +1 -1
- package/dist/node/cli-entry.cjs +1 -9
- package/dist/node/cli-entry.mjs +1 -9
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +245 -17
- package/dist/node/index.d.mts +246 -18
- package/dist/node/index.mjs +1 -1
- package/dist/node/mdx/shiki-adapter.cjs +1 -1
- package/dist/node/mdx/shiki-adapter.d.cts +24 -3
- package/dist/node/mdx/shiki-adapter.d.mts +24 -2
- package/dist/node/mdx/shiki-adapter.mjs +1 -1
- package/dist/node-BFNCsPs3.mjs +23 -0
- package/dist/node-TpmWEqXM.cjs +23 -0
- package/dist/{package-DSSB8B5L.mjs → package-5EsGUTVl.mjs} +1 -1
- package/dist/package-Ca2WSiy2.cjs +6 -0
- package/dist/pages-external-BBw8ObVK.mjs +6 -0
- package/dist/pages-external-DPiPFxxP.cjs +6 -0
- package/dist/parser-BqTOsEUa.cjs +6 -0
- package/dist/parser-CGMY2lJ7.mjs +6 -0
- package/dist/plugin-CUmUZOLD.mjs +69 -0
- package/dist/plugin-Ds3RLYpy.cjs +69 -0
- package/dist/plugin-context-C-l90hFt.cjs +15 -0
- package/dist/plugin-context-wqHNSZum.mjs +15 -0
- package/dist/plugin-lifecycle-BAKNKOxd.cjs +6 -0
- package/dist/resolve-B7vWOd8R.cjs +6 -0
- package/dist/resolve-C2kKnk_5.mjs +6 -0
- package/dist/resolve-It1Iug83.cjs +6 -0
- package/dist/resolve-YdTrt_FG.mjs +6 -0
- package/dist/router-C3kygdRK.cjs +1285 -0
- package/dist/router-CZBxMRAH.js +987 -0
- package/dist/routes-BL4y79tb.mjs +6 -0
- package/dist/routes-C2nPecwu.cjs +6 -0
- package/dist/routes-U9L8psZ9.cjs +6 -0
- package/dist/{search-dialog-DFnlx8LO.js → search-dialog-BqkzDTq2.js} +107 -57
- package/dist/search-dialog-D3jtaw6w.cjs +525 -0
- package/dist/search-dialog-DRiXejws.js +501 -0
- package/dist/{search-dialog-DHqwjJuG.cjs → search-dialog-DmirOMPg.cjs} +1 -1
- package/dist/{search-dialog-D6TvjcuV.js → search-dialog-MmwxFMmE.js} +1 -1
- package/dist/{search-dialog-B1NERUNx.cjs → search-dialog-x_qHU8ty.cjs} +107 -58
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.mts +1 -1
- package/dist/server/index.mjs +1 -1
- package/dist/update-check-BKqmYfwT.cjs +11 -0
- package/dist/update-check-QnrVR3q1.mjs +11 -0
- package/dist/utils-8lzafE49.mjs +7 -0
- package/dist/utils-ej6_SjIZ.cjs +7 -0
- package/dist/virtual-modules-Ca5tHk1X.cjs +30 -0
- package/dist/virtual-modules-Dlgt1fP0.mjs +30 -0
- package/package.json +18 -16
- package/src/shared/mdx-path.ts +12 -0
- package/src/shared/structured-data.ts +145 -0
- package/src/shared/types.ts +220 -16
- package/dist/banner-BMop1KLF.d.ts +0 -100
- package/dist/banner-CVD0GugR.d.cts +0 -100
- package/dist/cache-CO4Dy2uQ.cjs +0 -6
- package/dist/cache-Dk53iOo6.mjs +0 -6
- package/dist/config-CCXp3aXO.mjs +0 -7
- package/dist/config-CMd4XoFq.cjs +0 -6
- package/dist/config-DlGoEM9D.cjs +0 -7
- package/dist/csp-CRp_3U7a.cjs +0 -6
- package/dist/csp-oTC2ygvF.mjs +0 -6
- package/dist/doctor-Bv16QSrI.cjs +0 -7
- package/dist/doctor-DOAbSaiL.mjs +0 -7
- package/dist/headers-Ddwek8K7.mjs +0 -6
- package/dist/headers-dg4SDrjY.cjs +0 -6
- package/dist/link-2PzgTnaP.js +0 -673
- package/dist/meta-loader-C4Hu9RN9.mjs +0 -6
- package/dist/meta-loader-Dq1zcFnh.cjs +0 -6
- package/dist/node-B5hu_6qj.cjs +0 -104
- package/dist/node-BXtqM1uH.mjs +0 -6
- package/dist/node-C8725aw7.mjs +0 -104
- package/dist/node-aD1eisrR.cjs +0 -6
- package/dist/pages-external-BYa4JSda.mjs +0 -6
- package/dist/pages-external-XkYIs-d5.cjs +0 -6
- package/dist/parser-DCiEWkSk.cjs +0 -8
- package/dist/parser-qk9FIHJ7.mjs +0 -8
- package/dist/plugin-CX1OZ6jB.cjs +0 -73
- package/dist/plugin-CgfiWaFZ.mjs +0 -73
- package/dist/routes-BW6zsk7Z.mjs +0 -6
- package/dist/routes-BgoIB5wb.cjs +0 -6
- package/dist/routes-CORVxc02.cjs +0 -6
- package/dist/search-dialog-BRFno7HD.cjs +0 -330
- package/dist/search-dialog-BmxHiKwt.js +0 -312
- package/dist/shiki-adapter-CoQ6jyJ4.cjs +0 -6
- package/dist/shiki-adapter-D-aKw7PP.mjs +0 -6
- package/dist/utils-Crm9oPcV.mjs +0 -7
- package/dist/utils-D6Xtj0FZ.cjs +0 -7
- /package/dist/{errors-0zGHRLue.mjs → errors-N-b6Sn2G.mjs} +0 -0
- /package/dist/{index-1KsTDq4o.d.mts → index-lFoyzCXy.d.mts} +0 -0
- /package/dist/{types-generator-BXhv7Ill.cjs → types-generator-DDSA93P3.cjs} +0 -0
- /package/dist/{types-generator-bDPvUztF.mjs → types-generator-DG1GX1EZ.mjs} +0 -0
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { G as useOptionalConfig, H as icons_exports, W as useConfig, d as resolvePublicAssetUrl, h as Check, l as useRoutesContext, o as cn, s as useLocalizedTo, t as Link, u as normalizePath, v as ChevronRight } from "./link-CgdI6O2o.js";
|
|
7
|
+
import { E as useLocation, L as defaultNavigate, O as useNavigate, m as parseUrlReference } from "./router-CZBxMRAH.js";
|
|
8
|
+
import { Children, Fragment, createContext, use, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
9
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import * as RAC from "react-aria-components";
|
|
11
11
|
import { Breadcrumb, Breadcrumbs, Popover } from "react-aria-components";
|
|
12
|
+
import DOMPurify from "isomorphic-dompurify";
|
|
12
13
|
import virtualIcons from "virtual:boltdocs-icons";
|
|
13
14
|
import scrollIntoView from "scroll-into-view-if-needed";
|
|
14
15
|
|
|
@@ -19,9 +20,10 @@ function UIProvider({ children }) {
|
|
|
19
20
|
const location = useLocation();
|
|
20
21
|
const toggleSidebar = () => setIsSidebarOpen((prev) => !prev);
|
|
21
22
|
const closeSidebar = () => setIsSidebarOpen(false);
|
|
23
|
+
const { pathname } = location;
|
|
22
24
|
useEffect(() => {
|
|
23
|
-
setIsSidebarOpen(false);
|
|
24
|
-
}, [
|
|
25
|
+
if (pathname) setIsSidebarOpen(false);
|
|
26
|
+
}, [pathname]);
|
|
25
27
|
return /* @__PURE__ */ jsx(UIContext.Provider, {
|
|
26
28
|
value: {
|
|
27
29
|
isSidebarOpen,
|
|
@@ -33,11 +35,14 @@ function UIProvider({ children }) {
|
|
|
33
35
|
}
|
|
34
36
|
function useUI() {
|
|
35
37
|
const context = useContext(UIContext);
|
|
36
|
-
if (context === void 0)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
if (context === void 0) {
|
|
39
|
+
if (typeof window !== "undefined") console.warn("[boltdocs] useUI() was called outside of a <UIProvider>. Make sure Navbar/Sidebar are rendered within BoltdocsShell. The mobile sidebar will not open until the provider is shared.");
|
|
40
|
+
return {
|
|
41
|
+
isSidebarOpen: false,
|
|
42
|
+
toggleSidebar: () => {},
|
|
43
|
+
closeSidebar: () => {}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
41
46
|
return context;
|
|
42
47
|
}
|
|
43
48
|
|
|
@@ -58,17 +63,20 @@ function BreadcrumbsItem({ children, className, ...props }) {
|
|
|
58
63
|
});
|
|
59
64
|
}
|
|
60
65
|
function BreadcrumbsLink({ children, href, className, ...props }) {
|
|
61
|
-
return /* @__PURE__ */ jsx(Link
|
|
66
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
62
67
|
href,
|
|
63
68
|
className: cn("cursor-pointer", className),
|
|
64
69
|
...props,
|
|
65
70
|
children
|
|
66
71
|
});
|
|
67
72
|
}
|
|
68
|
-
function BreadcrumbsSeparator({ className }) {
|
|
69
|
-
return /* @__PURE__ */ jsx(
|
|
70
|
-
|
|
71
|
-
|
|
73
|
+
function BreadcrumbsSeparator({ className, separator }) {
|
|
74
|
+
return /* @__PURE__ */ jsx("span", {
|
|
75
|
+
className,
|
|
76
|
+
children: separator ?? /* @__PURE__ */ jsx(ChevronRight, {
|
|
77
|
+
size: 14,
|
|
78
|
+
className: "shrink-0"
|
|
79
|
+
})
|
|
72
80
|
});
|
|
73
81
|
}
|
|
74
82
|
Breadcrumbs$1.Root = Breadcrumbs$1;
|
|
@@ -78,22 +86,54 @@ Breadcrumbs$1.Separator = BreadcrumbsSeparator;
|
|
|
78
86
|
|
|
79
87
|
//#endregion
|
|
80
88
|
//#region src/client/components/primitives/button-group.tsx
|
|
81
|
-
|
|
89
|
+
const RADIUS_BY_RADIUS = {
|
|
90
|
+
full: [
|
|
91
|
+
"[&>*:first-child]:rounded-l-full",
|
|
92
|
+
"[&>*:last-child]:rounded-r-full",
|
|
93
|
+
"[&>*:first-child]:rounded-t-full",
|
|
94
|
+
"[&>*:last-child]:rounded-b-full"
|
|
95
|
+
],
|
|
96
|
+
xl: [
|
|
97
|
+
"[&>*:first-child]:rounded-l-xl",
|
|
98
|
+
"[&>*:last-child]:rounded-r-xl",
|
|
99
|
+
"[&>*:first-child]:rounded-t-xl",
|
|
100
|
+
"[&>*:last-child]:rounded-b-xl"
|
|
101
|
+
],
|
|
102
|
+
lg: [
|
|
103
|
+
"[&>*:first-child]:rounded-l-lg",
|
|
104
|
+
"[&>*:last-child]:rounded-r-lg",
|
|
105
|
+
"[&>*:first-child]:rounded-t-lg",
|
|
106
|
+
"[&>*:last-child]:rounded-b-lg"
|
|
107
|
+
],
|
|
108
|
+
md: [
|
|
109
|
+
"[&>*:first-child]:rounded-l-md",
|
|
110
|
+
"[&>*:last-child]:rounded-r-md",
|
|
111
|
+
"[&>*:first-child]:rounded-t-md",
|
|
112
|
+
"[&>*:last-child]:rounded-b-md"
|
|
113
|
+
],
|
|
114
|
+
none: []
|
|
115
|
+
};
|
|
116
|
+
function inferRadius(className) {
|
|
117
|
+
if (className?.includes("rounded-full")) return "full";
|
|
118
|
+
if (className?.includes("rounded-xl")) return "xl";
|
|
119
|
+
if (className?.includes("rounded-lg")) return "lg";
|
|
120
|
+
return "md";
|
|
121
|
+
}
|
|
122
|
+
function ButtonGroup({ children, className, vertical = false, radius }) {
|
|
123
|
+
const outer = RADIUS_BY_RADIUS[radius ?? inferRadius(className)] ?? [];
|
|
82
124
|
return /* @__PURE__ */ jsx("div", {
|
|
83
125
|
className: cn("inline-flex", vertical ? "flex-col" : "flex-row", !vertical && [
|
|
84
126
|
"[&>*:not(:first-child)]:-ml-px",
|
|
85
127
|
"[&>*:first-child]:rounded-r-none",
|
|
86
128
|
"[&>*:last-child]:rounded-l-none",
|
|
87
129
|
"[&>*:not(:first-child):not(:last-child)]:rounded-none",
|
|
88
|
-
|
|
89
|
-
className?.includes("rounded-xl") && ["[&>*:first-child]:rounded-l-xl", "[&>*:last-child]:rounded-r-xl"],
|
|
90
|
-
className?.includes("rounded-lg") && ["[&>*:first-child]:rounded-l-lg", "[&>*:last-child]:rounded-r-lg"]
|
|
130
|
+
outer.filter((c) => c.includes("rounded-l-") || c.includes("rounded-r-"))
|
|
91
131
|
], vertical && [
|
|
92
132
|
"[&>*:not(:first-child)]:-mt-px",
|
|
93
133
|
"[&>*:first-child]:rounded-b-none",
|
|
94
134
|
"[&>*:last-child]:rounded-t-none",
|
|
95
135
|
"[&>*:not(:first-child):not(:last-child)]:rounded-none",
|
|
96
|
-
|
|
136
|
+
outer.filter((c) => c.includes("rounded-t-") || c.includes("rounded-b-"))
|
|
97
137
|
], className),
|
|
98
138
|
children
|
|
99
139
|
});
|
|
@@ -152,29 +192,33 @@ function Menu(props) {
|
|
|
152
192
|
*/
|
|
153
193
|
function MenuItem(props) {
|
|
154
194
|
const textValue = props.textValue || (typeof props.children === "string" ? props.children : void 0);
|
|
195
|
+
const { contentClassName, checkClassName, chevronClassName, check, chevron, ...racProps } = props;
|
|
155
196
|
return /* @__PURE__ */ jsx(RAC.MenuItem, {
|
|
156
|
-
...
|
|
197
|
+
...racProps,
|
|
157
198
|
textValue,
|
|
158
199
|
className: RAC.composeRenderProps(props.className, (className) => cn("group relative flex flex-row items-center cursor-default outline-none", className)),
|
|
159
|
-
children: RAC.composeRenderProps(props.children, (children, { selectionMode, isSelected, hasSubmenu }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
200
|
+
children: RAC.composeRenderProps(props.children, (children, { selectionMode, isSelected, hasSubmenu }) => /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
160
201
|
selectionMode === "multiple" && /* @__PURE__ */ jsx("span", {
|
|
161
|
-
className: "flex items-center shrink-0 justify-center",
|
|
162
|
-
children: isSelected
|
|
202
|
+
className: cn("flex items-center shrink-0 justify-center", checkClassName),
|
|
203
|
+
children: check ?? (isSelected ? /* @__PURE__ */ jsx(Check, { className: "size-3.5" }) : null)
|
|
163
204
|
}),
|
|
164
205
|
/* @__PURE__ */ jsx("div", {
|
|
165
|
-
className: "flex flex-row w-full items-center",
|
|
206
|
+
className: cn("flex flex-row w-full items-center", contentClassName),
|
|
166
207
|
children
|
|
167
208
|
}),
|
|
168
|
-
hasSubmenu && /* @__PURE__ */ jsx(
|
|
209
|
+
hasSubmenu && /* @__PURE__ */ jsx("span", {
|
|
210
|
+
className: "ml-auto",
|
|
211
|
+
children: chevron ?? /* @__PURE__ */ jsx(ChevronRight, { className: cn("size-4", chevronClassName) })
|
|
212
|
+
})
|
|
169
213
|
] }))
|
|
170
214
|
});
|
|
171
215
|
}
|
|
172
|
-
function MenuSection({ title, ...props }) {
|
|
216
|
+
function MenuSection({ title, headerClassName, ...props }) {
|
|
173
217
|
return /* @__PURE__ */ jsxs(RAC.MenuSection, {
|
|
174
218
|
...props,
|
|
175
219
|
className: cn("flex flex-col", props.className),
|
|
176
220
|
children: [title && /* @__PURE__ */ jsx(RAC.Header, {
|
|
177
|
-
className: "select-none",
|
|
221
|
+
className: cn("select-none", headerClassName),
|
|
178
222
|
children: title
|
|
179
223
|
}), /* @__PURE__ */ jsx(RAC.Collection, {
|
|
180
224
|
items: props.items,
|
|
@@ -242,33 +286,126 @@ Tabs.Item = TabsItem;
|
|
|
242
286
|
Tabs.Content = TabsContent;
|
|
243
287
|
Tabs.Indicator = TabsIndicator;
|
|
244
288
|
|
|
289
|
+
//#endregion
|
|
290
|
+
//#region src/client/components/ui-base/icon-renderer.tsx
|
|
291
|
+
function isRecord(value) {
|
|
292
|
+
return typeof value === "object" && value !== null;
|
|
293
|
+
}
|
|
294
|
+
function normalizeIconExports(value) {
|
|
295
|
+
if (!isRecord(value)) return {};
|
|
296
|
+
const directExports = Object.fromEntries(Object.entries(value).filter(([key]) => key !== "default"));
|
|
297
|
+
const defaultExport = value.default;
|
|
298
|
+
if (!isRecord(defaultExport)) return directExports;
|
|
299
|
+
return {
|
|
300
|
+
...normalizeIconExports(defaultExport),
|
|
301
|
+
...directExports
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
function getIconRegistry() {
|
|
305
|
+
return {
|
|
306
|
+
...icons_exports,
|
|
307
|
+
...normalizeIconExports(virtualIcons)
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
function resolveIcon(icon, registry = getIconRegistry()) {
|
|
311
|
+
if (!icon || typeof icon !== "string") return icon;
|
|
312
|
+
if (icon.trim().startsWith("<svg")) return icon;
|
|
313
|
+
if (/^(?:https?:|data:image\/|\/|\.\.?(?:\/|$))/.test(icon) || /\.(?:svg|png|jpe?g|gif|webp|avif)(?:\?.*)?$/i.test(icon)) return icon;
|
|
314
|
+
return registry[icon] || registry[`${icon}Icon`];
|
|
315
|
+
}
|
|
316
|
+
function isImageSource(value) {
|
|
317
|
+
return /^(?:https?:|data:image\/|\/|\.\.?(?:\/|$))/.test(value) || /\.(?:svg|png|jpe?g|gif|webp|avif)(?:\?.*)?$/i.test(value);
|
|
318
|
+
}
|
|
319
|
+
function IconRenderer({ icon, size = 16, className, label }) {
|
|
320
|
+
const config = useOptionalConfig();
|
|
321
|
+
const resolved = resolveIcon(icon);
|
|
322
|
+
if (!resolved) return null;
|
|
323
|
+
if (typeof resolved === "function") return /* @__PURE__ */ jsx(resolved, {
|
|
324
|
+
size,
|
|
325
|
+
width: size,
|
|
326
|
+
height: size,
|
|
327
|
+
className,
|
|
328
|
+
"aria-hidden": label ? void 0 : true,
|
|
329
|
+
"aria-label": label
|
|
330
|
+
});
|
|
331
|
+
if (resolved.trim().startsWith("<svg")) {
|
|
332
|
+
const clean = DOMPurify.sanitize(resolved, { USE_PROFILES: { svg: true } });
|
|
333
|
+
if (label) return /* @__PURE__ */ jsx("span", {
|
|
334
|
+
className,
|
|
335
|
+
role: "img",
|
|
336
|
+
"aria-label": label,
|
|
337
|
+
dangerouslySetInnerHTML: { __html: clean }
|
|
338
|
+
});
|
|
339
|
+
return /* @__PURE__ */ jsx("span", {
|
|
340
|
+
className,
|
|
341
|
+
"aria-hidden": "true",
|
|
342
|
+
dangerouslySetInnerHTML: { __html: clean }
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
if (isImageSource(resolved)) return /* @__PURE__ */ jsx("img", {
|
|
346
|
+
src: resolvePublicAssetUrl(resolved, config?.base),
|
|
347
|
+
alt: label || "",
|
|
348
|
+
"aria-hidden": label ? void 0 : true,
|
|
349
|
+
className,
|
|
350
|
+
width: size,
|
|
351
|
+
height: size
|
|
352
|
+
});
|
|
353
|
+
return null;
|
|
354
|
+
}
|
|
355
|
+
|
|
245
356
|
//#endregion
|
|
246
357
|
//#region src/client/hooks/use-sidebar.ts
|
|
247
358
|
const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1).replace(/-/g, " ");
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
359
|
+
/**
|
|
360
|
+
* Builds a lookup map from meta.json relative-directory keys.
|
|
361
|
+
* Keys keep the locale (`es/...`) and tab (`(guides)/...`) segments so meta
|
|
362
|
+
* resolution can be scoped per tab and per locale; numeric prefixes are
|
|
363
|
+
* stripped and keys are lowercased for stable matching.
|
|
364
|
+
*/
|
|
365
|
+
const getDirectoryMetaLookup = (directoryMeta) => {
|
|
366
|
+
const lookup = {};
|
|
367
|
+
if (!directoryMeta) return lookup;
|
|
251
368
|
for (const [key, value] of Object.entries(directoryMeta)) {
|
|
252
|
-
const
|
|
253
|
-
|
|
369
|
+
const normalizedKey = key.split("/").map((part) => part.replace(/^\d+-/, "")).join("/").toLowerCase();
|
|
370
|
+
lookup[normalizedKey] = value;
|
|
371
|
+
}
|
|
372
|
+
return lookup;
|
|
373
|
+
};
|
|
374
|
+
/**
|
|
375
|
+
* Resolves the meta.json entry for a sidebar group by trying increasingly
|
|
376
|
+
* specific directory keys: locale + tab, tab, locale, then the bare path.
|
|
377
|
+
* This keeps groups that share a directory name across tabs or locales
|
|
378
|
+
* (e.g. `(guides)/content` vs `(plugins)/content`) from clobbering each
|
|
379
|
+
* other and lets localized sites resolve their own translated meta.
|
|
380
|
+
*/
|
|
381
|
+
const findDirectoryMeta = (lookup, route, relPath) => {
|
|
382
|
+
const locale = route?.locale;
|
|
383
|
+
const tab = route?.tab;
|
|
384
|
+
const candidates = [];
|
|
385
|
+
if (locale && tab) candidates.push(`${locale}/(${tab})/${relPath}`);
|
|
386
|
+
if (tab) candidates.push(`(${tab})/${relPath}`);
|
|
387
|
+
if (locale) candidates.push(`${locale}/${relPath}`);
|
|
388
|
+
candidates.push(relPath);
|
|
389
|
+
for (const candidate of candidates) {
|
|
390
|
+
const meta = lookup[candidate.toLowerCase()];
|
|
391
|
+
if (meta) return meta;
|
|
254
392
|
}
|
|
255
|
-
return meta;
|
|
256
393
|
};
|
|
257
|
-
const getOrCreateNode = (parts, rootMap,
|
|
394
|
+
const getOrCreateNode = (parts, rootMap, directoryMetaLookup, route) => {
|
|
258
395
|
let currentMap = rootMap;
|
|
259
396
|
let parentPath = "";
|
|
260
397
|
let lastNode;
|
|
261
398
|
for (const segment of parts) {
|
|
262
399
|
const currentRelPath = parentPath ? `${parentPath}/${segment}` : segment;
|
|
263
400
|
if (!currentMap.has(segment)) {
|
|
264
|
-
const meta =
|
|
401
|
+
const meta = findDirectoryMeta(directoryMetaLookup, route, currentRelPath) || {};
|
|
265
402
|
const newNode = {
|
|
266
403
|
path: "#",
|
|
267
404
|
title: meta.title || capitalize(segment),
|
|
268
405
|
componentPath: "",
|
|
269
406
|
filePath: "",
|
|
270
407
|
icon: meta.icon,
|
|
271
|
-
groupPosition: typeof meta.order === "number" ? meta.order :
|
|
408
|
+
groupPosition: typeof meta.order === "number" ? meta.order : void 0,
|
|
272
409
|
collapsible: meta.collapsible,
|
|
273
410
|
collapsed: meta.collapsed,
|
|
274
411
|
hasCustomTitle: meta.title !== void 0,
|
|
@@ -283,6 +420,20 @@ const getOrCreateNode = (parts, rootMap, directoryMeta) => {
|
|
|
283
420
|
}
|
|
284
421
|
return lastNode;
|
|
285
422
|
};
|
|
423
|
+
/**
|
|
424
|
+
* Whether a route (or any of its nested children) matches the active path or
|
|
425
|
+
* the active route's file. Used for group-level active detection and for the
|
|
426
|
+
* `isActive` helper exposed by `useSidebar`.
|
|
427
|
+
*/
|
|
428
|
+
function isRouteActive(route, activePath, activeRoute) {
|
|
429
|
+
if (!route?.path) return false;
|
|
430
|
+
const normalizedPath = route.path.endsWith("/") ? route.path.slice(0, -1) : route.path;
|
|
431
|
+
if ((activePath.endsWith("/") ? activePath.slice(0, -1) : activePath) === normalizedPath) return true;
|
|
432
|
+
if (activeRoute?.filePath && route.filePath && activeRoute.filePath === route.filePath) return true;
|
|
433
|
+
if (route.routes?.some((r) => isRouteActive(r, activePath, activeRoute))) return true;
|
|
434
|
+
if (route.subRoutes?.some((r) => isRouteActive(r, activePath, activeRoute))) return true;
|
|
435
|
+
return false;
|
|
436
|
+
}
|
|
286
437
|
const getRoutePosition = (r) => r.sidebarPosition ?? r.order ?? 999;
|
|
287
438
|
const getNodePosition = (n) => n.sidebarPosition ?? n.groupPosition ?? 999;
|
|
288
439
|
const finalizeTree = (nodes) => {
|
|
@@ -303,12 +454,18 @@ const finalizeTree = (nodes) => {
|
|
|
303
454
|
function useSidebar(routes) {
|
|
304
455
|
const config = useConfig();
|
|
305
456
|
const { pathname } = useLocation();
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
457
|
+
const { index } = useRoutesContext();
|
|
458
|
+
const currentPath = normalizePath(pathname);
|
|
459
|
+
const activeRoute = index.byPath.size > 0 ? index.byPath.get(currentPath) : routes.find((route) => normalizePath(route.path) === currentPath);
|
|
460
|
+
const configuredTabs = config.theme?.tabs || [];
|
|
461
|
+
const configuredTabIds = new Set(configuredTabs.map((tab) => tab.id.toLowerCase()));
|
|
462
|
+
const normalizedBase = normalizePath(config.base || "/docs");
|
|
463
|
+
const routeTabId = activeRoute?.tab?.toLowerCase();
|
|
464
|
+
const parsedCurrentRoute = parseUrlReference(currentPath, config, { kind: "doc" });
|
|
465
|
+
const activeTabId = (currentPath === normalizedBase || Boolean(activeRoute?.fallback) && parsedCurrentRoute.routePath === "/" || currentPath.startsWith(`${normalizedBase}/`) && parsedCurrentRoute.routePath === "/" ? configuredTabs[0]?.id.toLowerCase() : routeTabId && configuredTabIds.has(routeTabId) ? routeTabId : void 0) || void 0;
|
|
466
|
+
const sidebar = useMemo(() => {
|
|
467
|
+
const filteredRoutes = routes.filter((r) => !r.collection && !r.sidebarHidden && !r.fallback).filter((r) => !configuredTabs.length || r.tab?.toLowerCase() === activeTabId).sort((a, b) => getRoutePosition(a) - getRoutePosition(b));
|
|
468
|
+
const directoryMeta = getDirectoryMetaLookup(config.directoryMeta);
|
|
312
469
|
const rootNodesMap = /* @__PURE__ */ new Map();
|
|
313
470
|
const ungrouped = [];
|
|
314
471
|
for (const route of filteredRoutes) {
|
|
@@ -318,13 +475,13 @@ function useSidebar(routes) {
|
|
|
318
475
|
if (route.filePath) ungrouped.push(route);
|
|
319
476
|
continue;
|
|
320
477
|
}
|
|
321
|
-
const containerNode = getOrCreateNode(parts, rootNodesMap, directoryMeta);
|
|
478
|
+
const containerNode = getOrCreateNode(parts, rootNodesMap, directoryMeta, route);
|
|
322
479
|
if (isIndex) Object.assign(containerNode, {
|
|
323
480
|
path: route.path,
|
|
324
481
|
title: containerNode.hasCustomTitle ? containerNode.title : route.title || containerNode.title,
|
|
325
482
|
icon: route.icon || containerNode.icon,
|
|
326
483
|
badge: route.badge,
|
|
327
|
-
sidebarPosition: route.sidebarPosition,
|
|
484
|
+
sidebarPosition: containerNode.groupPosition === void 0 ? route.sidebarPosition : void 0,
|
|
328
485
|
frontmatter: route.frontmatter,
|
|
329
486
|
filePath: route.filePath
|
|
330
487
|
});
|
|
@@ -332,45 +489,93 @@ function useSidebar(routes) {
|
|
|
332
489
|
}
|
|
333
490
|
const finalizedTopNodes = finalizeTree(Array.from(rootNodesMap.values()));
|
|
334
491
|
const groups = [];
|
|
335
|
-
for (const node of finalizedTopNodes) if (node.subRoutes && node.subRoutes.length > 0)
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
492
|
+
for (const node of finalizedTopNodes) if (node.subRoutes && node.subRoutes.length > 0) {
|
|
493
|
+
const nodeWithMeta = node;
|
|
494
|
+
groups.push({
|
|
495
|
+
slug: node.title.toLowerCase().replace(/\s+/g, "-"),
|
|
496
|
+
title: node.title,
|
|
497
|
+
icon: node.icon,
|
|
498
|
+
path: node.path,
|
|
499
|
+
filePath: node.filePath,
|
|
500
|
+
routes: node.subRoutes,
|
|
501
|
+
sidebarPosition: node.sidebarPosition ?? node.groupPosition ?? 999,
|
|
502
|
+
collapsible: nodeWithMeta.collapsible,
|
|
503
|
+
collapsed: nodeWithMeta.collapsed
|
|
504
|
+
});
|
|
505
|
+
} else ungrouped.push(node);
|
|
506
|
+
const finalizedUngrouped = finalizeTree(ungrouped);
|
|
347
507
|
return {
|
|
348
508
|
groups,
|
|
349
|
-
ungrouped:
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
509
|
+
ungrouped: finalizedUngrouped,
|
|
510
|
+
merged: [...finalizedUngrouped.map((route) => ({
|
|
511
|
+
type: "link",
|
|
512
|
+
position: route.sidebarPosition ?? 999,
|
|
513
|
+
title: route.title,
|
|
514
|
+
route
|
|
515
|
+
})), ...groups.map((group) => ({
|
|
516
|
+
type: "group",
|
|
517
|
+
position: group.sidebarPosition ?? 999,
|
|
518
|
+
title: group.title,
|
|
519
|
+
group
|
|
520
|
+
}))].sort((a, b) => {
|
|
521
|
+
if (a.position !== b.position) return a.position - b.position;
|
|
522
|
+
if (a.type !== b.type) return a.type === "link" ? -1 : 1;
|
|
523
|
+
return a.title.localeCompare(b.title);
|
|
524
|
+
})
|
|
353
525
|
};
|
|
354
526
|
}, [
|
|
355
527
|
routes,
|
|
356
528
|
config,
|
|
357
|
-
|
|
529
|
+
activeTabId,
|
|
530
|
+
configuredTabs.length
|
|
531
|
+
]);
|
|
532
|
+
const isActive = useCallback((route) => isRouteActive(route, currentPath, activeRoute), [currentPath, activeRoute]);
|
|
533
|
+
const isGroupActive = useCallback((group) => group.routes.some((route) => isRouteActive(route, currentPath, activeRoute)), [currentPath, activeRoute]);
|
|
534
|
+
const tree = useMemo(() => {
|
|
535
|
+
const buildNode = (route, depth) => {
|
|
536
|
+
const children = route.routes || route.subRoutes || [];
|
|
537
|
+
return {
|
|
538
|
+
route,
|
|
539
|
+
depth,
|
|
540
|
+
isGroup: false,
|
|
541
|
+
isActive: isRouteActive(route, currentPath, activeRoute),
|
|
542
|
+
hasChildren: children.length > 0,
|
|
543
|
+
children: children.map((child) => buildNode(child, depth + 1))
|
|
544
|
+
};
|
|
545
|
+
};
|
|
546
|
+
const buildGroupNode = (group) => ({
|
|
547
|
+
route: group,
|
|
548
|
+
depth: 0,
|
|
549
|
+
isGroup: true,
|
|
550
|
+
isActive: isGroupActive(group),
|
|
551
|
+
hasChildren: true,
|
|
552
|
+
children: group.routes.map((route) => buildNode(route, 1))
|
|
553
|
+
});
|
|
554
|
+
return sidebar.merged.map((item) => item.type === "group" ? buildGroupNode(item.group) : buildNode(item.route, 0));
|
|
555
|
+
}, [
|
|
556
|
+
sidebar,
|
|
557
|
+
activeRoute,
|
|
558
|
+
currentPath,
|
|
559
|
+
isGroupActive
|
|
358
560
|
]);
|
|
561
|
+
return {
|
|
562
|
+
...sidebar,
|
|
563
|
+
tree,
|
|
564
|
+
isActive,
|
|
565
|
+
isGroupActive,
|
|
566
|
+
activeRoute,
|
|
567
|
+
activePath: currentPath,
|
|
568
|
+
config
|
|
569
|
+
};
|
|
359
570
|
}
|
|
360
571
|
|
|
361
|
-
//#endregion
|
|
362
|
-
//#region src/client/hooks/use-location.ts
|
|
363
|
-
const useLocation$1 = () => {
|
|
364
|
-
return useLocation();
|
|
365
|
-
};
|
|
366
|
-
|
|
367
572
|
//#endregion
|
|
368
573
|
//#region src/client/hooks/use-search-highlight.ts
|
|
369
574
|
/**
|
|
370
575
|
* Hook to highlight search terms based on the 'hl' query parameter.
|
|
371
576
|
*/
|
|
372
577
|
function useSearchHighlight(containerSelector = ".boltdocs-page") {
|
|
373
|
-
const { search } = useLocation
|
|
578
|
+
const { search } = useLocation();
|
|
374
579
|
const query = new URLSearchParams(search).get("hl");
|
|
375
580
|
useEffect(() => {
|
|
376
581
|
if (!query) {
|
|
@@ -406,11 +611,7 @@ function useSearchHighlight(containerSelector = ".boltdocs-page") {
|
|
|
406
611
|
observer.disconnect();
|
|
407
612
|
clearHighlights(containerSelector);
|
|
408
613
|
};
|
|
409
|
-
}, [
|
|
410
|
-
query,
|
|
411
|
-
search,
|
|
412
|
-
containerSelector
|
|
413
|
-
]);
|
|
614
|
+
}, [query, containerSelector]);
|
|
414
615
|
}
|
|
415
616
|
function clearHighlights(selector) {
|
|
416
617
|
document.querySelectorAll(`${selector} mark[data-search-highlight]`).forEach((mark) => {
|
|
@@ -430,8 +631,11 @@ function highlightTerms(container, terms) {
|
|
|
430
631
|
return NodeFilter.FILTER_ACCEPT;
|
|
431
632
|
} });
|
|
432
633
|
const nodes = [];
|
|
433
|
-
let node;
|
|
434
|
-
while (node
|
|
634
|
+
let node = walker.nextNode();
|
|
635
|
+
while (node) {
|
|
636
|
+
nodes.push(node);
|
|
637
|
+
node = walker.nextNode();
|
|
638
|
+
}
|
|
435
639
|
const accentMap = {
|
|
436
640
|
a: "[aáàäâã]",
|
|
437
641
|
e: "[eéèëê]",
|
|
@@ -628,7 +832,7 @@ function AnchorProvider({ toc, single = false, observerOptions, children }) {
|
|
|
628
832
|
return () => {
|
|
629
833
|
observer.unwatch();
|
|
630
834
|
};
|
|
631
|
-
}, [observer]);
|
|
835
|
+
}, [observer, observerOptions]);
|
|
632
836
|
return /* @__PURE__ */ jsx(ItemsContext.Provider, {
|
|
633
837
|
value: items,
|
|
634
838
|
children
|
|
@@ -636,53 +840,64 @@ function AnchorProvider({ toc, single = false, observerOptions, children }) {
|
|
|
636
840
|
}
|
|
637
841
|
function OnThisPage({ children, className }) {
|
|
638
842
|
return /* @__PURE__ */ jsx("nav", {
|
|
639
|
-
|
|
843
|
+
"data-otp-root": true,
|
|
844
|
+
className,
|
|
640
845
|
children
|
|
641
846
|
});
|
|
642
847
|
}
|
|
643
848
|
function OnThisPageHeader({ children, className, ...props }) {
|
|
644
849
|
return /* @__PURE__ */ jsx("div", {
|
|
645
|
-
className
|
|
850
|
+
className,
|
|
646
851
|
...props,
|
|
647
852
|
children
|
|
648
853
|
});
|
|
649
854
|
}
|
|
650
|
-
function OnThisPageContent({ children, className, ref, ...props }) {
|
|
855
|
+
function OnThisPageContent({ children, className, ref, fadeClassName, innerClassName, ...props }) {
|
|
651
856
|
const internalRef = useRef(null);
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
857
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
858
|
+
ref: useCallback((node) => {
|
|
859
|
+
internalRef.current = node;
|
|
860
|
+
if (typeof ref === "function") ref(node);
|
|
861
|
+
else if (ref) ref.current = node;
|
|
862
|
+
}, [ref]),
|
|
863
|
+
"data-otp-content": true,
|
|
864
|
+
className: cn("relative isolate overflow-y-auto", className),
|
|
660
865
|
...props,
|
|
661
|
-
children
|
|
866
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
867
|
+
className: cn("relative z-10", innerClassName),
|
|
868
|
+
children
|
|
869
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
870
|
+
"aria-hidden": "true",
|
|
871
|
+
"data-otp-fade": true,
|
|
872
|
+
className: cn("pointer-events-none sticky bottom-0 z-0 -mt-10 h-10 w-full", fadeClassName)
|
|
873
|
+
})]
|
|
662
874
|
});
|
|
663
875
|
}
|
|
664
876
|
OnThisPageContent.displayName = "OnThisPageContent";
|
|
665
877
|
function OnThisPageList({ children, className }) {
|
|
666
878
|
return /* @__PURE__ */ jsx("ul", {
|
|
667
|
-
|
|
879
|
+
"data-otp-list": true,
|
|
880
|
+
className: cn("relative", className),
|
|
668
881
|
children
|
|
669
882
|
});
|
|
670
883
|
}
|
|
671
884
|
function OnThisPageItem({ level, children, className }) {
|
|
672
885
|
return /* @__PURE__ */ jsx("li", {
|
|
673
|
-
|
|
886
|
+
"data-level": level || void 0,
|
|
887
|
+
className,
|
|
674
888
|
children
|
|
675
889
|
});
|
|
676
890
|
}
|
|
677
891
|
function OnThisPageLink({ children, href, active, onClick, className }) {
|
|
678
892
|
const items = use(ItemsContext);
|
|
679
893
|
const containerRef = use(ScrollContext);
|
|
894
|
+
const navigate = useNavigate();
|
|
680
895
|
const id = href ? getItemId(href) : null;
|
|
681
896
|
const anchorRef = useRef(null);
|
|
682
897
|
const computedActive = active !== void 0 ? active : id && items ? !!items.find((i) => i.id === id)?.active : false;
|
|
683
898
|
useEffect(() => {
|
|
684
899
|
if (computedActive && anchorRef.current && containerRef?.current) scrollIntoView(anchorRef.current, {
|
|
685
|
-
behavior: "
|
|
900
|
+
behavior: "auto",
|
|
686
901
|
block: "center",
|
|
687
902
|
inline: "center",
|
|
688
903
|
scrollMode: "if-needed",
|
|
@@ -690,14 +905,14 @@ function OnThisPageLink({ children, href, active, onClick, className }) {
|
|
|
690
905
|
});
|
|
691
906
|
}, [computedActive, containerRef]);
|
|
692
907
|
const handleClick = (e) => {
|
|
693
|
-
if (onClick)
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
if (
|
|
699
|
-
|
|
700
|
-
|
|
908
|
+
if (onClick) {
|
|
909
|
+
onClick(e);
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
if (href) {
|
|
913
|
+
if ((href.includes("#") ? href.split("#")[1] : null) && navigate !== defaultNavigate) {
|
|
914
|
+
e.preventDefault();
|
|
915
|
+
navigate(href);
|
|
701
916
|
}
|
|
702
917
|
}
|
|
703
918
|
};
|
|
@@ -705,8 +920,9 @@ function OnThisPageLink({ children, href, active, onClick, className }) {
|
|
|
705
920
|
ref: anchorRef,
|
|
706
921
|
href,
|
|
707
922
|
onClick: handleClick,
|
|
708
|
-
"data-active": computedActive,
|
|
709
|
-
|
|
923
|
+
"data-active": computedActive || void 0,
|
|
924
|
+
"aria-current": computedActive ? "true" : void 0,
|
|
925
|
+
className,
|
|
710
926
|
children
|
|
711
927
|
});
|
|
712
928
|
}
|
|
@@ -716,7 +932,9 @@ function OnThisPageIndicator({ style, className }) {
|
|
|
716
932
|
opacity: 0,
|
|
717
933
|
...style
|
|
718
934
|
});
|
|
935
|
+
const items = useItems();
|
|
719
936
|
useEffect(() => {
|
|
937
|
+
if (items.length === 0) return;
|
|
720
938
|
const parent = containerRef.current?.parentElement;
|
|
721
939
|
if (!parent) return;
|
|
722
940
|
const activeLinks = parent.querySelectorAll("a[data-active=\"true\"]");
|
|
@@ -738,10 +956,11 @@ function OnThisPageIndicator({ style, className }) {
|
|
|
738
956
|
opacity: 0,
|
|
739
957
|
...style
|
|
740
958
|
});
|
|
741
|
-
}, [
|
|
959
|
+
}, [items, style]);
|
|
742
960
|
return /* @__PURE__ */ jsx("div", {
|
|
743
961
|
ref: containerRef,
|
|
744
|
-
|
|
962
|
+
"data-otp-indicator": true,
|
|
963
|
+
className: cn("absolute", className),
|
|
745
964
|
style: {
|
|
746
965
|
transition: "transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1), height 180ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 150ms",
|
|
747
966
|
...internalStyle
|
|
@@ -751,16 +970,18 @@ function OnThisPageIndicator({ style, className }) {
|
|
|
751
970
|
/**
|
|
752
971
|
* High-level automated list of toc items
|
|
753
972
|
*/
|
|
754
|
-
function OnThisPageItems({ headings = [], className }) {
|
|
973
|
+
function OnThisPageItems({ headings = [], className, itemClassName, linkClassName, indicatorClassName }) {
|
|
755
974
|
const activeIds = useActiveAnchors();
|
|
756
975
|
if (headings.length === 0) return null;
|
|
757
976
|
return /* @__PURE__ */ jsxs(OnThisPageList, {
|
|
758
977
|
className,
|
|
759
|
-
children: [/* @__PURE__ */ jsx(OnThisPageIndicator, {}), headings.map((h) => /* @__PURE__ */ jsx(OnThisPageItem, {
|
|
978
|
+
children: [/* @__PURE__ */ jsx(OnThisPageIndicator, { className: indicatorClassName }), headings.map((h) => /* @__PURE__ */ jsx(OnThisPageItem, {
|
|
760
979
|
level: h.level,
|
|
980
|
+
className: itemClassName,
|
|
761
981
|
children: /* @__PURE__ */ jsx(OnThisPageLink, {
|
|
762
982
|
href: `#${h.id}`,
|
|
763
983
|
active: activeIds.includes(h.id),
|
|
984
|
+
className: linkClassName,
|
|
764
985
|
children: h.text
|
|
765
986
|
})
|
|
766
987
|
}, h.id))]
|
|
@@ -769,7 +990,7 @@ function OnThisPageItems({ headings = [], className }) {
|
|
|
769
990
|
/**
|
|
770
991
|
* High-level automated Table of Contents tree
|
|
771
992
|
*/
|
|
772
|
-
function OnThisPageTree({ headings = [], className }) {
|
|
993
|
+
function OnThisPageTree({ headings = [], className, itemClassName, linkClassName, indicatorClassName, fadeClassName, contentClassName }) {
|
|
773
994
|
const toc = useMemo(() => headings.map((h) => ({
|
|
774
995
|
title: h.text,
|
|
775
996
|
url: `#${h.id}`,
|
|
@@ -779,14 +1000,19 @@ function OnThisPageTree({ headings = [], className }) {
|
|
|
779
1000
|
if (headings.length === 0) return null;
|
|
780
1001
|
return /* @__PURE__ */ jsx(AnchorProvider, {
|
|
781
1002
|
toc,
|
|
782
|
-
single:
|
|
1003
|
+
single: true,
|
|
783
1004
|
children: /* @__PURE__ */ jsx(ScrollProvider, {
|
|
784
1005
|
containerRef: scrollContainerRef,
|
|
785
1006
|
children: /* @__PURE__ */ jsx(OnThisPageContent, {
|
|
786
1007
|
ref: scrollContainerRef,
|
|
1008
|
+
fadeClassName,
|
|
1009
|
+
className: contentClassName,
|
|
787
1010
|
children: /* @__PURE__ */ jsx(OnThisPageItems, {
|
|
788
1011
|
headings,
|
|
789
|
-
className
|
|
1012
|
+
className,
|
|
1013
|
+
itemClassName,
|
|
1014
|
+
linkClassName,
|
|
1015
|
+
indicatorClassName
|
|
790
1016
|
})
|
|
791
1017
|
})
|
|
792
1018
|
})
|
|
@@ -811,18 +1037,10 @@ function PageNav({ children, className }) {
|
|
|
811
1037
|
});
|
|
812
1038
|
}
|
|
813
1039
|
function PageNavLink({ children, to, direction, className }) {
|
|
814
|
-
|
|
815
|
-
return /* @__PURE__ */ jsxs(Link$1, {
|
|
1040
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
816
1041
|
href: to,
|
|
817
|
-
className: cn("flex items-center outline-none no-underline",
|
|
818
|
-
children
|
|
819
|
-
!isNext && /* @__PURE__ */ jsx(ChevronLeft, { className: "shrink-0" }),
|
|
820
|
-
/* @__PURE__ */ jsx("div", {
|
|
821
|
-
className: "flex flex-col flex-1",
|
|
822
|
-
children
|
|
823
|
-
}),
|
|
824
|
-
isNext && /* @__PURE__ */ jsx(ChevronRight, { className: "shrink-0" })
|
|
825
|
-
]
|
|
1042
|
+
className: cn("flex items-center outline-none no-underline", direction === "next" ? "justify-end" : "justify-start", className),
|
|
1043
|
+
children
|
|
826
1044
|
});
|
|
827
1045
|
}
|
|
828
1046
|
function PageNavTitle({ children, className }) {
|
|
@@ -837,8 +1055,11 @@ function PageNavDescription({ children, className }) {
|
|
|
837
1055
|
children
|
|
838
1056
|
});
|
|
839
1057
|
}
|
|
840
|
-
function PageNavIcon({ children }) {
|
|
841
|
-
return /* @__PURE__ */ jsx(
|
|
1058
|
+
function PageNavIcon({ children, className }) {
|
|
1059
|
+
return /* @__PURE__ */ jsx("span", {
|
|
1060
|
+
className: cn("shrink-0", className),
|
|
1061
|
+
children
|
|
1062
|
+
});
|
|
842
1063
|
}
|
|
843
1064
|
PageNav.Root = PageNav;
|
|
844
1065
|
PageNav.Link = PageNavLink;
|
|
@@ -850,27 +1071,20 @@ PageNav.Icon = PageNavIcon;
|
|
|
850
1071
|
//#region src/client/components/primitives/sidebar.tsx
|
|
851
1072
|
let sidebarScrollPos = 0;
|
|
852
1073
|
function getIcon(iconName) {
|
|
853
|
-
|
|
854
|
-
const icons = {
|
|
855
|
-
...icons_exports,
|
|
856
|
-
...virtualIcons
|
|
857
|
-
};
|
|
858
|
-
return icons[iconName] || icons[iconName + "Icon"] || void 0;
|
|
1074
|
+
return resolveIcon(iconName);
|
|
859
1075
|
}
|
|
860
1076
|
/**
|
|
861
|
-
* Internal Badge component for links
|
|
1077
|
+
* Internal Badge component for links.
|
|
1078
|
+
*
|
|
1079
|
+
* Carries no colors — the theme styles it via `data-badge`.
|
|
862
1080
|
*/
|
|
863
|
-
function Badge({ badge }) {
|
|
864
|
-
const
|
|
865
|
-
|
|
866
|
-
updated: "bg-emerald-500/10 text-emerald-500 border border-emerald-500/20",
|
|
867
|
-
deprecated: "bg-danger-500/10 text-danger-500 border border-danger-500/20"
|
|
868
|
-
};
|
|
869
|
-
const text = typeof badge === "string" ? badge : badge?.text;
|
|
870
|
-
if (!text) return null;
|
|
1081
|
+
function Badge({ badge, badgeClassName }) {
|
|
1082
|
+
const type = typeof badge === "string" ? badge : badge?.text;
|
|
1083
|
+
if (!type) return null;
|
|
871
1084
|
return /* @__PURE__ */ jsx("span", {
|
|
872
|
-
|
|
873
|
-
|
|
1085
|
+
"data-badge": type,
|
|
1086
|
+
className: cn("ml-auto shrink-0", badgeClassName),
|
|
1087
|
+
children: type
|
|
874
1088
|
});
|
|
875
1089
|
}
|
|
876
1090
|
/**
|
|
@@ -878,24 +1092,25 @@ function Badge({ badge }) {
|
|
|
878
1092
|
*/
|
|
879
1093
|
function SidebarRoot({ children, className }) {
|
|
880
1094
|
return /* @__PURE__ */ jsx("aside", {
|
|
881
|
-
|
|
1095
|
+
"data-sidebar-root": true,
|
|
1096
|
+
className,
|
|
882
1097
|
children
|
|
883
1098
|
});
|
|
884
1099
|
}
|
|
885
1100
|
/**
|
|
886
1101
|
* Mobile Sidebar Modal
|
|
887
1102
|
*/
|
|
888
|
-
function SidebarMobile({ children, className }) {
|
|
1103
|
+
function SidebarMobile({ children, className, overlayClassName, dialogClassName }) {
|
|
889
1104
|
const { isSidebarOpen, closeSidebar } = useUI();
|
|
890
1105
|
return /* @__PURE__ */ jsx(RAC.ModalOverlay, {
|
|
891
1106
|
isOpen: isSidebarOpen,
|
|
892
1107
|
onOpenChange: (open) => !open && closeSidebar(),
|
|
893
1108
|
isDismissable: true,
|
|
894
|
-
className: cn("
|
|
1109
|
+
className: cn("lg:hidden", overlayClassName),
|
|
895
1110
|
children: /* @__PURE__ */ jsx(RAC.Modal, {
|
|
896
|
-
className: cn("
|
|
1111
|
+
className: cn("lg:hidden", className),
|
|
897
1112
|
children: /* @__PURE__ */ jsx(RAC.Dialog, {
|
|
898
|
-
className: "h-full
|
|
1113
|
+
className: cn("h-full flex flex-col outline-none focus:outline-none", dialogClassName),
|
|
899
1114
|
children
|
|
900
1115
|
})
|
|
901
1116
|
})
|
|
@@ -906,12 +1121,15 @@ function SidebarMobile({ children, className }) {
|
|
|
906
1121
|
*/
|
|
907
1122
|
function SidebarHeader({ children, className }) {
|
|
908
1123
|
return /* @__PURE__ */ jsx("div", {
|
|
909
|
-
className
|
|
1124
|
+
className,
|
|
910
1125
|
children
|
|
911
1126
|
});
|
|
912
1127
|
}
|
|
913
1128
|
/**
|
|
914
1129
|
* Scrollable Content Wrapper
|
|
1130
|
+
*
|
|
1131
|
+
* The scroll container doubles as the semantic `<nav>` landmark. State and
|
|
1132
|
+
* scroll-position handling live here; all visuals belong to the theme.
|
|
915
1133
|
*/
|
|
916
1134
|
function SidebarContent({ children, className }) {
|
|
917
1135
|
const scrollRef = useRef(null);
|
|
@@ -927,107 +1145,143 @@ function SidebarContent({ children, className }) {
|
|
|
927
1145
|
el.addEventListener("scroll", handleScroll, { passive: true });
|
|
928
1146
|
return () => el.removeEventListener("scroll", handleScroll);
|
|
929
1147
|
}, []);
|
|
930
|
-
return /* @__PURE__ */ jsx("
|
|
1148
|
+
return /* @__PURE__ */ jsx("nav", {
|
|
931
1149
|
ref: scrollRef,
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
children
|
|
936
|
-
})
|
|
1150
|
+
"data-sidebar-content": true,
|
|
1151
|
+
className,
|
|
1152
|
+
children
|
|
937
1153
|
});
|
|
938
1154
|
}
|
|
939
1155
|
/**
|
|
940
1156
|
* Navigation Group
|
|
941
1157
|
*/
|
|
942
|
-
function SidebarGroup({ title, icon: Icon, children, className, collapsible = false, collapsed = false, active = false }) {
|
|
1158
|
+
function SidebarGroup({ title, icon: Icon, children, className, collapsible = false, collapsed = false, active = false, headerClassName, iconClassName, titleClassName, contentClassName, trailing, trailingClassName, renderTitle }) {
|
|
943
1159
|
const [isOpen, setIsOpen] = useState(() => active || !collapsed);
|
|
944
|
-
|
|
945
|
-
if (active !== prevActive) {
|
|
946
|
-
setPrevActive(active);
|
|
1160
|
+
useEffect(() => {
|
|
947
1161
|
if (active) setIsOpen(true);
|
|
948
|
-
}
|
|
1162
|
+
}, [active]);
|
|
1163
|
+
const titleContent = title && /* @__PURE__ */ jsxs("span", {
|
|
1164
|
+
className: cn("flex items-center gap-2", titleClassName),
|
|
1165
|
+
children: [Icon && /* @__PURE__ */ jsx(IconRenderer, {
|
|
1166
|
+
icon: Icon,
|
|
1167
|
+
size: 12,
|
|
1168
|
+
className: iconClassName
|
|
1169
|
+
}), title]
|
|
1170
|
+
});
|
|
949
1171
|
return /* @__PURE__ */ jsxs("div", {
|
|
1172
|
+
"data-group": true,
|
|
1173
|
+
"data-active": active || void 0,
|
|
1174
|
+
"data-collapsible": collapsible || void 0,
|
|
950
1175
|
className,
|
|
951
|
-
children: [title && (
|
|
1176
|
+
children: [title && (renderTitle ? renderTitle({
|
|
1177
|
+
title,
|
|
1178
|
+
isOpen
|
|
1179
|
+
}) : collapsible ? /* @__PURE__ */ jsxs("button", {
|
|
952
1180
|
onClick: () => setIsOpen(!isOpen),
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
}), /* @__PURE__ */ jsx(ChevronRight, {
|
|
1181
|
+
"aria-expanded": isOpen,
|
|
1182
|
+
"data-open": isOpen || void 0,
|
|
1183
|
+
className: cn("group flex w-full cursor-pointer items-center justify-between gap-2 text-left outline-none", headerClassName),
|
|
1184
|
+
children: [titleContent, trailing ?? /* @__PURE__ */ jsx(ChevronRight, {
|
|
958
1185
|
size: 12,
|
|
959
|
-
|
|
1186
|
+
"data-open": isOpen || void 0,
|
|
1187
|
+
className: cn("shrink-0 transition-transform duration-200", isOpen && "rotate-90")
|
|
960
1188
|
})]
|
|
961
1189
|
}) : /* @__PURE__ */ jsxs("h4", {
|
|
962
|
-
className: "
|
|
963
|
-
children: [
|
|
1190
|
+
className: cn("flex items-center gap-2 outline-none", headerClassName),
|
|
1191
|
+
children: [titleContent, trailing && /* @__PURE__ */ jsx("span", {
|
|
1192
|
+
className: cn("ml-auto", trailingClassName),
|
|
1193
|
+
children: trailing
|
|
1194
|
+
})]
|
|
964
1195
|
})), (!collapsible || isOpen) && /* @__PURE__ */ jsx("div", {
|
|
965
|
-
className: "flex flex-col
|
|
1196
|
+
className: cn("flex flex-col", contentClassName),
|
|
966
1197
|
children
|
|
967
1198
|
})]
|
|
968
1199
|
});
|
|
969
1200
|
}
|
|
970
|
-
function SidebarLink({ label, href, active, icon: Icon, badge, className }) {
|
|
971
|
-
|
|
1201
|
+
function SidebarLink({ label, href, active, icon: Icon, badge, className, iconClassName, labelClassName, badgeClassName, children, trailing, depth }) {
|
|
1202
|
+
const linkRef = useRef(null);
|
|
1203
|
+
useEffect(() => {
|
|
1204
|
+
if (active && linkRef.current?.scrollIntoView) linkRef.current.scrollIntoView({ block: "nearest" });
|
|
1205
|
+
}, [active]);
|
|
1206
|
+
return /* @__PURE__ */ jsxs(Link, {
|
|
1207
|
+
ref: linkRef,
|
|
972
1208
|
href,
|
|
973
|
-
|
|
1209
|
+
"data-active": active || void 0,
|
|
1210
|
+
"data-depth": depth !== void 0 ? depth : void 0,
|
|
1211
|
+
"aria-current": active ? "page" : void 0,
|
|
1212
|
+
className: cn("group flex items-center gap-2.5 outline-none", className),
|
|
974
1213
|
children: [
|
|
975
|
-
Icon && /* @__PURE__ */ jsx(
|
|
1214
|
+
Icon && /* @__PURE__ */ jsx(IconRenderer, {
|
|
1215
|
+
icon: Icon,
|
|
976
1216
|
size: 16,
|
|
977
|
-
className: cn(
|
|
1217
|
+
className: cn("shrink-0", iconClassName)
|
|
978
1218
|
}),
|
|
979
|
-
/* @__PURE__ */ jsx("span", {
|
|
980
|
-
className: "truncate",
|
|
1219
|
+
children ?? /* @__PURE__ */ jsx("span", {
|
|
1220
|
+
className: cn("truncate", labelClassName),
|
|
981
1221
|
children: label
|
|
982
1222
|
}),
|
|
983
|
-
badge && /* @__PURE__ */ jsx(Badge, {
|
|
1223
|
+
badge && /* @__PURE__ */ jsx(Badge, {
|
|
1224
|
+
badge,
|
|
1225
|
+
badgeClassName
|
|
1226
|
+
}),
|
|
1227
|
+
trailing
|
|
984
1228
|
]
|
|
985
1229
|
});
|
|
986
1230
|
}
|
|
987
1231
|
/**
|
|
988
1232
|
* Nested SubGroup
|
|
989
1233
|
*/
|
|
990
|
-
function SidebarSubGroup({ label, href, active, icon: Icon, badge, isOpen, onToggle, children, className }) {
|
|
1234
|
+
function SidebarSubGroup({ label, href, active, icon: Icon, badge, isOpen, onToggle, children, className, rootClassName, linkClassName, contentClassName, toggleClassName, wrapperClassName, renderToggle, depth }) {
|
|
991
1235
|
return /* @__PURE__ */ jsxs("div", {
|
|
992
|
-
className: "flex flex-col
|
|
1236
|
+
className: cn("flex flex-col", rootClassName),
|
|
993
1237
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
994
|
-
className: "group relative flex items-center",
|
|
1238
|
+
className: cn("group relative flex items-center", wrapperClassName),
|
|
995
1239
|
children: [/* @__PURE__ */ jsx(SidebarLink, {
|
|
996
1240
|
label,
|
|
997
1241
|
href,
|
|
998
1242
|
active,
|
|
999
1243
|
icon: Icon,
|
|
1000
1244
|
badge,
|
|
1001
|
-
|
|
1002
|
-
|
|
1245
|
+
depth,
|
|
1246
|
+
className: cn("flex-1 pr-8", linkClassName, className)
|
|
1247
|
+
}), renderToggle ? renderToggle({ isOpen }) : /* @__PURE__ */ jsx("button", {
|
|
1003
1248
|
onClick: (e) => {
|
|
1004
1249
|
e.preventDefault();
|
|
1005
1250
|
e.stopPropagation();
|
|
1006
1251
|
onToggle();
|
|
1007
1252
|
},
|
|
1008
|
-
|
|
1253
|
+
"aria-expanded": isOpen,
|
|
1254
|
+
"data-open": isOpen || void 0,
|
|
1255
|
+
className: cn("absolute right-1 cursor-pointer outline-none", toggleClassName),
|
|
1009
1256
|
children: /* @__PURE__ */ jsx(ChevronRight, {
|
|
1010
1257
|
size: 14,
|
|
1258
|
+
"data-open": isOpen || void 0,
|
|
1011
1259
|
className: cn("transition-transform duration-200", isOpen && "rotate-90")
|
|
1012
1260
|
})
|
|
1013
1261
|
})]
|
|
1014
1262
|
}), isOpen && /* @__PURE__ */ jsx("div", {
|
|
1015
|
-
className: "
|
|
1263
|
+
className: cn("flex flex-col", contentClassName),
|
|
1016
1264
|
children
|
|
1017
1265
|
})]
|
|
1018
1266
|
});
|
|
1019
1267
|
}
|
|
1020
|
-
function SidebarItem({ route, activePath, activeRoute, className }) {
|
|
1268
|
+
function SidebarItem({ route, activePath, activeRoute, className, depth = 0, renderItem, classNames }) {
|
|
1021
1269
|
const localizedHref = useLocalizedTo(route.path);
|
|
1022
1270
|
const isCurrent = activePath === (localizedHref.endsWith("/") ? localizedHref.slice(0, -1) : localizedHref) || !!activeRoute?.filePath && !!route.filePath && activeRoute.filePath === route.filePath;
|
|
1023
1271
|
const hasChildren = !!route.routes?.length || !!route.subRoutes?.length;
|
|
1024
1272
|
const children = route.routes || route.subRoutes;
|
|
1025
|
-
const
|
|
1026
|
-
const [
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1273
|
+
const shouldBeOpen = activePath.startsWith(localizedHref) || !!activeRoute?.filePath && !!route.filePath && activeRoute.filePath === route.filePath;
|
|
1274
|
+
const [isOpen, setIsOpen] = useState(() => shouldBeOpen);
|
|
1275
|
+
useEffect(() => {
|
|
1276
|
+
if (shouldBeOpen) setIsOpen(true);
|
|
1277
|
+
}, [shouldBeOpen]);
|
|
1278
|
+
const renderChild = (subRoute) => /* @__PURE__ */ jsx(Fragment, { children: renderItem ? renderItem(subRoute, depth + 1) : /* @__PURE__ */ jsx(SidebarItem, {
|
|
1279
|
+
route: subRoute,
|
|
1280
|
+
activePath,
|
|
1281
|
+
activeRoute,
|
|
1282
|
+
depth: depth + 1,
|
|
1283
|
+
classNames
|
|
1284
|
+
}) }, subRoute.path);
|
|
1031
1285
|
if (hasChildren) return /* @__PURE__ */ jsx(SidebarSubGroup, {
|
|
1032
1286
|
label: route.title,
|
|
1033
1287
|
href: route.path,
|
|
@@ -1036,12 +1290,13 @@ function SidebarItem({ route, activePath, activeRoute, className }) {
|
|
|
1036
1290
|
badge: route.badge,
|
|
1037
1291
|
isOpen,
|
|
1038
1292
|
onToggle: () => setIsOpen(!isOpen),
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1293
|
+
depth,
|
|
1294
|
+
rootClassName: classNames?.subgroup,
|
|
1295
|
+
linkClassName: cn(classNames?.subgroupLink, className),
|
|
1296
|
+
contentClassName: classNames?.subgroupContent,
|
|
1297
|
+
toggleClassName: classNames?.toggle,
|
|
1298
|
+
wrapperClassName: classNames?.subgroupWrapper,
|
|
1299
|
+
children: children?.map(renderChild)
|
|
1045
1300
|
});
|
|
1046
1301
|
return /* @__PURE__ */ jsx(SidebarLink, {
|
|
1047
1302
|
label: route.title,
|
|
@@ -1049,67 +1304,74 @@ function SidebarItem({ route, activePath, activeRoute, className }) {
|
|
|
1049
1304
|
active: isCurrent,
|
|
1050
1305
|
icon: getIcon(route.icon),
|
|
1051
1306
|
badge: route.badge,
|
|
1052
|
-
|
|
1307
|
+
depth,
|
|
1308
|
+
className: cn(classNames?.item, className),
|
|
1309
|
+
iconClassName: classNames?.itemIcon,
|
|
1310
|
+
labelClassName: classNames?.itemLabel,
|
|
1311
|
+
badgeClassName: classNames?.itemBadge
|
|
1053
1312
|
});
|
|
1054
1313
|
}
|
|
1055
|
-
|
|
1056
|
-
const
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
group
|
|
1075
|
-
}))].sort((a, b) => {
|
|
1076
|
-
if (a.position !== b.position) return a.position - b.position;
|
|
1077
|
-
if (a.type !== b.type) return a.type === "link" ? -1 : 1;
|
|
1078
|
-
return a.title.localeCompare(b.title);
|
|
1079
|
-
});
|
|
1314
|
+
function SidebarItems({ routes, className, classNames, componentItem, componentGroup }) {
|
|
1315
|
+
const { merged, activePath, activeRoute, isGroupActive } = useSidebar(routes);
|
|
1316
|
+
const renderItem = (route, depth) => {
|
|
1317
|
+
if (componentItem) return componentItem({
|
|
1318
|
+
route,
|
|
1319
|
+
activePath,
|
|
1320
|
+
activeRoute,
|
|
1321
|
+
isActive: isRouteActive(route, activePath, activeRoute),
|
|
1322
|
+
depth
|
|
1323
|
+
});
|
|
1324
|
+
return /* @__PURE__ */ jsx(SidebarItem, {
|
|
1325
|
+
route,
|
|
1326
|
+
activePath,
|
|
1327
|
+
activeRoute,
|
|
1328
|
+
depth,
|
|
1329
|
+
renderItem,
|
|
1330
|
+
classNames
|
|
1331
|
+
});
|
|
1332
|
+
};
|
|
1080
1333
|
const renderedElements = [];
|
|
1081
1334
|
let currentUngrouped = [];
|
|
1082
1335
|
const pushUngrouped = () => {
|
|
1083
1336
|
if (currentUngrouped.length > 0) {
|
|
1084
1337
|
const routesToRender = [...currentUngrouped];
|
|
1085
|
-
renderedElements.push(/* @__PURE__ */ jsx(SidebarGroup, {
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1338
|
+
renderedElements.push(/* @__PURE__ */ jsx(SidebarGroup, {
|
|
1339
|
+
className: classNames?.group,
|
|
1340
|
+
headerClassName: classNames?.groupHeader,
|
|
1341
|
+
iconClassName: classNames?.groupIcon,
|
|
1342
|
+
titleClassName: classNames?.groupTitle,
|
|
1343
|
+
contentClassName: classNames?.groupContent,
|
|
1344
|
+
children: routesToRender.map((route) => /* @__PURE__ */ jsx(Fragment, { children: renderItem(route, 0) }, route.path))
|
|
1345
|
+
}, `ungrouped-${routesToRender[0]?.path || "root"}`));
|
|
1090
1346
|
currentUngrouped = [];
|
|
1091
1347
|
}
|
|
1092
1348
|
};
|
|
1093
|
-
for (const item of
|
|
1349
|
+
for (const item of merged) if (item.type === "link") currentUngrouped.push(item.route);
|
|
1094
1350
|
else {
|
|
1095
1351
|
pushUngrouped();
|
|
1096
|
-
const
|
|
1097
|
-
|
|
1352
|
+
const groupActive = isGroupActive(item.group);
|
|
1353
|
+
const groupChildren = item.group.routes.map((route) => /* @__PURE__ */ jsx(Fragment, { children: renderItem(route, 1) }, route.path));
|
|
1354
|
+
renderedElements.push(componentGroup ? /* @__PURE__ */ jsx(Fragment, { children: componentGroup({
|
|
1355
|
+
group: item.group,
|
|
1356
|
+
isGroupActive: groupActive,
|
|
1357
|
+
children: groupChildren
|
|
1358
|
+
}) }, item.group.title) : /* @__PURE__ */ jsx(SidebarGroup, {
|
|
1098
1359
|
title: item.group.title,
|
|
1099
1360
|
icon: getIcon(item.group.icon),
|
|
1100
1361
|
collapsible: item.group.collapsible,
|
|
1101
1362
|
collapsed: item.group.collapsed,
|
|
1102
|
-
active:
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1363
|
+
active: groupActive,
|
|
1364
|
+
className: classNames?.group,
|
|
1365
|
+
headerClassName: classNames?.groupHeader,
|
|
1366
|
+
iconClassName: classNames?.groupIcon,
|
|
1367
|
+
titleClassName: classNames?.groupTitle,
|
|
1368
|
+
contentClassName: classNames?.groupContent,
|
|
1369
|
+
children: groupChildren
|
|
1108
1370
|
}, item.group.title));
|
|
1109
1371
|
}
|
|
1110
1372
|
pushUngrouped();
|
|
1111
1373
|
return /* @__PURE__ */ jsx("div", {
|
|
1112
|
-
className
|
|
1374
|
+
className,
|
|
1113
1375
|
children: renderedElements
|
|
1114
1376
|
});
|
|
1115
1377
|
}
|
|
@@ -1166,12 +1428,13 @@ function Content({ children, className, style }) {
|
|
|
1166
1428
|
children
|
|
1167
1429
|
});
|
|
1168
1430
|
}
|
|
1169
|
-
function ContentMdx({ children, className, style }) {
|
|
1431
|
+
function ContentMdx({ children, className, style, contentClassName, contentStyle }) {
|
|
1170
1432
|
return /* @__PURE__ */ jsxs("div", {
|
|
1171
|
-
className: cn("boltdocs-page w-full
|
|
1433
|
+
className: cn("boltdocs-page w-full", className),
|
|
1172
1434
|
style,
|
|
1173
1435
|
children: [/* @__PURE__ */ jsx(SearchHighlight, {}), /* @__PURE__ */ jsx("div", {
|
|
1174
|
-
className: "mx-auto w-full max-w-3xl sm:max-w-4xl lg:max-w-5xl",
|
|
1436
|
+
className: cn("mx-auto w-full max-w-3xl sm:max-w-4xl lg:max-w-5xl", contentClassName),
|
|
1437
|
+
style: contentStyle,
|
|
1175
1438
|
children
|
|
1176
1439
|
})]
|
|
1177
1440
|
});
|
|
@@ -1183,20 +1446,12 @@ function Header({ children, className, style }) {
|
|
|
1183
1446
|
children
|
|
1184
1447
|
});
|
|
1185
1448
|
}
|
|
1186
|
-
function Footer({ children, className, style }) {
|
|
1187
|
-
return /* @__PURE__ */ jsx("div", {
|
|
1188
|
-
className: cn("mt-20", className),
|
|
1189
|
-
style,
|
|
1190
|
-
children
|
|
1191
|
-
});
|
|
1192
|
-
}
|
|
1193
1449
|
const DocsLayout = Object.assign(DocsLayoutRoot, {
|
|
1194
1450
|
Body,
|
|
1195
1451
|
Content,
|
|
1196
1452
|
ContentMdx,
|
|
1197
|
-
Header
|
|
1198
|
-
Footer
|
|
1453
|
+
Header
|
|
1199
1454
|
});
|
|
1200
1455
|
|
|
1201
1456
|
//#endregion
|
|
1202
|
-
export {
|
|
1457
|
+
export { UIProvider as A, IconRenderer as C, Popover$1 as D, Menu as E, ButtonGroup as O, useSidebar as S, Tabs as T, ScrollProvider as _, SidebarHeader as a, useItems as b, SidebarLink as c, SidebarSubGroup as d, PageNav as f, OnThisPageTree as g, OnThisPageItems as h, SidebarGroup as i, useUI as j, Breadcrumbs$1 as k, SidebarMobile as l, OnThisPage as m, Sidebar as n, SidebarItem as o, AnchorProvider as p, SidebarContent as r, SidebarItems as s, DocsLayout as t, SidebarRoot as u, useActiveAnchor as v, resolveIcon as w, useSearchHighlight as x, useActiveAnchors as y };
|