boltdocs 3.3.5 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{adapters-BKzKe2mO.mjs → adapters-BXiBWAKs.mjs} +1 -1
- package/dist/{adapters-DwDTQoCG.cjs → adapters-Czl3WtQt.cjs} +1 -1
- package/dist/{build-B672n0hL.cjs → build-CNkXRdk8.cjs} +1 -1
- package/dist/{build-BVoMHMhw.mjs → build-CqUBsXVC.mjs} +1 -1
- package/dist/client/index.cjs +245 -56
- package/dist/client/index.d.cts +3 -3
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.js +246 -60
- package/dist/client/mdx.cjs +1 -1
- package/dist/client/mdx.js +1 -1
- package/dist/client/primitives.cjs +5 -5
- package/dist/client/primitives.d.cts +92 -42
- package/dist/client/primitives.d.ts +101 -51
- package/dist/client/primitives.js +4 -4
- package/dist/client/router.cjs +1 -1
- package/dist/client/router.d.cts +1 -1
- package/dist/client/router.d.ts +1 -1
- package/dist/client/router.js +1 -1
- package/dist/client/theme/reset.css +41 -0
- package/dist/config-B3SEoVjG.cjs +7 -0
- package/dist/{config-PLvresCv.cjs → config-Bfakeadu.cjs} +1 -1
- package/dist/config-CTcfF-0c.mjs +7 -0
- package/dist/dev-D1DmOSjn.mjs +6 -0
- package/dist/dev-DH6cSge8.cjs +6 -0
- package/dist/{docs-layout-CbZ7LDRe.js → docs-layout-CmntYM6p.js} +46 -147
- package/dist/{docs-layout-vzfXed1Q.cjs → docs-layout-DIgxJ5c7.cjs} +23 -130
- package/dist/{doctor-DMECtdK6.cjs → doctor-BLxm2alc.cjs} +1 -1
- package/dist/{doctor-FuFY1jBz.cjs → doctor-Dd-JMTRo.cjs} +1 -1
- package/dist/{doctor-i8Qmd8DJ.mjs → doctor-DogHujrP.mjs} +1 -1
- package/dist/{image-Hnaa2bJd.cjs → image-Bke2ojW1.cjs} +3 -3
- package/dist/{image-B-NDSDuY.js → image-CaY2w0ua.js} +2 -1
- package/dist/index--xbYbT8N.d.ts +343 -0
- package/dist/{index-Bg-JtZeK.d.cts → index-B_o5y34l.d.cts} +112 -13
- package/dist/{index-B3o307nd.d.ts → index-Bx0CUd7Q.d.ts} +112 -13
- package/dist/index-RK7W_Fxy.d.cts +343 -0
- package/dist/{link-CgdI6O2o.js → link-CSe_oD8Y.js} +137 -139
- package/dist/{link-vZjmD-es.cjs → link-Xb69Oy2F.cjs} +144 -169
- package/dist/{mdx-D0Absdq5.cjs → mdx-BCOrMd-P.cjs} +68 -16
- package/dist/{mdx-BRT71V5Q.js → mdx-BijiEbkp.js} +62 -15
- package/dist/{native-nLA4Jr0T.cjs → native-BbtRkce5.cjs} +1 -1
- package/dist/node/cli-entry.cjs +1 -1
- package/dist/node/cli-entry.mjs +1 -1
- package/dist/node/highlight.d.cts +2 -2
- package/dist/node/highlight.d.mts +2 -2
- package/dist/node/index.cjs +1 -1
- package/dist/node/index.d.cts +19 -37
- package/dist/node/index.d.mts +20 -38
- package/dist/node/index.mjs +1 -1
- package/dist/node/mdx/shiki-adapter.cjs +1 -1
- package/dist/node/mdx/shiki-adapter.d.cts +7 -2
- package/dist/node/mdx/shiki-adapter.d.mts +7 -2
- package/dist/node/mdx/shiki-adapter.mjs +1 -1
- package/dist/node-BgiLCa0I.cjs +39 -0
- package/dist/node-Da3tYBHo.mjs +39 -0
- package/dist/{package-CNqjEYE1.cjs → package-D1gVs5gQ.cjs} +1 -1
- package/dist/{package-sdcKhDhe.mjs → package-YgQJn3Yh.mjs} +1 -1
- package/dist/pages-external-B_r6gvqP.cjs +6 -0
- package/dist/pages-external-jmK7AHaO.mjs +6 -0
- package/dist/{parser-CD8Oo8qh.mjs → parser-CvNZc5s3.mjs} +1 -1
- package/dist/{parser-vPaKvzLp.cjs → parser-DJLWTiO-.cjs} +1 -1
- package/dist/plugin-DW9K2fW5.mjs +69 -0
- package/dist/plugin-NwGKyTJX.cjs +69 -0
- package/dist/{plugin-context-DuSg-Hax.mjs → plugin-context-COh-cbsW.mjs} +1 -1
- package/dist/{plugin-context-CscLcXjH.cjs → plugin-context-FIHaWn6r.cjs} +2 -2
- package/dist/{plugin-lifecycle-BywrEoWK.cjs → plugin-lifecycle-D9fTRaWY.cjs} +1 -1
- package/dist/{registry-BbB6NqSv.d.cts → registry-BFmzj1yg.d.mts} +1 -1
- package/dist/{registry-sJqDv0kE.d.mts → registry-BoswPzYV.d.cts} +1 -1
- package/dist/{resolve-C5rT6B21.mjs → resolve-5puUe7eS.mjs} +1 -1
- package/dist/{resolve-BelytNYR.cjs → resolve-CF4ZLfqx.cjs} +1 -1
- package/dist/route-paths-B6ocUfNY.cjs +6 -0
- package/dist/route-paths-DyDji4bX.mjs +6 -0
- package/dist/{router-CZBxMRAH.js → router-B5e8k4qK.js} +175 -10
- package/dist/{router-C3kygdRK.cjs → router-DKC0Lu0n.cjs} +204 -9
- package/dist/{routes-C3_w9fLX.cjs → routes-D55M8UrH.cjs} +1 -1
- package/dist/routes-DdE6Lfcl.cjs +6 -0
- package/dist/routes-_I_8PQYF.mjs +6 -0
- package/dist/{search-dialog-x_qHU8ty.cjs → search-dialog-BOQRHKTb.cjs} +197 -24
- package/dist/{search-dialog-BqkzDTq2.js → search-dialog-BXil4_7P.js} +190 -29
- package/dist/search-dialog-CwlBd-Mu.cjs +747 -0
- package/dist/{search-dialog-B9mdxsUC.js → search-dialog-D3Obh3eA.js} +1 -1
- package/dist/search-dialog-DeplpVEB.js +717 -0
- package/dist/{search-dialog-DCtm2dyR.cjs → search-dialog-cHXR5zhL.cjs} +1 -1
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.d.mts +1 -1
- package/dist/server/index.mjs +1 -1
- package/dist/ssg-static-options-Br1_u9qp.mjs +6 -0
- package/dist/ssg-static-options-CVvGKM8i.cjs +6 -0
- package/dist/types-58Ac3UGI.d.cts +114 -0
- package/dist/types-BwnGf-1E.d.mts +114 -0
- package/dist/virtual-modules-C4-qxFlL.cjs +40 -0
- package/dist/virtual-modules-DiWUKJGP.mjs +40 -0
- package/package.json +8 -5
- package/src/shared/types.ts +133 -987
- package/dist/config-CrsQJHQz.cjs +0 -7
- package/dist/config-DC0nMMk7.mjs +0 -7
- package/dist/dev-B49V6O6p.mjs +0 -6
- package/dist/dev-DbuhNcF5.cjs +0 -6
- package/dist/index-CgWkOCCn.d.cts +0 -1193
- package/dist/index-CuNSD3E2.d.ts +0 -1193
- package/dist/node-BljvHMpS.cjs +0 -23
- package/dist/node-CWxGw4H4.mjs +0 -23
- package/dist/pages-external-BBw8ObVK.mjs +0 -6
- package/dist/pages-external-DPiPFxxP.cjs +0 -6
- package/dist/plugin-BPcm1cU0.mjs +0 -69
- package/dist/plugin-WUhxnpko.cjs +0 -69
- package/dist/routes-C0kb4ue6.cjs +0 -6
- package/dist/routes-C4wrLWwu.mjs +0 -6
- package/dist/search-dialog-Bp_ouN1c.cjs +0 -550
- package/dist/search-dialog-an2BNMj6.js +0 -526
- package/dist/types-Db6zToZH.d.mts +0 -975
- package/dist/types-o7iZ2BAR.d.cts +0 -975
- package/dist/virtual-modules-B2X4Ht2r.mjs +0 -39
- package/dist/virtual-modules-DPsdHKcu.cjs +0 -39
- /package/dist/{audit-CMc_ydRr.mjs → audit-CYAkXXvP.mjs} +0 -0
- /package/dist/{audit-CHkGiV3c.cjs → audit-DxCZZTuX.cjs} +0 -0
- /package/dist/{csp-BiGAG8aF.cjs → csp-B-gc2Iha.cjs} +0 -0
- /package/dist/{csp-D0BOH8ae.mjs → csp-f8DOcI_7.mjs} +0 -0
- /package/dist/{generator-BCrZL53x.cjs → generator-CBAPKY6r.cjs} +0 -0
- /package/dist/{generator-CFukoGa0.mjs → generator-MRpn-yp6.mjs} +0 -0
- /package/dist/{handler-Lex5DbvG.mjs → handler-DBZqoWt2.mjs} +0 -0
- /package/dist/{handler-Ch-Q9NAB.cjs → handler-ryZR9Q41.cjs} +0 -0
- /package/dist/{index-HAwIo4nZ.d.mts → index-CPr34I2C.d.mts} +0 -0
- /package/dist/{native-BYKMke79.mjs → native-DZ6WMwjG.mjs} +0 -0
- /package/dist/{native-BOet8hpE.cjs → native-DeKxny_T.cjs} +0 -0
- /package/dist/{update-check-BXD1atVv.mjs → update-check-BXx8te9F.mjs} +0 -0
- /package/dist/{update-check-DFQZyoSU.cjs → update-check-CiIeC7CX.cjs} +0 -0
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
* Copyright (c) 2026 Jesus Alcala
|
|
4
4
|
* Licensed under the MIT License.
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import { E as useLocation } from "./router-
|
|
6
|
+
import { B as X, E as Hash, F as MoreVertical, P as Moon, R as Sun, T as FileText, a as useLocalizedTo, b as CornerDownLeft, i as cn, t as Link, u as resolvePublicAssetUrl, x as ExternalLink } from "./link-CSe_oD8Y.js";
|
|
7
|
+
import { E as useLocation, V as useConfig } from "./router-B5e8k4qK.js";
|
|
8
8
|
import { Component, useEffect, useState } from "react";
|
|
9
9
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
10
|
import * as RAC from "react-aria-components";
|
|
11
|
-
import { Button, Dialog, Modal, ModalOverlay, Separator, ToggleButton } from "react-aria-components";
|
|
11
|
+
import { Autocomplete, Button, Dialog, Input, ListBox, ListBoxItem, Modal, ModalOverlay, SearchField, Separator, ToggleButton } from "react-aria-components";
|
|
12
12
|
|
|
13
13
|
//#region src/client/components/primitives/button.tsx
|
|
14
14
|
function Button$1({ ...props }) {
|
|
@@ -39,6 +39,15 @@ var ErrorBoundary = class extends Component {
|
|
|
39
39
|
error: null
|
|
40
40
|
});
|
|
41
41
|
};
|
|
42
|
+
prevResetKeys = [];
|
|
43
|
+
componentDidUpdate(prevProps) {
|
|
44
|
+
if (prevProps.resetKeys !== this.props.resetKeys && this.state.hasError && this.props.resetKeys?.length && this.props.resetKeys.some((key, i) => !Object.is(key, this.prevResetKeys[i]))) {
|
|
45
|
+
this.prevResetKeys = this.props.resetKeys;
|
|
46
|
+
this.resetErrorBoundary();
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
this.prevResetKeys = this.props.resetKeys ?? [];
|
|
50
|
+
}
|
|
42
51
|
render() {
|
|
43
52
|
const { hasError, error } = this.state;
|
|
44
53
|
const { children, fallback, FallbackComponent } = this.props;
|
|
@@ -149,13 +158,46 @@ function NavbarCenter({ children, className }) {
|
|
|
149
158
|
children
|
|
150
159
|
});
|
|
151
160
|
}
|
|
152
|
-
function NavbarLogo({ src, alt, width = 24, height = 24, className, logoClassName, href = "/" }) {
|
|
161
|
+
function NavbarLogo({ src, srcLight, srcDark, alt, width = 24, height = 24, className, logoClassName, logoLightClassName, logoDarkClassName, href = "/" }) {
|
|
153
162
|
const config = useConfig();
|
|
163
|
+
const light = srcLight ?? src;
|
|
164
|
+
const hasPair = Boolean(srcDark) && srcDark !== light;
|
|
165
|
+
const resolve = (value) => resolvePublicAssetUrl(value, config.base);
|
|
154
166
|
return /* @__PURE__ */ jsx(Link, {
|
|
155
167
|
href,
|
|
156
168
|
className: cn("flex items-center gap-2 shrink-0 outline-none", className),
|
|
157
|
-
children:
|
|
158
|
-
|
|
169
|
+
children: hasPair ? /* @__PURE__ */ jsxs(
|
|
170
|
+
Fragment$1,
|
|
171
|
+
/**
|
|
172
|
+
* Both variants are always in the DOM and CSS picks the visible one.
|
|
173
|
+
*
|
|
174
|
+
* Rendering only the active source would make the markup depend on the
|
|
175
|
+
* resolved theme, which the server cannot know: it would render one
|
|
176
|
+
* `src` while the browser renders the other, the hoisted preload `href`
|
|
177
|
+
* would no longer match, and React would throw away the server HTML
|
|
178
|
+
* with a hydration mismatch. Two elements that are identical on both
|
|
179
|
+
* sides cost one extra request-free `<img>` and remove the whole class
|
|
180
|
+
* of bug.
|
|
181
|
+
*/
|
|
182
|
+
{ children: [/* @__PURE__ */ jsx("img", {
|
|
183
|
+
src: resolve(light),
|
|
184
|
+
alt,
|
|
185
|
+
width,
|
|
186
|
+
height,
|
|
187
|
+
fetchPriority: "high",
|
|
188
|
+
"data-logo-theme": "light",
|
|
189
|
+
className: cn("h-6 w-6 object-contain dark:hidden", logoClassName, logoLightClassName)
|
|
190
|
+
}), /* @__PURE__ */ jsx("img", {
|
|
191
|
+
src: resolve(srcDark),
|
|
192
|
+
alt,
|
|
193
|
+
width,
|
|
194
|
+
height,
|
|
195
|
+
"data-logo-theme": "dark",
|
|
196
|
+
"aria-hidden": "true",
|
|
197
|
+
className: cn("hidden h-6 w-6 object-contain dark:block", logoClassName, logoDarkClassName)
|
|
198
|
+
})] }
|
|
199
|
+
) : src ? /* @__PURE__ */ jsx("img", {
|
|
200
|
+
src: resolve(src),
|
|
159
201
|
alt,
|
|
160
202
|
width,
|
|
161
203
|
height,
|
|
@@ -165,17 +207,20 @@ function NavbarLogo({ src, alt, width = 24, height = 24, className, logoClassNam
|
|
|
165
207
|
});
|
|
166
208
|
}
|
|
167
209
|
function NavbarTitle({ children, className, linkClassName, href = "/" }) {
|
|
210
|
+
const titleText = typeof children === "string" || typeof children === "number" ? String(children) : void 0;
|
|
168
211
|
return /* @__PURE__ */ jsx(Link, {
|
|
169
212
|
href,
|
|
170
213
|
className: cn(linkClassName),
|
|
214
|
+
"aria-label": titleText ? `Go to ${titleText} home` : void 0,
|
|
171
215
|
children: /* @__PURE__ */ jsx("span", {
|
|
172
216
|
className: cn("text-lg font-bold tracking-tight hidden sm:inline-block", className),
|
|
173
217
|
children
|
|
174
218
|
})
|
|
175
219
|
});
|
|
176
220
|
}
|
|
177
|
-
function NavbarLinks({ children, className }) {
|
|
221
|
+
function NavbarLinks({ children, className, label }) {
|
|
178
222
|
return /* @__PURE__ */ jsx("nav", {
|
|
223
|
+
"aria-label": label,
|
|
179
224
|
className: cn("hidden md:flex items-center gap-6 text-sm font-medium", className),
|
|
180
225
|
children
|
|
181
226
|
});
|
|
@@ -184,6 +229,7 @@ function NavbarLink({ label, href, to, className, iconClassName }) {
|
|
|
184
229
|
return /* @__PURE__ */ jsxs(Link, {
|
|
185
230
|
href,
|
|
186
231
|
target: to === "external" ? "_blank" : void 0,
|
|
232
|
+
prefetch: to === "external" ? "none" : "viewport",
|
|
187
233
|
className: cn("transition-all outline-none", className),
|
|
188
234
|
children: [label, to === "external" && /* @__PURE__ */ jsx("span", {
|
|
189
235
|
className: cn("ml-1 inline-block", iconClassName),
|
|
@@ -236,18 +282,20 @@ function NavbarDropdownItem({ href, label, className }) {
|
|
|
236
282
|
children: label
|
|
237
283
|
});
|
|
238
284
|
}
|
|
239
|
-
function NavbarSearchTriggerDesktop({ className, onPress, children }) {
|
|
285
|
+
function NavbarSearchTriggerDesktop({ className, onPress, children, ...props }) {
|
|
240
286
|
return /* @__PURE__ */ jsx(Button, {
|
|
287
|
+
...props,
|
|
241
288
|
onPress,
|
|
242
289
|
className: cn("hidden lg:flex items-center justify-between gap-2 px-3 py-2 text-sm outline-none cursor-pointer w-full max-w-[720px]", className),
|
|
243
290
|
children
|
|
244
291
|
});
|
|
245
292
|
}
|
|
246
|
-
function NavbarSearchTriggerMobile({ className, onPress, children }) {
|
|
293
|
+
function NavbarSearchTriggerMobile({ className, onPress, children, ...props }) {
|
|
247
294
|
return /* @__PURE__ */ jsx(Button, {
|
|
295
|
+
...props,
|
|
248
296
|
onPress,
|
|
249
297
|
className: cn("lg:hidden flex h-10 w-10 items-center justify-center outline-none cursor-pointer", className),
|
|
250
|
-
"aria-label": "Search",
|
|
298
|
+
"aria-label": props["aria-label"] || "Search",
|
|
251
299
|
children
|
|
252
300
|
});
|
|
253
301
|
}
|
|
@@ -330,6 +378,7 @@ function NavbarMobileMenu({ isOpen, onClose, children, className, overlayClassNa
|
|
|
330
378
|
children: /* @__PURE__ */ jsx(X, { size: 24 })
|
|
331
379
|
})]
|
|
332
380
|
}), /* @__PURE__ */ jsx("nav", {
|
|
381
|
+
"aria-label": "Mobile navigation",
|
|
333
382
|
className: cn("flex-1 overflow-y-auto flex flex-col gap-4", navClassName),
|
|
334
383
|
children
|
|
335
384
|
})]
|
|
@@ -405,69 +454,181 @@ Navbar.MobileMenu = NavbarMobileMenu;
|
|
|
405
454
|
Navbar.MobileLink = NavbarMobileLink;
|
|
406
455
|
Navbar.MobileLinkItem = NavbarMobileLinkItem;
|
|
407
456
|
|
|
457
|
+
//#endregion
|
|
458
|
+
//#region src/client/hooks/use-search-highlight.ts
|
|
459
|
+
/**
|
|
460
|
+
* Hook to highlight search terms based on the 'hl' query parameter.
|
|
461
|
+
*/
|
|
462
|
+
function useSearchHighlight(containerSelector = ".boltdocs-page") {
|
|
463
|
+
const { search } = useLocation();
|
|
464
|
+
const query = new URLSearchParams(search).get("hl");
|
|
465
|
+
useEffect(() => {
|
|
466
|
+
if (!query) {
|
|
467
|
+
clearHighlights(containerSelector);
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
const container = document.querySelector(containerSelector);
|
|
471
|
+
if (!container) return;
|
|
472
|
+
const target = container;
|
|
473
|
+
let rafId;
|
|
474
|
+
const observer = new MutationObserver((mutations) => {
|
|
475
|
+
if (mutations.some((m) => {
|
|
476
|
+
const addedNodes = Array.from(m.addedNodes);
|
|
477
|
+
const removedNodes = Array.from(m.removedNodes);
|
|
478
|
+
return addedNodes.some((n) => !(n instanceof HTMLElement && n.hasAttribute("data-search-highlight"))) || removedNodes.some((n) => !(n instanceof HTMLElement && n.hasAttribute("data-search-highlight")));
|
|
479
|
+
})) run();
|
|
480
|
+
});
|
|
481
|
+
function run() {
|
|
482
|
+
cancelAnimationFrame(rafId);
|
|
483
|
+
rafId = requestAnimationFrame(() => {
|
|
484
|
+
observer.disconnect();
|
|
485
|
+
clearHighlights(containerSelector);
|
|
486
|
+
const terms = (query ?? "").split(/\s+/).map((t) => t.trim()).filter((t) => t.length >= 2);
|
|
487
|
+
if (terms.length > 0) highlightTerms(target, terms);
|
|
488
|
+
observer.observe(target, {
|
|
489
|
+
childList: true,
|
|
490
|
+
subtree: true
|
|
491
|
+
});
|
|
492
|
+
});
|
|
493
|
+
}
|
|
494
|
+
run();
|
|
495
|
+
return () => {
|
|
496
|
+
cancelAnimationFrame(rafId);
|
|
497
|
+
observer.disconnect();
|
|
498
|
+
clearHighlights(containerSelector);
|
|
499
|
+
};
|
|
500
|
+
}, [query, containerSelector]);
|
|
501
|
+
}
|
|
502
|
+
function clearHighlights(selector) {
|
|
503
|
+
document.querySelectorAll(`${selector} mark[data-search-highlight]`).forEach((mark) => {
|
|
504
|
+
try {
|
|
505
|
+
const parent = mark.parentNode;
|
|
506
|
+
if (parent?.contains(mark)) {
|
|
507
|
+
const text = mark.textContent || "";
|
|
508
|
+
parent.replaceChild(document.createTextNode(text), mark);
|
|
509
|
+
}
|
|
510
|
+
} catch {}
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
function createSearchHighlightRegex(terms) {
|
|
514
|
+
const accentMap = {
|
|
515
|
+
a: "[aáàäâãåāăą]",
|
|
516
|
+
c: "[cçćč]",
|
|
517
|
+
d: "[dďđ]",
|
|
518
|
+
e: "[eéèëêėęě]",
|
|
519
|
+
g: "[gğģ]",
|
|
520
|
+
i: "[iíìïîīįı]",
|
|
521
|
+
l: "[lĺļł]",
|
|
522
|
+
n: "[nñńň]",
|
|
523
|
+
o: "[oóòöôõøōő]",
|
|
524
|
+
r: "[rřŕ]",
|
|
525
|
+
s: "[sśšş]",
|
|
526
|
+
t: "[tťţ]",
|
|
527
|
+
u: "[uúùüûūůűų]",
|
|
528
|
+
y: "[yýÿ]",
|
|
529
|
+
z: "[zžźż]"
|
|
530
|
+
};
|
|
531
|
+
const escapeTerm = (term) => [...term].map((char) => {
|
|
532
|
+
return accentMap[char.toLocaleLowerCase()] ?? char.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
533
|
+
}).join("");
|
|
534
|
+
const uniqueTerms = [...new Set(terms.map((term) => term.trim()).filter(Boolean))].sort((left, right) => right.length - left.length);
|
|
535
|
+
if (uniqueTerms.length === 0) return null;
|
|
536
|
+
return new RegExp(`(${uniqueTerms.map(escapeTerm).join("|")})`, "gi");
|
|
537
|
+
}
|
|
538
|
+
function highlightTerms(container, terms) {
|
|
539
|
+
const walker = document.createTreeWalker(container, NodeFilter.SHOW_TEXT, { acceptNode: (node) => {
|
|
540
|
+
const parent = node.parentElement;
|
|
541
|
+
if (parent && (parent.tagName === "SCRIPT" || parent.tagName === "STYLE" || parent.tagName === "MARK" || parent.closest("pre") || parent.closest("code"))) return NodeFilter.FILTER_REJECT;
|
|
542
|
+
return NodeFilter.FILTER_ACCEPT;
|
|
543
|
+
} });
|
|
544
|
+
const nodes = [];
|
|
545
|
+
let node = walker.nextNode();
|
|
546
|
+
while (node) {
|
|
547
|
+
nodes.push(node);
|
|
548
|
+
node = walker.nextNode();
|
|
549
|
+
}
|
|
550
|
+
const regex = createSearchHighlightRegex(terms);
|
|
551
|
+
if (!regex) return;
|
|
552
|
+
nodes.forEach((textNode) => {
|
|
553
|
+
const text = textNode.textContent;
|
|
554
|
+
regex.lastIndex = 0;
|
|
555
|
+
if (text && regex.test(text)) {
|
|
556
|
+
const fragment = document.createDocumentFragment();
|
|
557
|
+
text.split(regex).forEach((part, index) => {
|
|
558
|
+
if (index % 2 === 1) {
|
|
559
|
+
const mark = document.createElement("mark");
|
|
560
|
+
mark.textContent = part;
|
|
561
|
+
mark.setAttribute("data-search-highlight", "true");
|
|
562
|
+
fragment.appendChild(mark);
|
|
563
|
+
} else if (part) fragment.appendChild(document.createTextNode(part));
|
|
564
|
+
});
|
|
565
|
+
if (textNode.parentNode) textNode.parentNode.replaceChild(fragment, textNode);
|
|
566
|
+
}
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
|
|
408
570
|
//#endregion
|
|
409
571
|
//#region src/client/components/primitives/search-dialog.tsx
|
|
410
572
|
/**
|
|
411
|
-
* Pure, unstyled SearchDialog Overlay (maps to
|
|
573
|
+
* Pure, unstyled SearchDialog Overlay (maps to ModalOverlay)
|
|
412
574
|
*/
|
|
413
575
|
function SearchDialog({ className, ...props }) {
|
|
414
|
-
return /* @__PURE__ */ jsx(
|
|
576
|
+
return /* @__PURE__ */ jsx(ModalOverlay, {
|
|
415
577
|
className: cn("fixed inset-0 z-100", className),
|
|
416
578
|
...props
|
|
417
579
|
});
|
|
418
580
|
}
|
|
419
581
|
/**
|
|
420
|
-
* Pure, unstyled SearchDialog Content (maps to
|
|
582
|
+
* Pure, unstyled SearchDialog Content (maps to Modal)
|
|
421
583
|
*/
|
|
422
584
|
function SearchDialogContent({ className, ...props }) {
|
|
423
|
-
return /* @__PURE__ */ jsx(
|
|
585
|
+
return /* @__PURE__ */ jsx(Modal, {
|
|
424
586
|
className: cn(className),
|
|
425
587
|
...props
|
|
426
588
|
});
|
|
427
589
|
}
|
|
428
590
|
/**
|
|
429
|
-
* Pure, unstyled SearchDialog Dialog (maps to
|
|
591
|
+
* Pure, unstyled SearchDialog Dialog (maps to Dialog)
|
|
430
592
|
*/
|
|
431
593
|
function SearchDialogDialog({ children, className, ...props }) {
|
|
432
|
-
return /* @__PURE__ */ jsx(
|
|
594
|
+
return /* @__PURE__ */ jsx(Dialog, {
|
|
433
595
|
className: cn("flex flex-col focus:outline-none", className),
|
|
434
596
|
...props,
|
|
435
597
|
children
|
|
436
598
|
});
|
|
437
599
|
}
|
|
438
600
|
/**
|
|
439
|
-
* Pure, unstyled SearchDialog Input Field (maps to
|
|
601
|
+
* Pure, unstyled SearchDialog Input Field (maps to SearchField)
|
|
440
602
|
*/
|
|
441
603
|
function SearchDialogField({ className, ...props }) {
|
|
442
|
-
return /* @__PURE__ */ jsx(
|
|
604
|
+
return /* @__PURE__ */ jsx(SearchField, {
|
|
443
605
|
className: cn("flex items-center", className),
|
|
444
606
|
...props
|
|
445
607
|
});
|
|
446
608
|
}
|
|
447
609
|
/**
|
|
448
|
-
* Pure, unstyled SearchInput (maps to
|
|
610
|
+
* Pure, unstyled SearchInput (maps to Input)
|
|
449
611
|
*/
|
|
450
612
|
function SearchDialogSearchInput({ className, ...props }) {
|
|
451
|
-
return /* @__PURE__ */ jsx(
|
|
613
|
+
return /* @__PURE__ */ jsx(Input, {
|
|
452
614
|
className: cn("w-full bg-transparent outline-none border-none", className),
|
|
453
615
|
...props
|
|
454
616
|
});
|
|
455
617
|
}
|
|
456
618
|
/**
|
|
457
|
-
* Pure, unstyled Clear Button (maps to
|
|
619
|
+
* Pure, unstyled Clear Button (maps to Button with slot="clear")
|
|
458
620
|
*/
|
|
459
621
|
function SearchDialogClearButton({ className, ...props }) {
|
|
460
|
-
return /* @__PURE__ */ jsx(
|
|
622
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
461
623
|
slot: "clear",
|
|
462
624
|
className: cn(className),
|
|
463
625
|
...props
|
|
464
626
|
});
|
|
465
627
|
}
|
|
466
628
|
/**
|
|
467
|
-
* Pure, unstyled Autocomplete container (maps to
|
|
629
|
+
* Pure, unstyled Autocomplete container (maps to Autocomplete)
|
|
468
630
|
*/
|
|
469
631
|
function SearchDialogAutocomplete({ children, className, innerClassName, ...props }) {
|
|
470
|
-
const Autocomplete = RAC.Autocomplete;
|
|
471
632
|
return /* @__PURE__ */ jsx("div", {
|
|
472
633
|
className: cn("flex-1 min-h-0", className),
|
|
473
634
|
children: /* @__PURE__ */ jsx(Autocomplete, {
|
|
@@ -478,20 +639,20 @@ function SearchDialogAutocomplete({ children, className, innerClassName, ...prop
|
|
|
478
639
|
});
|
|
479
640
|
}
|
|
480
641
|
/**
|
|
481
|
-
* Pure, unstyled List Box (maps to
|
|
642
|
+
* Pure, unstyled List Box (maps to ListBox)
|
|
482
643
|
*/
|
|
483
644
|
function SearchDialogList({ children, className, ...props }) {
|
|
484
|
-
return /* @__PURE__ */ jsx(
|
|
645
|
+
return /* @__PURE__ */ jsx(ListBox, {
|
|
485
646
|
...props,
|
|
486
647
|
className: cn("flex-1 overflow-y-auto outline-none min-h-0", className),
|
|
487
648
|
children
|
|
488
649
|
});
|
|
489
650
|
}
|
|
490
651
|
/**
|
|
491
|
-
* Pure, unstyled List Box Item (maps to
|
|
652
|
+
* Pure, unstyled List Box Item (maps to ListBoxItem)
|
|
492
653
|
*/
|
|
493
654
|
function SearchDialogItemRoot({ children, className, hintClassName, renderHint, ...props }) {
|
|
494
|
-
return /* @__PURE__ */ jsx(
|
|
655
|
+
return /* @__PURE__ */ jsx(ListBoxItem, {
|
|
495
656
|
...props,
|
|
496
657
|
className: cn("group flex items-center outline-none cursor-pointer", className),
|
|
497
658
|
children: (itemProps) => /* @__PURE__ */ jsxs(Fragment$1, { children: [children, renderHint ? renderHint({
|
|
@@ -541,4 +702,4 @@ SearchDialog.Item = Object.assign(SearchDialogItemRoot, {
|
|
|
541
702
|
});
|
|
542
703
|
|
|
543
704
|
//#endregion
|
|
544
|
-
export {
|
|
705
|
+
export { Github as a, Button$1 as c, Navbar as i, createSearchHighlightRegex as n, ErrorBoundary as o, useSearchHighlight as r, ErrorBoundaryFallback as s, SearchDialog as t };
|